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