PageSourceSearch

https://linnewebergmbh.de/scripts/js/jutho_fbprivacy.js

js linnewebergmbh.de collected 2026-10-06 00:20:40 UTC 16,070 bytes, 345 lines download raw bytes

1/*
2##########################################################################
3
4© JuTho-Agentur, www.jutho.com
5Version 3, 28.04.2016
6
7~~~~~~~~~~~~~~~~~~
8Einbindung
9~~~~~~~~~~~~~~~~~~
10<script src="http://code.jquery.com/jquery-latest.js"></script>
11<script type="text/javascript" src="jutho_fbprivacy.js"></script>
12<link href="jutho_fbprivacy.css" rel="stylesheet">
13
14~~~~~~~~~~~~~~~~~~
15Definition
16~~~~~~~~~~~~~~~~~~
17Sowohl der Facebook-Like-Button als auch das Facebook-Page-Plugin
18werden über ein div mit der Klasse jutho_fbprivacy eingebunden:
19<div class="jutho_fbprivacy" data-lbl-clickable="true" data-class="fb-page" data-href="https://www.facebook.com/jutho.agentur"></div>
20
21Das div kann bzw. sollte dabei mit verschiedenen data-Attributen 
22versehen werden:
23
24data-lbl-off				=> [Text]									: Text des Labels, wenn deaktiviert (Standard: "Facebook - deaktiviert") 
25data-lbl-on					=> [Text]									: Text des Labels, wenn aktiviert (Standard: "Facebook - aktiviert") 
26data-lbl-clickable			=> true,false								: Legt fest, ob über Klick auf das Label das Plugin aktiviert kann.
27data-helper-id				=> [ID eines bestehenden Elementes]			: Wird zunächst ausgeblendet und als Hilfe/Tooltipp beim Überfahren des Labels angezeigt.
28data-class					=> fb-like,fb-page							: Unterscheidung zwischen Like-Button und Page-Plugin
29data-href					=> [URL]									: href des Like-Buttons bzw. URL zur Facebook-Page
30data-width					=> [Zahl]									: Breite des Plugins (Standard: Breite des Elternelements
31data-layout					=> standard,box_count,button_count,button	: Layout des Like-Buttons (Standard: standard) [Nur bei fb-like]
32data-action					=> like,recommend							: Aktion des Like-Buttons (Standard: like) [Nur bei fb-like]
33data-show-faces				=> true,false								: Gesichter von Freunden anzeigen (Standard: true) [Nur bei fb-like]
34data-share					=> true,false								: Button "Teilen" hinzufügen (Standard: false) [Nur bei fb-like]
35data-tabs					=> timeline,events							: Angezeigte Tabs bei Page-Plugin (Standard: timeline) [Nur bei fb-page]
36data-height					=> [Zahl] 									: Mindesthöhe des Plugins (Standard): Höhe des Elternelements [Nur bei fb-page]
37data-small-header			=> true,false								: Kleinen Header verwenden (Standard: true) [Nur bei fb-page]
38data-adapt-container-width	=> true,false								: An Plugin-Container-Breite anpassen (Standard: true) [Nur bei fb-page]
39data-hide-cover				=> true,false								: Titelbild verbergen (Standard: false) [Nur bei fb-page]
40data-show-facepile			=> true,false								: Gesichter der Freunde anzeigen (Standard: true) [Nur bei fb-page]
41
42##########################################################################
43*/
44var lbl_text = "Facebook"; //Standard-Label-Text
45var jutho_FBprivacy_root = false; //Merker für FB-Root - nicht ändern!!!!
46var jutho_FBprivacy_active = "0"; //Merker für Anzahl der aktivierten Plugins - nicht ändern!!!!
47
48$(document).ready(function() {
49	console.log("Facebook-Privacy-Plugin (c) by www.jutho.com");
50	
51	//Buttons vorbereiten
52	var fb_like_buttons = $(".jutho_fbprivacy");
53	$.each(fb_like_buttons, function(i) {
54		var id=$(this).attr("id"); //ID auslesen
55		if(typeof(id)=="undefined") { //Wenn keine ID gesetzt wurde, automatisch vergeben
56			for(var i=1;document.getElementById('jutho_FBprivacy'+i)!=null;i++) {
57				//console.log(i);
58			}
59			$(this).attr("id", "jutho_FBprivacy"+i);
60			id=$(this).attr("id");
61		}
62		//Label-Text bestimmen
63		var lbl_off=$(this).attr("data-lbl-off") || lbl_text+" - deaktiviert";
64		//Helper finden
65		var helper_id=$(this).attr("data-helper-id") || false;
66		//Helper einbinden, entsprechendes Label dazu
67		if(helper_id) {
68			$("#"+helper_id).css("display", "none");
69			$("#"+helper_id).css("position", "absolute");
70			var lbl = "<label id=\"lbl_"+id+"\" class=\"jutho_onoffswitch_label\" onmouseover=\"jutho_FBprivacy_helper_show('"+helper_id+"')\" onmouseout=\"jutho_FBprivacy_helper_hide('"+helper_id+"')\">"+lbl_off+"</label>";
71		}
72		//Label, wenn kein Helper
73		else { 
74			var lbl = "<label id=\"lbl_"+id+"\" class=\"jutho_onoffswitch_label\">"+lbl_off+"</label>";			
75		}
76		
77		var elem=$(this);
78		//Schalter einbinden
79		var switcher = "<div id=\"switcher_"+id+"\" class=\"jutho_onoffswitch off\"><span class=\"bull\" data-inputid=\"\"></span></div>";
80		//Bereich für Späteres Plugin vorsehen
81		var fb_live = "<div id=\"dummy_"+id+"\" style=\"display:none\"></div>";
82		//alles anzeigen
83		$(this).append(switcher, lbl, fb_live);
84		
85		//Event-Handler auf den Switcher
86		$(this).on("click", ".jutho_onoffswitch > .bull", function(e) {
87			jutho_FBprivacy_toggle_likebutton(id);
88		});
89		//Label-Clickable?
90		var clickable=$(this).attr("data-lbl-clickable"); //Data-Clickable auslesen
91		if(clickable=="true") { //Wenn gewollt, dann ergänzen
92			var lbl = document.getElementById("lbl_"+id);
93			lbl.setAttribute("onclick", "jutho_FBprivacy_toggle_likebutton('"+id+"')");
94			lbl.style.cursor = "pointer";
95		}
96	});
97	
98	
99});
100
101function jutho_FBprivacy_toggle_likebutton(id) {
102	var elem=$("#"+id);
103	var switcher=$("#switcher_"+id);
104	var lbl=$("#lbl_"+id);
105	var fblive=$("#dummy_"+id);
106	var lbl_off=elem.attr("data-lbl-off") || lbl_text+" - deaktiviert";
107	var lbl_on=elem.attr("data-lbl-on") || lbl_text+" - aktiviert";;
108	//if(typeof(lbl_off)=="undefined") { lbl_off=lbl_text + " - deaktiviert"; }
109	//if(typeof(lbl_on)=="undefined") { lbl_off=lbl_text + " - aktiviert"; }
110	if($(switcher).hasClass("off")) { //Anschalten
111		$(switcher).removeClass("off");
112		$(switcher).addClass("on");
113		//$(lbl).css("display", "none");
114		$(lbl).html(lbl_on);
115		jutho_FBprivacy_load_fb_plugin(id);
116	} 
117	else if($(switcher).hasClass("on")) { //Ausschalten
118		$(switcher).removeClass("on");
119		$(switcher).addClass("off");
120		//$(lbl).css("display","inline-block");
121		$(lbl).html(lbl_off);
122		jutho_FBprivacy_kill_fb_plugin(id);
123	}
124}
125
126/*
127######################################################################################################
128######### LOAD PLUGIN ################################################################################
129######################################################################################################
130*/
131function jutho_FBprivacy_load_fb_plugin(id) {
132	container=document.getElementById(id);
133	
134	jutho_FBprivacy_initialize_fb();
135	
136	//Einstellungen laden
137	FBprivacy_set_fbclass = container.getAttribute("data-class") || "fb-like";
138	FBprivacy_set_datahref = container.getAttribute("data-href") || window.location.href;
139	FBprivacy_set_datatabs = container.getAttribute("data-tabs") || "timeline"; //nur für Page
140	FBprivacy_set_datawidth = container.getAttribute("data-width") || container.parentElement.offsetWidth;
141	FBprivacy_set_dataheight = container.getAttribute("data-height") || container.parentElement.offsetHeight; //nur für Page
142	FBprivacy_set_datalayout = container.getAttribute("data-layout") || "standard";
143	FBprivacy_set_dataaction = container.getAttribute("data-action") || "like";
144	FBprivacy_set_datashowfaces = container.getAttribute("data-show-faces") || "true";
145	FBprivacy_set_datashare = container.getAttribute("data-share") || "true";
146	FBprivacy_set_datasmallheader = container.getAttribute("data-small-header") || "true"; //nur für Page
147	FBprivacy_set_dataadaptcontainerwidth = container.getAttribute("data-adapt-container-width") || "true"; //nur für Page
148	FBprivacy_set_datahidecover = container.getAttribute("data-hide-cover") || "false"; //nur für Page
149	FBprivacy_set_datashowfacepile = container.getAttribute("data-show-facepile") || "true"; //nur für Page
150
151	//Plugin einbinden
152	plug_id=id+"_plugin";
153	if(FBprivacy_set_fbclass=="fb-like") { jutho_FBprivacy_generate_fblike(id,plug_id); }
154	if(FBprivacy_set_fbclass=="fb-page") { jutho_FBprivacy_generate_fbpage(id,plug_id); }
155}
156
157/*
158######################################################################################################
159######### KILL PLUGIN ################################################################################
160######################################################################################################
161*/
162
163function jutho_FBprivacy_kill_fb_plugin(id) {
164	container=document.getElementById(id);
165	dummy=document.getElementById("dummy_"+id);
166	
167	//FB-root löschen
168	if(jutho_FBprivacy_root===true && jutho_FBprivacy_active=="1") { //Nur l
168öschen, wenn noch aktiv und kein weiteres Plugin aktiviert
169		
170		fbroot = document.getElementById('fb-root'); //fb-root löschen
171		fbroot.parentNode.removeChild(fbroot);
172		
173		fbroot2 = document.getElementById('facebook-jssdk'); //sdk löschen
174		fbroot2.parentNode.removeChild(fbroot2);
175		
176		jutho_FBprivacy_root=false; //Merken, dass nicht mehr aktiv
177		//FB-windows entfernen
178		delete(window.FB);
179		for(var i=0;window[i];i++) {
180			delete(window[i]);
181		}
182	}
183	
184	//FB-Plugin löschen/leeren
185	dummy.innerHTML="";
186	dummy.className="";
187	dummy.style.display="none";
188	
189	//Anzahl der aktivierten Plugins erniedrigen
190	jutho_FBprivacy_active--;
191}
192
193/*
194######################################################################################################
195######### FB INITIALISIEREN ##########################################################################
196######################################################################################################
197*/
198
199function jutho_FBprivacy_initialize_fb() {
200	//FB-root einbinden
201	if(jutho_FBprivacy_root===true) { //Wenn vorher schon aktiviert
202		//FB-windows entfernen
203		delete(window.FB);
204		for(var i=0;window[i];i++) {
205			delete(window[i]);
206		}
207		fbroot = document.getElementById('fb-root'); //fb-root entfernen
208		fbroot.parentNode.removeChild(fbroot);
209		
210		fbroot2 = document.getElementById('facebook-jssdk'); //sdk entfernen
211		fbroot2.parentNode.removeChild(fbroot2);
212		
213		var fbroot = document.createElement("div"); //fb-root neu einfügen
214		fbroot.setAttribute("id", "fb-root");
215		var BODY = document.getElementsByTagName("body")[0];
216		BODY.insertBefore(fbroot, BODY.childNodes[0]);
217		//Aktivierungsskript ausführen
218		(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/de_DE/sdk.js#xfbml=1&version=v2.5"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));
219	}
220	else { //Wenn vorher noch nicht aktiviert
221		var fbroot = document.createElement("div"); //fb-root einfügen
222		fbroot.setAttribute("id", "fb-root");
223		var BODY = document.getElementsByTagName("body")[0];
224		BODY.insertBefore(fbroot, BODY.childNodes[0]);
225		//Aktivierungsskript ausführen
226		(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/de_DE/sdk.js#xfbml=1&version=v2.5"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));
227		jutho_FBprivacy_root=true; //Merken, dass aktiviert
228	}
229}
230
231/*
232######################################################################################################
233######### GENERATE FB LIKE ###########################################################################
234######################################################################################################
235*/
236function jutho_FBprivacy_generate_fblike(id,plug_id) {
237	container=document.getElementById(id);
238	dummy=document.getElementById("dummy_"+id)
239	var fbplugin = document.createElement("div");
240	fbplugin.setAttribute("id", plug_id);
241	fbplugin.className="fb-like";
242	fbplugin.setAttribute("data-href", FBprivacy_set_datahref);
243	fbplugin.setAttribute("data-width", FBprivacy_set_datawidth);
244	fbplugin.setAttribute("data-layout", FBprivacy_set_datalayout);
245	fbplugin.setAttribute("data-action", FBprivacy_set_dataaction);
246	fbplugin.setAttribute("data-show-faces", FBprivacy_set_datashowfaces);
247	fbplugin.setAttribute("data-share", FBprivacy_set_datashare);
248	
249	dummy.appendChild(fbplugin);
250	dummy.className="jutho_fb_live";
251	dummy.style.display="";
252	
253	//Aktivierungsskript ausführen
254	(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/de_DE/sdk.js#xfbml=1&version=v2.5"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));
255
256	//Anzahl der aktivierten Plugins hochzählen
257	jutho_FBprivacy_active++;	
258}
259
260
261/*
262######################################################################################################
263######### GENERATE FB PAGE ###########################################################################
264######################################################################################################
265*/
266function jutho_FBprivacy_generate_fbpage(id,plug_id,func) {
267	container=document.getElementById(id);
268	dummy=document.getElementById("dummy_"+id)
269	//umschließendes DIV
270	var fbplugin = document.createElement("div");
271	fbplugin.setAttribute("id", plug_id);
272	fbplugin.className="fb-page";
273	fbplugin.setAttribute("data-href", FBprivacy_set_datahref);
274	fbplugin.setAttribute("data-tabs", FBprivacy_set_datatabs);
275	fbplugin.setAttribute("data-width", FBprivacy_set_datawidth);
276	fbplugin.setAttribute("data-height", FBprivacy_set_dataheight);
277	fbplugin.setAttribute("data-small-header", FBprivacy_set_datasmallheader);
278	fbplugin.setAttribute("data-adapt-container-width", FBprivacy_set_dataadaptcontainerwidth);
279	fbplugin.setAttribute("data-hide-cover", FBprivacy_set_datahidecover);
280	fbplugin.setAttribute("data-show-facepile", FBprivacy_set_datashowfacepile);
281	
282	//inner-div
283	var fbplugin2 = document.createElement("div");
284	fbplugin2.className="fb-xfbml-parse-ignore";
285	
286	//blockquote
287	var blockquote = document.createElement("blockquote");
288	blockquote.setAttribute("cite", FBprivacy_set_datahref);
289	
290	//anker
291	var anker = document.createElement("a");
292	anker.setAttribute("href", FBprivacy_set_datahref);
293	var textnode = document.createTextNode("Zur Facebookseite");
294	
295	//alles einbinden
296	anker.appendChild(textnode);  
297	blockquote.appendChild(anker);
298	fbplugin2.appendChild(blockquote);
299	fbplugin.appendChild(fbplugin2);
300	dummy.appendChild(fbplugin);
301	dummy.className="jutho_fb_live";
302	
303	//alles sichtbar schalten
304	dummy.style.display="";
305	
306	//Aktivierungsskript ausführen
307	(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/de_DE/sdk.js#xfbml=1&version=v2.6&appId=167809726644240"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); 
308	//Anzahl der aktivierten Plugins hochzählen
309	jutho_FBprivacy_active++;	
310}
311
312/*
313######################################################################################################
314######### HELPER #####################################################################################
315######################################################################################################
316*/
317function jutho_FBprivacy_helper_show(helper_id) {
318	helper = document.getElementById(helper_id);
319    helper.style.display = "block"
320	document.onmousemove = jutho_FBprivacy_helper_update;
321}
322function jutho_FBprivacy_helper_hide() {
323    helper.style.display = "none";
324	document.onmousemove = false;
325}
326function jutho_FBprivacy_helper_update(e) {
327	//console.log("type: "+typeof(helper) + " " + helper.style.display);
328    if (typeof(helper) != "undefined" && helper.style.display == 'block') {
329		x = (e.pageX ? e.pageX : window.event.x) + helper.offsetParent.scrollLeft - helper.offsetParent.offsetLeft;
330		y = (e.pageY ? e.pageY : window.event.y) + helper.offsetParent.scrollTop - helper.offsetParent.offsetTop;
331		helper.style.left = (x + 20) + "px";
332		//helper.style.right = "0px";
333		helper.style.top = (y + 20) + "px";
334	}
335}
336
337/*
338##########################################################################
339########## Versionshistorie:
340##########################################################################
341
342+ Version 1: Grundfunktionen entwickelt
343+ Version 2: Auf children() verzichtet und fixe IDs vergeben
344+ Version 3: Fehlerkorrektur beim Deaktivieren des Plugins
345*/

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.