1/*
2 * jquery.socialshareprivacy.js | 2 Klicks fuer mehr Datenschutz
3 *
4 * Copyright (c) 2012 Mathias Panzenböck
5 *
6 * is released under the MIT License http://www.opensource.org/licenses/mit-license.php
7 *
8 * Spread the word, link to us if you can.
9 */
10
11(function ($, undefined) {
12	"use strict";
13
14	function get (self, options, uri, settings, name) {
15		var value = options[name];
16		if (typeof value === "function") {
17			return value.call(self, options, uri, settings);
18		}
19		return String(value);
20	}
21
22	// using an unsupported language breaks the flattr button
23	var langs = {en:true,sq:true,ar:true,be:true,bg:true,ca:true,zh:true,hr:true,cs:true,da:true,nl:true,eo:true,et:true,fi:true,fr:true,es:true,de:true,el:true,iw:true,hi:true,hu:true,is:true,'in':true,ga:true,it:true,ja:true,ko:true,lv:true,lt:true,mk:true,ms:true,mt:true,no:true,nn:true,fa:true,pl:true,pt:true,ro:true,ru:true,sr:true,sk:true,sl:true,sv:true,th:true,tr:true,uk:true,vi:true};
24
25	$.fn.socialSharePrivacy.settings.services.flattr = {
26		'status'            : true,
27		'button_class'      : 'flatter',
28		'dummy_line_img'    : 'images/dummy_flattr.png',
29		'dummy_box_img'     : 'images/dummy_box_flattr.png',
30		'dummy_alt'         : '"Flattr"-Dummy',
31		'txt_info'          : 'Two clicks for more privacy: The Flattr button will be enabled once you click here. Activating the button already sends data to Flattr &ndash; see <em>i</em>.',
32		'txt_off'           : 'not connected to Flattr',
33		'txt_on'            : 'connected to Flattr',
34		'perma_option'      : true,
35		'display_name'      : 'Flattr',
36		'referrer_track'    : '',
37		'title'             : $.fn.socialSharePrivacy.getTitle,
38		'description'       : $.fn.socialSharePrivacy.getDescription,
39		'uid'               : '',
40		'category'          : '',
41		'tags'              : '',
42		'popout'            : '',
43		'hidden'            : '',
44		'button'            : function (options, uri, settings) {
45			var attrs = {
46				href                   : uri + options.referrer_track,
47				title                  : get(this, options, uri, settings, 'title')
48			};
49			if (options.uid)      attrs['data-flattr-uid']      = options.uid;
50			if (options.hidden)   attrs['data-flattr-hidden']   = options.hidden;
51			if (options.popout)   attrs['data-flattr-popout']   = options.popout;
52			if (options.category) attrs['data-flattr-category'] = options.category;
53			if (options.tags)     attrs['data-flattr-tags']     = options.tags;
54			if (options.language) {
55				var lang = String(options.language).replace('-','_');
56				var baselang = lang.split('_')[0];
57				if (langs[baselang] === true) {
58					attrs['data-flattr-language'] = attrs.lang = lang;
59				}
60			}
61			if (settings.layout === 'line') attrs['data-flattr-button'] = 'compact';
62
63			var $code = $('<a class="FlattrButton">' + get(this, options, uri, settings, 'description') +
64				'</a><script text="text/javscript" src="'+(location.protocol === 'https:' ? 'https:' : 'http:') +
65				'//api.flattr.com/js/0.6/load.js?mode=auto"></script>');
66
67			$code.filter('a').attr(attrs);
68
69			return $code;
70		}
71	};
72})(jQuery);
73