PageSourceSearch

https://www.goingout.co.uk/plugins/system/cookiespolicynotificationbar/assets/js/jquery.cookiesdirective.js

js goingout.co.uk collected 2026-10-05 05:19:05 UTC 10,698 bytes, 297 lines download raw bytes

1/* ======================================================
2# Cookies Policy Notification Bar - Joomla! Plugin v3.0.5 (PRO version)
3# -------------------------------------------------------
4# For Joomla! 3.x
5# Author: Yiannis Christodoulou ([email protected])
6# Copyright (©) 2009-2016 Web357. All rights reserved.
7# License: GNU/GPLv3, http://www.gnu.org/licenses/gpl-3.0.html
8# Website: https://www.web357.eu/
9# Demo: http://demo.web357.eu/?item=cookiespolicynotificationbar
10# Support: [email protected]
11# Last modified: 22 Nov 2016, 03:38:17
12========================================================= */
13
14/* Cookies Directive - The rewrite. Now a jQuery plugin
15 * Version: 2.0.1
16 * Author: Ollie Phillips
17 * 24 October 2013
18 */
19
20function popupwindow(url, title, w, h) {
21    wLeft = window.screenLeft ? window.screenLeft : window.screenX;
22    wTop = window.screenTop ? window.screenTop : window.screenY;
23
24    var left = wLeft + (window.innerWidth / 2) - (w / 2);
25    var top = wTop + (window.innerHeight / 2) - (h / 2);
26    return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
27}
28
29;(function($) {
30	$.cookiesDirective = function(options) {
31			
32		// Default Cookies Directive Settings
33		var settings = $.extend({
34			//Options
35			w357_explicitConsent: true,
36			w357_position: 'bottom',
37			w357_duration: 60,
38			w357_animate_duration: 2000,
39			w357_limit: 0,
40			w357_message: null,				
41			w357_buttonText: "Ok, I've understood!",		
42			w357_buttonMoreText: "More Info",
43			w357_display_more_info_btn: 1,
44			w357_buttonMoreLink: "",		
45			cookieScripts: null,
46			privacyPolicyUri: 'privacy.html',
47			w357_scriptWrapper: function(){},	
48			// Styling
49			fontFamily: "Lato1, 'Helvetica Neue', Helvetica, Arial, sans-serif",
50			w357_fontColor: '#F1F1F3',
51			w357_fontSize: '12px',
52			w357_backgroundColor: '#323A45',
53			w357_height: 'auto',
54			w357_line_height: '100%',
55			w357_backgroundOpacity: '95',
56			w357_linkColor: '#FFF',
57			w357_cookie_name: 'cookiesDirective',
58			w357_link_target: '_self',
59			w357_popup_width: '800',
60			w357_popup_height: '600'
61		}, options);
62		
63		// Perform consent checks
64		//if(!getCookie('cookiesDirective')) {
65		if(!getCookie(settings.w357_cookie_name)) {
66			if(settings.w357_limit > 0) {
67				// Display limit in force, record the view
68				if(!getCookie('cookiesDisclosureCount')) {
69					setCookie('cookiesDisclosureCount',1,1);		
70				} else {
71					var disclosureCount = getCookie('cookiesDisclosureCount');
72					disclosureCount ++;
73					setCookie('cookiesDisclosureCount',disclosureCount,1);
74				}
75				
76				// Have we reached the display limit, if not make disclosure
77				if(settings.w357_limit >= getCookie('cookiesDisclosureCount')) {
78					disclosure(settings);		
79				}
80			} else {
81				// No display limit
82				disclosure(settings);
83			}		
84			
85			// If we don't require explicit consent, load up our script wrapping function
86			if(!settings.w357_explicitConsent) {
87				settings.w357_scriptWrapper.call();
88			}	
89		} else {
90			// Cookies accepted, load script wrapping function
91			settings.w357_scriptWrapper.call();
92		}		
93	};
94	
95	// Used to load external javascript files into the DOM
96	$.cookiesDirective.loadScript = function(options) {
97		var settings = $.extend({
98			uri: 		'', 
99			appendTo: 	'body'
100		}, options);	
101		
102		var elementId = String(settings.appendTo);
103		var sA = document.createElement("script");
104		sA.src = settings.uri;
105		sA.type = "text/javascript";
106		sA.onload = sA.onreadystatechange = function() {
107			if ((!sA.readyState || sA.readyState == "loaded" || sA.readyState == "complete")) {
108				return;
109			} 	
110		}
111		switch(settings.appendTo) {
112			case 'head':			
113				$('head').append(sA);
114			  	break;
115			case 'body':
116				$('body').append(sA);
117			  	break;
118			default: 
119				$('#' + elementId).append(sA);
120		}
121	}	 
122	
123	// Helper scripts
124	// Get cookie
125	var getCookie = function(name) {
126		var nameEQ = name + "=";
127		var ca = document.cookie.split(';');
128		for(var i=0;i < ca.length;i++) {
129			var c = ca[i];
130			while (c.charAt(0)==' ') c = c.substring(1,c.length);
131			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
132		}
133		return null;
134	}
135	
136	// Set cookie
137	var setCookie = function(name,value,days) {
138		if (days) {
139			var date = new Date();
140			date.setTime(date.getTime()+(days*24*60*60*1000));
141			var expires = "; expires="+date.toGMTString();
142		}
143		else var expires = "";
144		document.cookie = name+"="+value+expires+"; path=/";
145	}
146	
147	// Detect IE < 9
148	var checkIE = function(){
149		var version;
150		if (navigator.appName == 'Microsoft Internet Explorer') {
151	        var ua = navigator.userAgent;
152	        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
153	        if (re.exec(ua) != null) {
154	            version = parseFloat(RegExp.$1);
155			}	
156			if (version <= 8.0) {
157				return true;
158			} else {
159				if(version == 9.0) {
160					if(document.compatMode == "BackCompat") {
161						// IE9 in quirks mode won't run the script properly, set to emulate IE8	
162						var mA = document.createElement("meta");
163						mA.content = "IE=EmulateIE8";				
164						document.getElementsByTagName('head')[0].appendChild(mA);
165						return true;
166					} else {
167						return false;
168					}
169				}	
170				return false;
171			}		
172	    } else {
173			return false;
174		}
175	}
176
177	// Disclosure routines
178	var disclosure = function(options) {
179		var settings = options;
180		settings.css = 'fixed';
181		
182		// IE 9 and lower has issues with position:fixed, either out the box or in compatibility mode - fix that
183		if(checkIE()) {
184			settings.w357_position = 'top';
185			settings.css = 'absolute';
186		}
187		
188		// Any cookie setting scripts to disclose
189		var scriptsDisclosure = '';
190		if (settings.cookieScripts) {
191			var scripts = settings.cookieScripts.split(',');
192			var scriptsCount = scripts.length;
193			var scriptDisclosureTxt = '';
194			if(scriptsCount>1) {
195				for(var t=0; t < scriptsCount - 1; t++) {
196					 scriptDisclosureTxt += scripts[t] + ', ';	
197				}	
198			}
199		} 
200		
201		// Create overlay, vary the disclosure based on explicit/implied consent
202		// Set our disclosure/message if one not supplied
203		var html = ''; 
204		html += '<div id="w357_cpnb">';
205		html += '<div id="w357_cpnb_outer" style="position:'+ settings.css +';'+ settings.w357_position + ':-300px;left:0px;width:100%;'
206		html += 'height:' + settings.w357_height + ';line-height:' + settings.w357_line_height + ';background:' + settings.w357_backgroundColor + ';opacity:'+ (settings.w357_backgroundOpacity < 100 ? '.' + settings.w357_backgroundOpacity : 1) + ';';
207		html += '-ms-filter: “alpha(opacity=' + settings.w357_backgroundOpacity + ')”; filter: alpha(opacity=' + settings.w357_backgroundOpacity + ');';
208		html += '-khtml-opacity: .' + settings.w357_backgroundOpacity + '; -moz-opacity: .' + settings.w357_backgroundOpacity + ';';
209		html += 'color:' + settings.w357_fontColor + ';font-size:' + settings.w357_fontSize + ';';
210		html += 'text-align:center;z-index:1000;">';
211		//html += '<div id="w357_cpnb_inner" style="position:relative;height:auto;width:90%;padding:10px;margin-left:auto;margin-right:auto;">';
212		html += '<div id="w357_cpnb_inner">';
213			
214		if(!settings.w357_message) {
215			if(settings.w357_explicitConsent) {
216				// Explicit consent message
217				settings.w357_message = 'This site uses cookies. Some of the cookies we ';
218				settings.w357_message += 'use are essential for parts of the site to operate and have already been set.';
219			} else {
220				// Implied consent message
221				settings.w357_message = 'We have placed cookies on your computer to help make this website better.';
222			}		
223		}	
224		html += '<div id="w357_cpnb_message">' + settings.w357_message + '</div>';
225		
226		// Build the rest of the disclosure for implied and explicit consent
227		var popup_onclick = (settings.w357_link_target === 'popup') ? 'onClick="popupwindow(\'' + settings.w357_buttonMoreLink + '?cpnb=1\', \'Cookies Policy\', ' +settings.w357_popup_width + ', ' +settings.w357_popup_height + '); return false;"' : '';
228		html += '<div id="w357_cpnb_buttons">';
229		html += '<a class="w357_cpnb_button" id="w357_cpnb_button_ok">' + settings.w357_buttonText + '</a>';
230		html += (settings.w357_buttonMoreText != '' && settings.w357_display_more_info_btn) ? '<a target="' + settings.w357_link_target + '" href="' + settings.w357_buttonMoreLink + '" class="w357_cpnb_button" id="w357_cpnb_button_more" '+ popup_onclick +'>' + settings.w357_buttonMoreText + '</a>' : '';
231		html += '<div style="clear:both;"></div>';
232		html += '</div>';
233		html += '</div></div>';
234		$('body').append(html);
235		
236		// Serve the disclosure, and be smarter about branching
237		var dp = settings.w357_position.toLowerCase();
238		if(dp != 'top' && dp!= 'bottom') {
239			dp = 'top';
240		}	
241		var opts = new Array();
242		if(dp == 'top') {
243			opts['in'] = {'top':'0'};
244			opts['out'] = {'top':'-300'};
245		} else {
246			opts['in'] = {'bottom':'0'};
247			opts['out'] = {'bottom':'-300'};
248		}		
249
250		// Start animation
251		$('#w357_cpnb_outer').animate(opts['in'], settings.w357_animate_duration, function() {
252			// Set event handlers depending on type of disclosure
253			if(settings.w357_explicitConsent) {
254				// Explicit, need to check a box and click a button
255				$('#explicitsubmit').click(function() {
256					if($('#epdagree').is(':checked')) {	
257						// Set a cookie to prevent this being displayed again
258						//setCookie('cookiesDirective',1,365);	
259						setCookie(settings.w357_cookie_name,1,365);	
260						// Close the overlay
261						$('#w357_cpnb_outer').animate(opts['out'],settings.w357_animate_duration,function() { 
262							// Remove the elements from the DOM and reload page
263							$('#w357_cpnb_outer').remove();
264							location.reload(true);
265						});
266					} else {
267						// We need the box checked we want "explicit consent", display message
268						$('#epdnotick').css('display', 'block'); 
269					}	
270				});
271			} else {
272				// Implied consent, just a button to close it
273				$('#w357_cpnb_button_ok').click(function() {
274					// Set a cookie to prevent this being displayed again
275					//setCookie('cookiesDirective',1,365);	
276					setCookie(settings.w357_cookie_name,1,365);	
277					// Close the overlay
278					//
279					location.reload();
280					$('#w357_cpnb_outer').animate(opts['out'],1000,function() { 
281						// Remove the elements from the DOM and reload page
282						$('#w357_cpnb_outer').remove();
283					});
284				});
285			}	
286			
287			// Set a timer to remove the warning after 'settings.w357_duration' seconds
288			setTimeout(function(){
289				$('#w357_cpnb_outer').animate({
290					opacity:'0'
291				},settings.w357_animate_duration, function(){
292					$('#w357_cpnb_outer').css(dp,'-300px');
293				});
294			}, settings.w357_duration * 1000);
295		});	
296	}
297})(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.