34 lines
10 KiB
JavaScript
34 lines
10 KiB
JavaScript
/*
|
|
* jquery.socialshareprivacy.js | 2 Klicks fuer mehr Datenschutz
|
|
*
|
|
* http://www.heise.de/extras/socialshareprivacy/
|
|
* http://www.heise.de/ct/artikel/2-Klicks-fuer-mehr-Datenschutz-1333879.html
|
|
*
|
|
* Copyright (c) 2011 Hilko Holweg, Sebastian Hilbig, Nicolas Heiringhoff, Juergen Schmidt,
|
|
* Heise Zeitschriften Verlag GmbH & Co. KG, http://www.heise.de
|
|
*
|
|
* is released under the MIT License http://www.opensource.org/licenses/mit-license.php
|
|
*
|
|
* Spread the word, link to us if you can.
|
|
*/
|
|
(function(b){function x(b,a){var f=decodeURIComponent(b);if(f.length<=a)return b;var j=f.substring(0,a-1).lastIndexOf(" ");return f=encodeURIComponent(f.substring(0,j))+"\u2026"}function p(c){return b('meta[name="'+c+'"]').attr("content")||""}function r(){var c=p("DC.title"),a=p("DC.creator");c.length>0&&a.length>0?c+=" - "+a:c=b("title").text();return encodeURIComponent(c)}function s(){var c=document.location.href,a=b("link[rel=canonical]").attr("href");a&&a.length>0&&(a.indexOf("http")<0&&(a=document.location.protocol+
|
|
"//"+document.location.host+a),c=a);return c}b.fn.socialSharePrivacy=function(c){var a=b.extend(!0,{services:{facebook:{status:"on",dummy_img:"socialshareprivacy/images/dummy_facebook.png",txt_info:"2 Klicks für mehr Datenschutz: Erst wenn Sie hier klicken, wird der Button aktiv und Sie können Ihre Empfehlung an Facebook senden. Schon beim Aktivieren werden Daten an Dritte übertragen – siehe <em>i</em>.",txt_fb_off:"nicht mit Facebook verbunden",txt_fb_on:"mit Facebook verbunden",
|
|
perma_option:"on",display_name:"Facebook",referrer_track:"",language:"de_DE",action:"recommend"},twitter:{status:"on",dummy_img:"socialshareprivacy/images/dummy_twitter.png",txt_info:"2 Klicks für mehr Datenschutz: Erst wenn Sie hier klicken, wird der Button aktiv und Sie können Ihre Empfehlung an Twitter senden. Schon beim Aktivieren werden Daten an Dritte übertragen – siehe <em>i</em>.",txt_twitter_off:"nicht mit Twitter verbunden",txt_twitter_on:"mit Twitter verbunden",perma_option:"on",
|
|
display_name:"Twitter",referrer_track:"",tweet_text:r,language:"en"},gplus:{status:"on",dummy_img:"socialshareprivacy/images/dummy_gplus.png",txt_info:"2 Klicks für mehr Datenschutz: Erst wenn Sie hier klicken, wird der Button aktiv und Sie können Ihre Empfehlung an Google+ senden. Schon beim Aktivieren werden Daten an Dritte übertragen – siehe <em>i</em>.",txt_gplus_off:"nicht mit Google+ verbunden",txt_gplus_on:"mit Google+ verbunden",perma_option:"on",display_name:"Google+",
|
|
referrer_track:"",language:"de"}},info_link:"http://www.heise.de/ct/artikel/2-Klicks-fuer-mehr-Datenschutz-1333879.html",txt_help:"Wenn Sie diese Felder durch einen Klick aktivieren, werden Informationen an Facebook, Twitter oder Google in die USA übertragen und unter Umständen auch dort gespeichert. Näheres erfahren Sie durch einen Klick auf das <em>i</em>.",settings_perma:"Dauerhaft aktivieren und Datenüber­tragung zustimmen:",cookie_path:"/",cookie_domain:document.location.host,
|
|
cookie_expires:"365",css_path:"socialshareprivacy/socialshareprivacy.css",uri:s},c),f=a.services.facebook.status==="on",j=a.services.twitter.status==="on",n=a.services.gplus.status==="on";if(f||j||n)return a.css_path.length>0&&(document.createStyleSheet?document.createStyleSheet(a.css_path):b("head").append('<link rel="stylesheet" type="text/css" href="'+a.css_path+'" />')),this.each(function(){b(this).prepend('<ul class="social_share_privacy_area"></ul>');var d=b(".social_share_privacy_area",this),
|
|
c=a.uri;typeof c==="function"&&(c=c(d));if(f){var g=encodeURIComponent(c+a.services.facebook.referrer_track),p='<iframe src="http://www.facebook.com/plugins/like.php?locale='+a.services.facebook.language+"&href="+g+"&send=false&layout=button_count&width=120&show_faces=false&action="+a.services.facebook.action+'&colorscheme=light&font&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:145px; height:21px;" allowTransparency="true"></iframe>',
|
|
t='<img src="'+a.services.facebook.dummy_img+'" alt="Facebook "Like"-Dummy" class="fb_like_privacy_dummy" />';d.append('<li class="facebook help_info"><span class="info">'+a.services.facebook.txt_info+'</span><span class="switch off">'+a.services.facebook.txt_fb_off+'</span><div class="fb_like dummy_btn">'+t+"</div></li>");var k=b("li.facebook",d);b("li.facebook div.fb_like img.fb_like_privacy_dummy,li.facebook span.switch",d).live("click",function(){k.find("span.switch").hasClass("off")?
|
|
(k.addClass("info_off"),k.find("span.switch").addClass("on").removeClass("off").html(a.services.facebook.txt_fb_on),k.find("img.fb_like_privacy_dummy").replaceWith(p)):(k.removeClass("info_off"),k.find("span.switch").addClass("off").removeClass("on").html(a.services.facebook.txt_fb_off),k.find(".fb_like").html(t))})}if(j){g=a.services.twitter.tweet_text;typeof g==="function"&&(g=g());var g=x(g,"120"),o=encodeURIComponent(c+a.services.twitter.referrer_track),e=encodeURIComponent(c),r='<iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url='+
|
|
o+"&counturl="+e+"&text="+g+"&count=horizontal&lang="+a.services.twitter.language+'" style="width:130px; height:25px;"></iframe>',u='<img src="'+a.services.twitter.dummy_img+'" alt=""Tweet this"-Dummy" class="tweet_this_dummy" />';d.append('<li class="twitter help_info"><span class="info">'+a.services.twitter.txt_info+'</span><span class="switch off">'+a.services.twitter.txt_twitter_off+'</span><div class="tweet dummy_btn">'+u+"</div></li>");var l=b("li.twitter",d);b("li.twitter div.tweet img,li.twitter span.switch",
|
|
d).live("click",function(){l.find("span.switch").hasClass("off")?(l.addClass("info_off"),l.find("span.switch").addClass("on").removeClass("off").html(a.services.twitter.txt_twitter_on),l.find("img.tweet_this_dummy").replaceWith(r)):(l.removeClass("info_off"),l.find("span.switch").addClass("off").removeClass("on").html(a.services.twitter.txt_twitter_off),l.find(".tweet").html(u))})}if(n){var s='<div class="g-plusone" data-size="medium" data-href="'+(c+a.services.gplus.referrer_track)+'"></div><script type="text/javascript">window.___gcfg = {lang: "'+
|
|
a.services.gplus.language+'"}; (function() { var po = document.createElement("script"); po.type = "text/javascript"; po.async = true; po.src = "https://apis.google.com/js/plusone.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(po, s); })(); <\/script>',v='<img src="'+a.services.gplus.dummy_img+'" alt=""Google+1"-Dummy" class="gplus_one_dummy" />';d.append('<li class="gplus help_info"><span class="info">'+a.services.gplus.txt_info+'</span><span class="switch off">'+
|
|
a.services.gplus.txt_gplus_off+'</span><div class="gplusone dummy_btn">'+v+"</div></li>");var m=b("li.gplus",d);b("li.gplus div.gplusone img,li.gplus span.switch",d).live("click",function(){m.find("span.switch").hasClass("off")?(m.addClass("info_off"),m.find("span.switch").addClass("on").removeClass("off").html(a.services.gplus.txt_gplus_on),m.find("img.gplus_one_dummy").replaceWith(s)):(m.removeClass("info_off"),m.find("span.switch").addClass("off").removeClass("on").html(a.services.gplus.txt_gplus_off),
|
|
m.find(".gplusone").html(v))})}d.append('<li class="settings_info"><div class="settings_info_menu off perma_option_off"><a href="'+a.info_link+'"><span class="help_info icon"><span class="info">'+a.txt_help+"</span></span></a></div></li>");b(".help_info:not(.info_off)",d).live("mouseenter",function(){var a=b(this),c=window.setTimeout(function(){b(a).addClass("display")},500);b(this).data("timeout_id",c)});b(".help_info",d).live("mouseleave",function(){var a=b(this).data("timeout_id");window.clearTimeout(a);
|
|
b(this).hasClass("display")&&b(this).removeClass("display")});c=a.services.facebook.perma_option==="on";g=a.services.twitter.perma_option==="on";o=a.services.gplus.perma_option==="on";if((f&&c||j&&g||n&&o)&&(!b.browser.msie||b.browser.msie&&b.browser.version>7)){for(var i=document.cookie.split(";"),e="{",q=0;q<i.length;q+=1){var w=i[q].split("=");e+='"'+b.trim(w[0])+'":"'+b.trim(w[1])+'"';q<i.length-1&&(e+=",")}e+="}";var e=JSON.parse(e),h=b("li.settings_info",d);h.find(".settings_info_menu").removeClass("perma_option_off");
|
|
h.find(".settings_info_menu").append('<span class="settings">Einstellungen</span><form><fieldset><legend>'+a.settings_perma+"</legend></fieldset></form>");f&&c&&(i=e.socialSharePrivacy_facebook==="perma_on"?' checked="checked"':"",h.find("form fieldset").append('<input type="checkbox" name="perma_status_facebook" id="perma_status_facebook"'+i+' /><label for="perma_status_facebook">'+a.services.facebook.display_name+"</label>"));j&&g&&(i=e.socialSharePrivacy_twitter==="perma_on"?' checked="checked"':
|
|
"",h.find("form fieldset").append('<input type="checkbox" name="perma_status_twitter" id="perma_status_twitter"'+i+' /><label for="perma_status_twitter">'+a.services.twitter.display_name+"</label>"));n&&o&&(i=e.socialSharePrivacy_gplus==="perma_on"?' checked="checked"':"",h.find("form fieldset").append('<input type="checkbox" name="perma_status_gplus" id="perma_status_gplus"'+i+' /><label for="perma_status_gplus">'+a.services.gplus.display_name+"</label>"));h.find("span.settings").css("cursor","pointer");
|
|
b(h.find("span.settings"),d).live("mouseenter",function(){var a=window.setTimeout(function(){h.find(".settings_info_menu").removeClass("off").addClass("on")},500);b(this).data("timeout_id",a)});b(h,d).live("mouseleave",function(){var a=b(this).data("timeout_id");window.clearTimeout(a);h.find(".settings_info_menu").removeClass("on").addClass("off")});b(h.find("fieldset input")).live("click",function(c){var e=c.target.id,g="socialSharePrivacy_"+e.substr(e.lastIndexOf("_")+1,e.length);if(b("#"+c.target.id+
|
|
":checked").length){var c=a.cookie_expires,h=a.cookie_path,f=a.cookie_domain,i=new Date;i.setTime(i.getTime()+c*864E5);document.cookie=g+"=perma_on; expires="+i.toUTCString()+"; path="+h+"; domain="+f;b("form fieldset label[for="+e+"]",d).addClass("checked")}else c=a.cookie_path,h=a.cookie_domain,f=new Date,f.setTime(f.getTime()-100),document.cookie=g+"=perma_on; expires="+f.toUTCString()+"; path="+c+"; domain="+h,b("form fieldset label[for="+e+"]",d).removeClass("checked")});f&&c&&e.socialSharePrivacy_facebook===
|
|
"perma_on"&&b("li.facebook span.switch",d).click();j&&g&&e.socialSharePrivacy_twitter==="perma_on"&&b("li.twitter span.switch",d).click();n&&o&&e.socialSharePrivacy_gplus==="perma_on"&&b("li.gplus span.switch",d).click()}})}})(jQuery);
|