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