PageSourceSearch

https://www.padreefiglio.it/assets/web/assets/cookies-alert-plugin/cookies-alert-core.js

js padreefiglio.it collected 2026-10-05 19:30:14 UTC 12,694 bytes, 344 lines download raw bytes

1/* Cookies Directive - The rewrite. Now a jQuery plugin
2 * Version: 2.1.0
3 * Author: Ollie Phillips
4 * 24 October 2013
5
6 Modified by Mobirise
7 */
8
9;(function($) {
10	$.cookiesDirective = function(options) {
11
12		// Default Cookies Directive Settings
13		var settings = $.extend({
14			//Options
15			explicitConsent: true,
16			position: 'top',
17			duration: 10,
18			limit: 0,
19			message: null,
20			cookieScripts: null,
21			privacyPolicyUri: 'privacy.html',
22			scriptWrapper: function(){},
23			customDialogSelector: null,
24			// Styling
25			fontFamily: 'helvetica',
26			fontColor: '#FFFFFF',
27			fontSize: '13px',
28			backgroundColor: '#000000',
29			backgroundOpacity: '80',
30			linkColor: '#CA0000',
31			underlineLink: true,
32			textButton: null,
33			colorButton: '',
34			positionOffset: '0',
35			animate: true,
36			callback: function () {}
37		}, options);
38
39		// Perform consent checks
40		if(!getCookie('cookiesDirective')) {
41			if(settings.limit > 0) {
42				// Display limit in force, record the view
43				if(!getCookie('cookiesDisclosureCount')) {
44					setCookie('cookiesDisclosureCount',1,1);
45				} else {
46					var disclosureCount = getCookie('cookiesDisclosureCount');
47					disclosureCount ++;
48					setCookie('cookiesDisclosureCount',disclosureCount,1);
49				}
50
51				// Have we reached the display limit, if not make disclosure
52				if(settings.limit >= getCookie('cookiesDisclosureCount')) {
53					disclosure(settings);
54				}
55			} else {
56				// No display limit
57				disclosure(settings);
58			}
59
60			// If we don't require explicit consent, load up our script wrapping function
61			if(!settings.explicitConsent) {
62				settings.scriptWrapper.call();
63			}
64		} else {
65			// Cookies accepted, load script wrapping function
66			settings.scriptWrapper.call();
67		}
68	};
69
70	// Used to load external javascript files into the DOM
71	$.cookiesDirective.loadScript = function(options) {
72		var settings = $.extend({
73			uri: 		'',
74			appendTo: 	'body'
75		}, options);
76
77		var elementId = String(settings.appendTo);
78		var sA = document.createElement("script");
79		sA.src = settings.uri;
80		sA.type = "text/javascript";
81		sA.onload = sA.onreadystatechange = function() {
82			if ((!sA.readyState || sA.readyState == "loaded" || sA.readyState == "complete")) {
83				return;
84			}
85		};
86		switch(settings.appendTo) {
87			case 'head':
88				$('head').append(sA);
89			  	break;
90			case 'body':
91				$('body').append(sA);
92			  	break;
93			default:
94				$('#' + elementId).append(sA);
95		}
96	};
97
98	// Helper scripts
99	// Get cookie
100	var getCookie = function(name) {
101		var nameEQ = name + "=";
102		var ca = document.cookie.split(';');
103		for(var i=0;i < ca.length;i++) {
104			var c = ca[i];
105			while (c.charAt(0)==' ') c = c.substring(1,c.length);
106			if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length,c.length);
107		}
108		return null;
109	};
110
111	// Set cookie
112	var setCookie = function(name,value,days) {
113		var expires = "";
114		if (days) {
115			var date = new Date();
116			date.setTime(date.getTime()+(days*24*60*60*1000));
117			expires = "; expires="+date.toGMTString();
118		}
119		document.cookie = name+"="+value+expires+"; path=/";
120	};
121
122	// Detect IE < 9
123	var checkIE = function(){
124		var version;
125		if (navigator.appName == 'Microsoft Internet Explorer') {
126	        var ua = navigator.userAgent;
127	        var re = new RegExp("MSIE ([0-9]{1,}[\\.0-9]{0,})");
128	        if (re.exec(ua) !== null) {
129	            version = parseFloat(RegExp.$1);
130			}
131			if (version <= 8.0) {
132				return true;
133			} else {
134				if(version == 9.0) {
135					if(document.compatMode == "BackCompat") {
136						// IE9 in quirks mode won't run the script properly, set to emulate IE8
137						var mA = document.createElement("meta");
138						mA.content = "IE=EmulateIE8";
139						document.getElementsByTagName('head')[0].appendChild(mA);
140						return true;
141					} else {
142						return false;
143					}
144				}
145				return false;
146			}
147	    } else {
148			return false;
149		}
150	};
151
152	// Disclosure routines
153	var disclosure = function(options) {
154		var settings = options;
155		settings.css = 'fixed';
156
157		// IE 9 and lower has issues with position:fixed, either out the box or in compatibility mode - fix that
158		if(checkIE()) {
159			settings.position = 'top';
160			settings.css = 'absolute';
161		}
162
163		// Any cookie setting scripts to disclose
164		var scriptsDisclosure = '';
165		if (settings.cookieScripts) {
166			var scripts = settings.cookieScripts.split(',');
167			var scriptsCount = scripts.length;
168			var scriptDisclosureTxt = '';
169			if(scriptsCount>1) {
170				for(var t=0; t < scriptsCount - 1; t++) {
171					 scriptDisclosureTxt += scripts[t] + ', ';
172				}
173				scriptsDisclosure = ' We use ' +  scriptDisclosureTxt.substring(0,  scriptDisclosureTxt.length - 2) + ' and ' + scripts[scriptsCount - 1] + ' scripts, which all set cookies. ';
174			} else {
175				scriptsDisclosure = ' We use a ' + scripts[0] + ' script which sets cookies.';
176			}
177		}
178
179		// Create overlay, vary the disclosure based on explicit/implied consent
180		// Set our disclosure/message if one not supplied
181		if (!settings.customDialogSelector) {
182
183			// Remove the "cookiesdirective" dialog if it already exists in the HTML.
184			$('#cookiesdirective').remove();
185
186			var html = '';
187			html += '<div id="epd">';
188			html += '<div id="cookiesdirective" style="position:'+ settings.css +';'+ settings.position + ':-300px;left:0px;width:100%;';
189			html += 'height:auto;background:' + settings.backgroundColor + ';opacity:.' + settings.backgroundOpacity + ';';
190			html += '-ms-filter: “alpha(opacity=' + settings.backgroundOpacity + ')”; filter: alpha(opacity=' + settings.backgroundOpacity + ');';
191			html += '-khtml-opacity: .' + settings.backgroundOpacity + '; -moz-opacity: .' + settings.backgroundOpacity + ';';
192			html += 'color:' + settings.fontColor + ';';
193			html += 'text-align:center;z-index:1000;">';
194			html += '<div class="cookieText display-7" style="position:relative;height:auto;width:90%;padding:10px;margin-left:auto;margin-right:auto; font-size:inherit;">';
195
196			if(!settings.message) {
197				if(settings.explicitConsent) {
198					// Explicit consent message
199					settings.message = 'This site uses cookies. Some of the cookies we ';
200					settings.message += 'use are essential for parts of the site to operate and have already been set.';
201				} else {
202					// Implied consent message
203					settings.message = 'We have placed cookies on your computer to help make this website better.';
204				}
205			}
206			html += settings.message;
207
208			// Build the rest of the disclosure for implied and explicit consent
209			if(settings.explicitConsent) {
210				// Explicit consent disclosure
211				html += scriptsDisclosure + 'You may delete and block all cookies from this site, but parts of the site will not work.';
212				html += 'To find out more about cookies on this website, see our <a style="color:'+ settings.linkColor + ';font-weight:bold;';
213				html += 'font-family:' + settings.fontFamily + ';font-size:' + settings.fontSize + ';" href="'+ settings.privacyPolicyUri + '">privacy policy</a>.<br/>';
214				html += '<div id="epdnotick" style="color:#ca0000;display:none;margin:2px;"><span style="background:#cecece;padding:2px;">You must tick the "I accept cookies from this site" box to accept</span></div>';
215				html += '<div style="margin-top:5px;">I accept cookies from this site <input type="checkbox" name="epdagree" id="epdagree" />&nbsp;';
216				html += '<input type="submit" name="explicitsubmit" id="explicitsubmit" value="Continue"/><br/></div></div>';
217
218			} else {
219				// Implied consent disclosure
220				html += scriptsDisclosure;
221				html += '<input style="display: inline-block; margin-left:10px; font-size:inherit;' + (settings.colorButton ? ' background-color:' + settings.colorButton + ' !important;' : '') + (settings.colorButton && self === top ? 'border-color:' + settings.colorButton + ' !important;' : '') + '" type="submit" name="impliedsubmit" id="impliedsubmit" class="btn btn-sm btn-primary display-7" value="' + settings.textButton + '"/></div>';
222			}
223			html += '</div></div>';
224
225			// Links
226			html = html.replace(/<a/g, '<a style="color: ' + settings.linkColor + ';text-decoration:' + (settings.underlineLink === true || settings.underlineLink === 'true' ? 'underline' : 'none') + ';"');
227
228			$('body').append(html);
229
230		} else {
231			// Get the dialog and "cookiesdirective" div.
232			var $dialog = $('#cookie-dialog');
233			var $cd = $dialog.find('#cookiesdirective');
234
235			// If explicit consent is required, the appropriate controls are
236			// needed for the user to be able to consent. If they are not
237			// added by the user (developer), we'll automatically add them
238			// here and issue a warning to the console.
239			if (settings.explicitConsent) {
240				if ($cd.find('#epdnotick').length == 0) {
241					$cd.append('<div id="epdnotick" style="display: none;">You must tick the "I accept cookies from this site" box to accept</div>');
242					console.warn('cookiesDirective: Element with ID "epdnotick" does not exist in custom dialog, so automatically added');
243				}
244				if ($cd.find('input#epdagree').length == 0) {
245					$cd.append('<input type="checkbox" id="epdagree" />');
246					console.warn('cookiesDirective: Checkbox with ID "epdagree" does not exist in custom dialog, so automatically added');
247				}
248				if ($cd.find('input#explicitsubmit').length == 0) {
249					$cd.append('<input type="submit" id="explicitsubmit" value="Continue" />');
250					console.warn('cookiesDirective: Submit button with ID "explicitsubmit" does not exist in custom dialog, so automatically added');
251				}
252			// However, if implied consent is enough, we'll still need a
253			// button for the user to indicate that they do not want to see
254			// the message again.
255			} else {
256				if ($cd.find('input#impliedsubmit').length == 0) {
257					$cd.append('<input type="submit" id="impliedsubmit" value="Do not show this message again" />');
258					console.warn('cookiesDirective: Submit button with ID "impliedsubmit" does not exist in custom dialog, so automatically added');
259				}
260			}
261
262			// Make sure that the custom dialog's message about explicit
263			// consent being required, is invisible at the start.
264			$dialog.find('#epdnotick').css('display', 'none');
265
266			// The custom dialog must start invisible. We cannot automatically
267			// set it at this point because it will revert to its original
268			// state once the cookie acceptance is complete. Instead, we warn
269			// the user (developer).
270			if ($dialog.css('display') != 'none') {
271				console.error('cookiesDirective: Custom dialog element should have CSS style display: "none".');
272			}
273
274			// Dialog starts hidden so that it's not visible in content
275			// afterwards, so it has to be explicitly made visible.
276			$dialog.show();
277		}
278
279		// Serve the disclosure, and be smarter about branching
280		var dp = settings.position.toLowerCase();
281		if(dp != 'top' && dp!= 'bottom') {
282			dp = 'top';
283		}
284		var opts = { in: null, out: null};
285		if(dp == 'top') {
286			opts.in = {'top':settings.positionOffset};
287			opts.out = {'top':'-300'};
288		} else {
289			opts.in = {'bottom':settings.positionOffset};
290			opts.out = {'bottom':'-300'};
291		}
292
293		// Start animation
294		$('#cookiesdirective').animate(opts.in, (settings.animate ? 1000 : 0), function() {
295			// Set event handlers depending on type of disclosure
296			if(settings.explicitConsent) {
297				// Explicit, need to check a box and click a button
298				$('#explicitsubmit').click(function() {
299					if($('#epdagree').is(':checked')) {
300						// Set a cookie to prevent this being displayed again
301						setCookie('cookiesDirective',1,365);
302						// Close the overlay
303						$('#cookiesdirective').animate(opts.out,1000,function() {
304							// Remove the elements from the DOM and reload page
305							$('#cookiesdirective').remove();
306							location.reload(true);
307						});
308					} else {
309						// Show message about explicit consent being required
310						// (CSS style display set to default)
311						$('#epdnotick').css('display', '');
312					}
313				});
314			} else {
315				// Implied consent, just a button to close it
316				$('#impliedsubmit').click(function() {
317					// If demo-mode off event
318                    if ($('#impliedsubmit').is("[demo]")) return;
319					// Set a cookie to prevent this being displayed again
320					setCookie('cookiesDirective',1,365);
321					// Close the overlay
322					$('#cookiesdirective').animate(opts.out, settings.animate ? 1000 : 0, function() {
323						// Remove the elements from the DOM and reload page
324						$('#cookiesdirective').remove();
325					});
326				});
327			}
328
329			if(settings.duration > 0)
330			{
331				// Set a timer to remove the warning after 'settings.duration' seconds
332				setTimeout(function(){
333					$('#cookiesdirective').animate({
334						opacity:'0'
335					},2000, function(){
336						$('#cookiesdirective').css(dp,'-300px');
337					});
338				}, settings.duration * 1000);
339			}
340
341			settings.callback();
342		});
343	};
344})(jQuery);

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.