flattr.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. (function ($, undefined) {
  11. "use strict";
  12. function get (self, options, uri, settings, name) {
  13. var value = options[name];
  14. if (typeof value === "function") {
  15. return value.call(self, options, uri, settings);
  16. }
  17. return String(value);
  18. }
  19. // using an unsupported language breaks the flattr button
  20. 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};
  21. $.fn.socialSharePrivacy.settings.services.flattr = {
  22. 'status' : true,
  23. 'button_class' : 'flattr',
  24. 'dummy_line_img' : 'images/dummy_flattr.png',
  25. 'dummy_box_img' : 'images/dummy_box_flattr.png',
  26. 'dummy_alt' : '"Flattr"-Dummy',
  27. '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>.',
  28. 'txt_off' : 'not connected to Flattr',
  29. 'txt_on' : 'connected to Flattr',
  30. 'perma_option' : true,
  31. 'display_name' : 'Flattr',
  32. 'referrer_track' : '',
  33. 'title' : $.fn.socialSharePrivacy.getTitle,
  34. 'description' : $.fn.socialSharePrivacy.getDescription,
  35. 'uid' : '',
  36. 'category' : '',
  37. 'tags' : '',
  38. 'popout' : '',
  39. 'hidden' : '',
  40. 'button' : function (options, uri, settings) {
  41. var attrs = {
  42. href : uri + options.referrer_track,
  43. title : get(this, options, uri, settings, 'title')
  44. };
  45. if (options.uid) attrs['data-flattr-uid'] = options.uid;
  46. if (options.hidden) attrs['data-flattr-hidden'] = options.hidden;
  47. if (options.popout) attrs['data-flattr-popout'] = options.popout;
  48. if (options.category) attrs['data-flattr-category'] = options.category;
  49. if (options.tags) attrs['data-flattr-tags'] = options.tags;
  50. if (options.language) {
  51. var lang = String(options.language).replace('-','_');
  52. var baselang = lang.split('_')[0];
  53. if (langs[baselang] === true) {
  54. attrs['data-flattr-language'] = attrs.lang = lang;
  55. }
  56. }
  57. if (settings.layout === 'line') attrs['data-flattr-button'] = 'compact';
  58. var $code = $('<a class="FlattrButton">' + get(this, options, uri, settings, 'description') +
  59. '</a><script text="text/javscript" src="'+
  60. 'https://api.flattr.com/js/0.6/load.js?mode=auto"></script>');
  61. $code.filter('a').attr(attrs);
  62. return $code;
  63. }
  64. };
  65. })(jQuery);