1/* 2 * jquery.socialshareprivacy.js | 2 Klicks fuer mehr Datenschutz 3 * 4 * http://www.heise.de/extras/socialshareprivacy/ 5 * http://www.heise.de/ct/artikel/2-Klicks-fuer-mehr-Datenschutz-1333879.html 6 * 7 * Copyright (c) 2011 Hilko Holweg, Sebastian Hilbig, Nicolas Heiringhoff, Juergen Schmidt, 8 * Heise Zeitschriften Verlag GmbH & Co. KG, http://www.heise.de 9 * 10 * Copyright (c) 2012 Mathias Panzenböck 11 * 12 * is released under the MIT License http://www.opensource.org/licenses/mit-license.php 13 * 14 * Spread the word, link to us if you can. 15 */ 16 17(function ($, undefined) { 18 "use strict"; 19 20 function get (self, options, uri, settings, name) { 21 var value = options[name]; 22 if (typeof value === "function") { 23 return value.call(self, options, uri, settings); 24 } 25 return String(value); 26 } 27 28 var loadingScript = false; 29 function loadScript () { 30 // prevent already loaded buttons from being broken: 31 $('.social_share_privacy_area .pinterest .pinit a[data-pin-log]').attr('data-pin-do','ignore'); 32 var prot = 'https:' === document.location.protocol ? 'https:' : 'http:'; 33 $.ajax({ 34 url : prot+'//assets.pinterest.com/js/pinit.js', 35 dataType : 'script', 36 cache : true 37 }); 38 // because there is no callback yet I have no choice but to do this now: 39 loadingScript = false; 40 } 41 42 $.fn.socialSharePrivacy.settings.services.pinterest = { 43 'status' : true, 44 'button_class' : 'pinit', 45 'dummy_line_img' : 'images/dummy_pinit.png', 46 'dummy_box_img' : 'images/dummy_box_pinit.png', 47 'dummy_alt' : '"Pin it"-Dummy', 48 'txt_info' : 'Two clicks for more privacy: The Pin it button will be enabled once you click here. Activating the button already sends data to Pinterest – see <em>i</em>.', 49 'txt_off' : 'not connected to Pinterest', 50 'txt_on' : 'connected to Pinterest', 51 'perma_option' : true, 52 'display_name' : 'Pinterest', 53 'referrer_track' : '', 54 'title' : $.fn.socialSharePrivacy.getTitle, 55 'description' : $.fn.socialSharePrivacy.getDescription, 56 'media' : $.fn.socialSharePrivacy.getImage, 57 'button' : function (options, uri, settings) { 58 var prot = 'https:' === document.location.protocol ? 'https:' : 'http:'; 59 var params = { 60 url : uri + options.referrer_track, 61 media : get(this, options, uri, settings, 'media') 62 }; 63 var title = get(this, options, uri, settings, 'title'); 64 var description = get(this, options, uri, settings, 'description'); 65 if (title) params.title = title; 66 if (description) params.description = description; 67 68 var $code = $('<a data-pin-do="buttonPin"><img /></a>'); 69 70 $code.filter('a').attr({ 71 'data-pin-config' : settings.layout === 'line' ? 'beside' : 'above', 72 href : prot+'//pinterest.com/pin/create/button/?'+$.param(params) 73 }).find('img').attr('src', prot+'//assets.pinterest.com/images/pidgets/pin_it_button.png'); 74 75 // This way when the user has permanently enabled pinterest and there are several pinterest 76 // buttons on one webpage it will load the script only once and so the buttons will work: 77 if (!loadingScript) { 78 loadingScript = true; 79 setTimeout(loadScript, 10); 80 } 81 82 return $code; 83 } 84 }; 85})(jQuery); 86