PageSourceSearch

https://www.daugyvenesmuziejus.lt/libs/TurnWheel/jReject/js/jquery.reject.js

js daugyvenesmuziejus.lt collected 2026-10-08 10:54:47 UTC 17,575 bytes, 595 lines download raw bytes

1/*!
2 * jReject (jQuery Browser Rejection Plugin)
3 * Version 1.1.x
4 * URL: http://jreject.turnwheel.com/
5 * Description: jReject is a easy method of rejecting specific browsers on your site
6 * Author: Steven Bower (TurnWheel Designs) http://turnwheel.com/
7 * Copyright: Copyright (c) 2009-2014 Steven Bower under dual MIT/GPLv2 license.
8 */
9
10(function($) {
11$.reject = function(options) {
12	var opts = $.extend(true, {
13		// Specifies which browsers/versions will be blocked
14		reject : {
15			all: false, // Covers Everything (Nothing blocked)
16			msie: 6 // Covers MSIE <= 6 (Blocked by default)
17			/*
18			 * Many possible combinations.
19			 * You can specify browser (msie, chrome, firefox)
20			 * You can specify rendering engine (geko, trident)
21			 * You can specify OS (Win, Mac, Linux, Solaris, iPhone, iPad)
22			 *
23			 * You can specify versions of each.
24			 * Examples: msie9: true, firefox8: true,
25			 *
26			 * You can specify the highest number to reject.
27			 * Example: msie: 9 (9 and lower are rejected.
28			 *
29			 * There is also "unknown" that covers what isn't detected
30			 * Example: unknown: true
31			 */
32		},
33		display: [], // What browsers to display and their order (default set below)
34		browserShow: true, // Should the browser options be shown?
35		browserInfo: { // Settings for which browsers to display
36			chrome: {
37				// Text below the icon
38				text: 'Google Chrome',
39				// URL For icon/text link
40				url: 'http://www.google.com/chrome/'
41				// (Optional) Use "allow" to customized when to show this option
42				// Example: to show chrome only for IE users
43				// allow: { all: false, msie: true }
44			},
45			firefox: {
46				text: 'Mozilla Firefox',
47				url: 'http://www.mozilla.com/firefox/'
48			},
49			safari: {
50				text: 'Safari',
51				url: 'http://www.apple.com/safari/download/'
52			},
53			opera: {
54				text: 'Opera',
55				url: 'http://www.opera.com/download/'
56			},
57			msie: {
58				text: 'Internet Explorer',
59				url: 'http://www.microsoft.com/windows/Internet-explorer/'
60			}
61		},
62
63		// Pop-up Window Text
64		header: 'Did you know that your Internet Browser is out of date?',
65
66		paragraph1: 'Your browser is out of date, and may not be compatible with '+
67					'our website. A list of the most popular web browsers can be '+
68					'found below.',
69
70		paragraph2: 'Just click on the icons to get to the download page',
71
72		// Allow closing of window
73		close: true,
74
75		// Message displayed below closing link
76		closeMessage: 'By closing this window you acknowledge that your experience '+
77						'on this website may be degraded',
78		closeLink: 'Close This Window',
79		closeURL: '#',
80
81		// Allows closing of window with esc key
82		closeESC: true,
83
84		// Use cookies to remmember if window was closed previously?
85		closeCookie: false,
86		// Cookie settings are only used if closeCookie is true
87		cookieSettings: {
88			// Path for the cookie to be saved on
89			// Should be root domain in most cases
90			path: '/',
91			// Expiration Date (in seconds)
92			// 0 (default) means it ends with the current session
93			expires: 0
94		},
95
96		// Path where images are located
97		imagePath: './images/',
98		// Background color for overlay
99		overlayBgColor: '#000',
100		// Background transparency (0-1)
101		overlayOpacity: 0.8,
102
103		// Fade in time on open ('slow','medium','fast' or integer in ms)
104		fadeInTime: 'fast',
105		// Fade out time on close ('slow','medium','fast' or integer in ms)
106		fadeOutTime: 'fast',
107
108		// Google Analytics Link Tracking (Optional)
109		// Set to true to enable
110		// Note: Analytics tracking code must be added separately
111		analytics: false
112	}, options);
113
114	// Set default browsers to display if not already defined
115	if (opts.display.length < 1) {
116		opts.display = [ 'chrome','firefox','safari','opera','msie' ];
117	}
118
119	// beforeRject: Customized Function
120	if ($.isFunction(opts.beforeReject)) {
121		opts.beforeReject();
122	}
123
124	// Disable 'closeESC' if closing is disabled (mutually exclusive)
125	if (!opts.close) {
126		opts.closeESC = false;
127	}
128
129	// This function parses the advanced browser options
130	var browserCheck = function(settings) {
131		// Check 1: Look for 'all' forced setting
132		// Check 2: Browser+major version (optional) (eg. 'firefox','msie','{msie: 6}')
133		// Check 3: Browser+major version (eg. 'firefox3','msie7','chrome4')
134		// Check 4: Rendering engine+version (eg. 'webkit', 'gecko', '{webkit: 537.36}')
135		// Check 5: Operating System (eg. 'win','mac','linux','solaris','iphone')
136		var layout = settings[$.layout.name],
137			browser = settings[$.browser.name];
138		return !!(settings['all']
139			|| (browser && (browser === true || $.browser.versionNumber <= browser))
140			|| settings[$.browser.className]
141			|| (layout && (layout === true || $.layout.versionNumber <= layout))
142			|| settings[$.os.name]);
143	};
144
145	// Determine if we need to display rejection for this browser, or exit
146	if (!browserCheck(opts.reject)) {
147		// onFail: Optional Callback
148		if ($.isFunction(opts.onFail)) {
149			opts.onFail();
150		}
151
152		return false;
153	}
154
155	// If user can close and set to remmember close, initiate cookie functions
156	if (opts.close && opts.closeCookie) {
157		// Local global setting for the name of the cookie used
158		var COOKIE_NAME = 'jreject-close';
159
160		// Cookies Function: Handles creating/retrieving/deleting cookies
161		// Cookies are only used for opts.closeCookie parameter functionality
162		var _cookie = function(name, value) {
163			// Save cookie
164			if (typeof value != 'undefined') {
165				var expires = '';
166
167				// Check if we need to set an expiration date
168				if (opts.cookieSettings.expires !== 0) {
169					var date = new Date();
170					date.setTime(date.getTime()+(opts.cookieSettings.expires*1000));
171					expires = "; expires="+date.toGMTString();
172				}
173
174				// Get path from settings
175				var path = opts.cookieSettings.path || '/';
176
177				// Set Cookie with parameters
178				document.cookie = name+'='+
179					encodeURIComponent((!value) ? '' : value)+expires+
180					'; path='+path;
181
182				return true;
183			}
184			// Get cookie
185			else {
186				var cookie,val = null;
187
188				if (document.cookie && document.cookie !== '') {
189					var cookies = document.cookie.split(';');
190
191					// Loop through all cookie values
192					var clen = cookies.length;
193					for (var i = 0; i < clen; ++i) {
194						cookie = $.trim(cookies[i]);
195
196						// Does this cookie string begin with the name we want?
197						if (cookie.substring(0,name.length+1) == (name+'=')) {
198							var len = name.length;
199							val = decodeURIComponent(cookie.substring(len+1));
200							break;
201						}
202					}
203				}
204
205				// Returns cookie value
206				return val;
207			}
208		};
209
210		// If cookie is set, return false and don't display rejection
211		if (_cookie(COOKIE_NAME)) {
212			return false;
213		}
214	}
215
216	// Load background overlay (jr_overlay) + Main wrapper (jr_wrap) +
217	// Inner Wrapper (jr_inner) w/ opts.header (jr_header) +
218	// opts.paragraph1/opts.paragraph2 if set
219	var html = '<div id="jr_overlay"></div><div id="jr_wrap"><div id="jr_inner">'+
220		'<h1 id="jr_header">'+opts.header+'</h1>'+
221		(opts.paragraph1 === '' ? '' : '<p>'+opts.paragraph1+'</p>')+
222		(opts.paragraph2 === '' ? '' : '<p>'+opts.paragraph2+'</p>');
223
224	var displayNum = 0;
225	if (opts.browserShow) {
226		html += '<ul>';
227
228		// Generate the browsers to display
229		for (var x in opts.display) {
230			var browser = opts.display[x]; // Current Browser
231			var info = opts.browserInfo[browser] || false; // Browser Information
232
233			// If no info exists for this browser
234			// or if this browser is not suppose to display to this user
235			// based on "allow" flag
236			if (!info || (info['allow'] != undefined && !browserCheck(info['allow']))) {
237				continue;
238			}
239
240			var url = info.url || '#'; // URL to link text/icon to
241
242			// Generate HTML for this browser option
243			html += '<li id="jr_'+browser+'"><div class="jr_icon"></div>'+
244					'<div><a href="'+url+'">'+(info.text || 'Unknown')+'</a>'+
245					'</div></li>';
246
247			++displayNum;
248		}
249
250		html += '</ul>';
251	}
252
253	// Close list and #jr_list
254	html += '<div id="jr_close">'+
255	// Display close links/message if set
256	(opts.close ? '<a href="'+opts.closeURL+'">'+opts.closeLink+'</a>'+
257		'<p>'+opts.closeMessage+'</p>' : '')+'</div>'+
258	// Close #jr_inner and #jr_wrap
259	'</div></div>';
260
261	var element = $('<div>'+html+'</div>'); // Create element
262	var size = _pageSize(); // Get page size
263	var scroll = _scrollSize(); // Get page scroll
264
265	// This function handles closing this reject window
266	// When clicked, fadeOut and remove all elements
267	element.bind('closejr', function() {
268		// Make sure the permission to close is granted
269		if (!opts.close) {
270			return false;
271		}
272
273		// Customized Function
274		if ($.isFunction(opts.beforeClose)) {
275			opts.beforeClose();
276		}
277
278		// Remove binding function so it
279		// doesn't get called more than once
280		$(this).unbind('closejr');
281
282		// Fade out background and modal wrapper
283		$('#jr_overlay,#jr_wrap').fadeOut(opts.fadeOutTime,function() {
284			$(this).remove(); // Remove element from DOM
285
286			// afterClose: Customized Function
287			if ($.isFunction(opts.afterClose)) {
288				opts.afterClose();
289			}
290		});
291
292		// Show elements that were hidden for layering issues
293		var elmhide = 'embed.jr_hidden, object.jr_hidden, select.jr_hidden, applet.jr_hidden';
294		$(elmhide).show().removeClass('jr_hidden');
295
296		// Set close cookie for next run
297		if (opts.closeCookie) {
298			_cookie(COOKIE_NAME, 'true');
299		}
300
301		return true;
302	});
303
304	// Tracks clicks in Google Analytics (category 'External Links')
305	// only if opts.analytics is enabled
306	var analytics = function(url) {
307		if (!opts.analytics) {
308			return false;
309		}
310
311		// Get just the hostname
312		var host = url.split(/\/+/g)[1];
313
314		// Send external link event to Google Analaytics
315		// Attempts both versions of analytics code. (Newest first)
316		try {
317			// Newest analytics code
318			ga('send', 'event', 'External', 'Click', host, url);
319		} catch (e) {
320			try {
321				_gaq.push([ '_trackEvent', 'External Links',  host, url ]);
322			} catch (e) { }
323		}
324	};
325
326	// Called onClick for browser links (and icons)
327	// Opens link in new window
328	var openBrowserLinks = function(url) {
329		// Send link to analytics if enabled
330		analytics(url);
331
332		// Open window, generate random id value
333		window.open(url, 'jr_'+ Math.round(Math.random()*11));
334
335		return false;
336	};
337
338	/*
339	 * Trverse through element DOM and apply JS variables
340	 * All CSS elements that do not require JS will be in
341	 * css/jquery.jreject.css
342	 */
343
344	// Creates 'background' (div)
345	element.find('#jr_overlay').css({
346		width: size[0],
347		height: size[1],
348		background: opts.overlayBgColor,
349		opacity: opts.overlayOpacity
350	});
351
352	// Wrapper for our pop-up (div)
353	element.find('#jr_wrap').css({
354		top: scroll[1]+(size[3]/4),
355		left: scroll[0]
356	});
357
358	// Wrapper for inner centered content (div)
359	element.find('#jr_inner').css({
360		minWidth: displayNum*100,
361		maxWidth: displayNum*140,
362		// min/maxWidth not supported by IE
363		width: $.layout.name == 'trident' ? displayNum*155 : 'auto'
364	});
365
366	element.find('#jr_inner li').css({ // Browser list items (li)
367		background: 'transparent url("'+opts.imagePath+'background_browser.gif") '+
368					'no-repeat scroll left top'
369	});
370
371	element.find('#jr_inner li .jr_icon').each(function() {
372		// Dynamically sets the icon background image
373		var self = $(this);
374		self.css('background','transparent url('+opts.imagePath+'browser_'+
375				(self.parent('li').attr('id').replace(/jr_/,''))+'.gif)'+
376					' no-repeat scroll left top');
377
378		// Send link clicks to openBrowserLinks
379		self.click(function () {
380			var url = $(this).next('div').children('a').attr('href');
381			openBrowserLinks(url);
382		});
383	});
384
385	element.find('#jr_inner li a').click(function() {
386		openBrowserLinks($(this).attr('href'));
387		return false;
388	});
389
390	// Bind closing event to trigger closejr
391	// to be consistant with ESC key close function
392	element.find('#jr_close a').click(function() {
393		$(this).trigger('closejr');
394
395		// If plain anchor is set, return false so there is no page jump
396		if (opts.closeURL === '#') {
397			return false;
398		}
399	});
400
401	// Set focus (fixes ESC key issues with forms and other focus bugs)
402	$('#jr_overlay').focus();
403
404	// Hide elements that won't display properly
405	$('embed, object, select, applet').each(function() {
406		if ($(this).is(':visible')) {
407			$(this).hide().addClass('jr_hidden');
408		}
409	});
410
411	// Append element to body of document to display
412	$('body').append(element.hide().fadeIn(opts.fadeInTime));
413
414	// Handle window resize/scroll events and update overlay dimensions
415	$(window).bind('resize scroll',function() {
416		var size = _pageSize(); // Get size
417
418		// Update overlay dimensions based on page size
419		$('#jr_overlay').css({
420			width: size[0],
421			height: size[1]
422		});
423
424		var scroll = _scrollSize(); // Get page scroll
425
426		// Update modal position based on scroll
427		$('#jr_wrap').css({
428			top: scroll[1] + (size[3]/4),
429			left: scroll[0]
430		});
431	});
432
433	// Add optional ESC Key functionality
434	if (opts.closeESC) {
435		$(document).bind('keydown',function(event) {
436			// ESC = Keycode 27
437			if (event.keyCode == 27) {
438				element.trigger('closejr');
439			}
440		});
441	}
442
443	// afterReject: Customized Function
444	if ($.isFunction(opts.afterReject)) {
445		opts.afterReject();
446	}
447
448	return true;
449};
450
451// Based on compatibility data from quirksmode.com
452// This is used to help calculate exact center of the page
453var _pageSize = function() {
454	var xScroll = window.innerWidth && window.scrollMaxX ?
455				window.innerWidth + window.scrollMaxX :
456				(document.body.scrollWidth > document.body.offsetWidth ?
457				document.body.scrollWidth : document.body.offsetWidth);
458
459	var yScroll = window.innerHeight && window.scrollMaxY ?
460				window.innerHeight + window.scrollMaxY :
461				(document.body.scrollHeight > document.body.offsetHeight ?
462				document.body.scrollHeight : document.body.offsetHeight);
463
464	var windowWidth = window.innerWidth ? window.innerWidth :
465				(document.documentElement && document.documentElement.clientWidth ?
466				document.documentElement.clientWidth : document.body.clientWidth);
467
468	var windowHeight = window.innerHeight ? window.innerHeight :
469				(document.documentElement && document.documentElement.clientHeight ?
470				document.documentElement.clientHeight : document.body.clientHeight);
471
472	return [
473		xScroll < windowWidth ? xScroll : windowWidth, // Page Width
474		yScroll < windowHeight ? windowHeight : yScroll, // Page Height
475		windowWidth,windowHeight
476	];
477};
478
479
480// Based on compatibility data from quirksmode.com
481var _scrollSize = function() {
482	return [
483		// scrollSize X
484		window.pageXOffset ? window.pageXOffset : (document.documentElement &&
485				document.documentElement.scrollTop ?
486				document.documentElement.scrollLeft : document.body.scrollLeft),
487
488		// scrollSize Y
489		window.pageYOffset ? window.pageYOffset : (document.documentElement &&
490				document.documentElement.scrollTop ?
491				document.documentElement.scrollTop : document.body.scrollTop)
492	];
493};
494})(jQuery);
495
496/*
497 * jQuery Browser Plugin
498 * Version 2.4 / jReject 1.0.x
499 * URL: http://jquery.thewikies.com/browser
500 * Description: jQuery Browser Plugin extends browser detection capabilities and
501 * can assign browser selectors to CSS classes.
502 * Author: Nate Cavanaugh, Minhchau Dang, Jonathan Neal, & Gregory Waxman
503 * Updated By: Steven Bower for use with jReject plugin
504 * Copyright: Copyright (c) 2008 Jonathan Neal under dual MIT/GPL license.
505 */
506
507(function ($) {
508	$.browserTest = function (a, z) {
509		var u = 'unknown',
510			x = 'X',
511			m = function (r, h) {
512				for (var i = 0; i < h.length; i = i + 1) {
513					r = r.replace(h[i][0], h[i][1]);
514				}
515
516				return r;
517			}, c = function (i, a, b, c) {
518				var r = {
519					name: m((a.exec(i) || [u, u])[1], b)
520				};
521
522				r[r.name] = true;
523
524				if (!r.opera) {
525					r.version = (c.exec(i) || [x, x, x, x])[3];
526				}
527				else {
528					r.version = window.opera.version();
529				}
530
531				if (/safari/.test(r.name)) {
532					var safariversion = /(safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/;
533					var res = safariversion.exec(i);
534					if (res && res[3] && res[3] < 400) {
535						r.version = '2.0';
536					}
537				}
538
539				else if (r.name === 'presto') {
540					r.version = ($.browser.version > 9.27) ? 'futhark' : 'linear_b';
541				}
542
543				if (/msie/.test(r.name) && r.version === x) {
544					var ieVersion = /rv:(\d+\.\d+)/.exec(i);
545					r.version = ieVersion[1];
546				}
547
548				r.versionNumber = parseFloat(r.version, 10) || 0;
549				var minorStart = 1;
550
551				if (r.versionNumber < 100 && r.versionNumber > 9) {
552					minorStart = 2;
553				}
554
555				r.versionX = (r.version !== x) ? r.version.substr(0, minorStart) : x;
556				r.className = r.name + r.versionX;
557
558				return r;
559			};
560
561		a = (/Opera|Navigator|Minefield|KHTML|Chrome|CriOS/.test(a) ? m(a, [
562			[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/, ''],
563			['Chrome Safari', 'Chrome'],
564			['CriOS', 'Chrome'],
565			['KHTML', 'Konqueror'],
566			['Minefield', 'Firefox'],
567			['Navigator', 'Netscape']
568		]) : a).toLowerCase();
569
570		$.browser = $.extend((!z) ? $.browser : {}, c(a,
571			/(camino|chrome|crios|firefox|netscape|konqueror|lynx|msie|trident|opera|safari)/,
572			[
573				['trident', 'msie']
574			],
575			/(camino|chrome|crios|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|rv|safari)(:|\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/));
576
577		$.layout = c(a, /(gecko|konqueror|msie|trident|opera|webkit)/, [
578			['konqueror', 'khtml'],
579			['msie', 'trident'],
580			['opera', 'presto']
581		], /(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/);
582
583		$.os = {
584			name: (/(win|mac|linux|sunos|solaris|iphone|ipad)/.
585					exec(navigator.platform.toLowerCase()) || [u])[0].replace('sunos', 'solaris')
586		};
587
588		if (!z) {
589			$('html').addClass([$.os.name, $.browser.name, $.browser.className,
590				$.layout.name, $.layout.className].join(' '));
591		}
592	};
593
594	$.browserTest(navigator.userAgent);
595}(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.