1/* 2 * jReject (jQuery Browser Rejection Plugin) 3 * Version 1.0.2 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-2013 Steven Bower under dual MIT/GPLv2 license. 8 */ 9 10(function($) { 11$.reject = function(options) { 12 var opts = $.extend(true,{ 13 reject : { // Rejection flags for specific browsers 14 all: false, // Covers Everything (Nothing blocked) 15 msie5: true, msie6: true // Covers MSIE 5-6 (Blocked by default) 16 /* 17 * Possibilities are endless... 18 * 19 * // MSIE Flags (Global, 5-8) 20 * msie, msie5, msie6, msie7, msie8, 21 * // Firefox Flags (Global, 1-3) 22 * firefox, firefox1, firefox2, firefox3, 23 * // Konqueror Flags (Global, 1-3) 24 * konqueror, konqueror1, konqueror2, konqueror3, 25 * // Chrome Flags (Global, 1-4) 26 * chrome, chrome1, chrome2, chrome3, chrome4, 27 * // Safari Flags (Global, 1-4) 28 * safari, safari2, safari3, safari4, 29 * // Opera Flags (Global, 7-10) 30 * opera, opera7, opera8, opera9, opera10, 31 * // Rendering Engines (Gecko, Webkit, Trident, KHTML, Presto) 32 * gecko, webkit, trident, khtml, presto, 33 * // Operating Systems (Win, Mac, Linux, Solaris, iPhone) 34 * win, mac, linux, solaris, iphone, 35 * unknown // Unknown covers everything else 36 */ 37 }, 38 display: [], // What browsers to display and their order (default set below) 39 browserShow: true, // Should the browser options be shown? 40 browserInfo: { // Settings for which browsers to display 41 firefox: { 42 text: 'Mozilla Firefox', // Text below the icon 43 url: 'http://www.mozilla.com/firefox/' // URL For icon/text link 44 }, 45 chrome: { 46 text: 'Google Chrome', 47 url: 'http://www.google.com/chrome/' 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 gcf: { 62 text: 'Google Chrome Frame', 63 url: 'http://code.google.com/chrome/chromeframe/', 64 // This browser option will only be displayed for MSIE 65 allow: { all: false, msie: true } 66 } 67 }, 68 69 // Header of pop-up window 70 header: 'Did you know that your Internet Browser is out of date?', 71 // Paragraph 1 72 paragraph1: 'Your browser is out of date, and may not be compatible with '+ 73 'our website. A list of the most popular web browsers can be '+ 74 'found below.', 75 // Paragraph 2 76 paragraph2: 'Just click on the icons to get to the download page', 77 close: true, // Allow closing of window 78 // Message displayed below closing link 79 closeMessage: 'By closing this window you acknowledge that your experience '+ 80 'on this website may be degraded', 81 closeLink: 'Close This Window', // Text for closing link 82 closeURL: '#', // Close URL 83 closeESC: true, // Allow closing of window with esc key 84 85 // If cookies should be used to remmember if the window was closed 86 // See cookieSettings for more options 87 closeCookie: false, 88 // Cookie settings are only used if closeCookie is true 89 cookieSettings: { 90 // Path for the cookie to be saved on 91 // Should be root domain in most cases 92 path: '/', 93 // Expiration Date (in seconds) 94 // 0 (default) means it ends with the current session 95 expires: 0 96 }, 97 98 imagePath: './images/', // Path where images are located 99 overlayBgColor: '#000', // Background color for overlay 100 overlayOpacity: 0.8, // Background transparency (0-1) 101 102 // Fade in time on open ('slow','medium','fast' or integer in ms) 103 fadeInTime: 'fast', 104 // Fade out time on close ('slow','medium','fast' or integer in ms) 105 fadeOutTime: 'fast', 106 107 // Google Analytics Link Tracking (Optional) 108 // Set to true to enable 109 // Note: Analytics tracking code must be added separately 110 analytics: false 111 }, options); 112 113 // Set default browsers to display if not already defined 114 if (opts.display.length < 1) { 115 opts.display = ['chrome','firefox','safari','opera','gcf','msie']; 116 } 117 118 // beforeRject: Customized Function 119 if ($.isFunction(opts.beforeReject)) { 120 opts.beforeReject(); 121 } 122 123 // Disable 'closeESC' if closing is disabled (mutually exclusive) 124 if (!opts.close) { 125 opts.closeESC = false;
126 } 127 128 // This function parses the advanced browser options 129 var browserCheck = function(settings) { 130 // Check 1: Look for 'all' forced setting 131 // Check 2: Operating System (eg. 'win','mac','linux','solaris','iphone') 132 // Check 3: Rendering engine (eg. 'webkit', 'gecko', 'trident') 133 // Check 4: Browser name (eg. 'firefox','msie','chrome') 134 // Check 5: Browser+major version (eg. 'firefox3','msie7','chrome4') 135 return (settings['all'] ? true : false) || 136 (settings[$.os.name] ? true : false) || 137 (settings[$.layout.name] ? true : false) || 138 (settings[$.browser.name] ? true : false) || 139 (settings[$.browser.className] ? true : false); 140 }; 141 142 // Determine if we need to display rejection for this browser, or exit 143 if (!browserCheck(opts.reject)) { 144 // onFail: Customized Function 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 if (opts.browserShow) { 222 html += '<ul>'; 223 224 var displayNum = 0; 225 226 // Generate the browsers to display 227 for (var x in opts.display) { 228 var browser = opts.display[x]; // Current Browser 229 var info = opts.browserInfo[browser] || false; // Browser Information 230 231 // If no info exists for this browser 232 // or if this browser is not suppose to display to this user 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) return false; 305 306 // Get just the hostname 307 var host = url.split(/\/+/g)[1]; 308 309 // Send external link event to Google Analaytics 310 // Attempts both versions of analytics code. (Newest first) 311 try { 312 // Newest analytics code 313 _gaq.push(['_trackEvent', 'External Links', host, url]); 314 } catch (e) { 315 try { 316 // Older analytics code 317 pageTracker._trackEvent('External Links', host, url); 318 } catch (e) { } 319 } 320 }; 321 322 // Called onClick for browser links (and icons) 323 // Opens link in new window 324 var openBrowserLinks = function(url) { 325 // Send link to analytics if enabled 326 analytics(url); 327 328 // Open window, generate random id value 329 window.open(url, 'jr_'+ Math.round(Math.random()*11)); 330 331 return false; 332 }; 333 334 /* 335 * Trverse through element DOM and apply JS variables 336 * All CSS elements that do not require JS will be in 337 * css/jquery.jreject.css 338 */ 339 340 // Creates 'background' (div) 341 element.find('#jr_overlay').css({ 342 width: size[0], 343 height: size[1], 344 background: opts.overlayBgColor, 345 opacity: opts.overlayOpacity 346 }); 347 348 // Wrapper for our pop-up (div) 349 element.find('#jr_wrap').css({ 350 top: scroll[1]+(size[3]/4), 351 left: scroll[0] 352 }); 353 354 // Wrapper for inner centered content (div) 355 element.find('#jr_inner').css({ 356 minWidth: displayNum*100, 357 maxWidth: displayNum*140, 358 // min/maxWidth not supported by IE 359 width: $.layout.name == 'trident' ? displayNum*155 : 'auto' 360 }); 361 362 element.find('#jr_inner li').css({ // Browser list items (li) 363 background: 'transparent url("'+opts.imagePath+'background_browser.gif")'+ 364 'no-repeat scroll left top' 365 }); 366 367 element.find('#jr_inner li .jr_icon').each(function() { 368 // Dynamically sets the icon background image 369 var self = $(this); 370 self.css('background','transparent url('+opts.imagePath+'browser_'+ 371 (self.parent('li').attr('id').replace(/jr_/,''))+'.gif)'+ 372 ' no-repeat scroll left top'); 373 374 // Send link clicks to openBrowserLinks 375 self.click(function () { 376 var url = $(this).next('div').children('a').attr('href'); 377 openBrowserLinks(url); 378 }); 379 }); 380 381 element.find('#jr_inner li a').click(function() { 382 openBrowserLinks($(this).attr('href')); 383 return false; 384 }); 385 386 // Bind closing event to trigger closejr 387 // to be consistant with ESC key close function 388 element.find('#jr_close a').click(function() { 389 $(this).trigger('closejr'); 390 391 // If plain anchor is set, return false so there is no page jump 392 if (opts.closeURL === '#') { 393 return false; 394 } 395 }); 396 397 // Set focus (fixes ESC key issues with forms and other focus bugs) 398 $('#jr_overlay').focus(); 399 400 // Hide elements that won't display properly 401 $('embed, object, select, applet').each(function() { 402 if ($(this).is(':visible')) { 403 $(this).hide().addClass('jr_hidden'); 404 } 405 }); 406 407 // Append element to body of document to display 408 $('body').append(element.hide().fadeIn(opts.fadeInTime)); 409 410 // Handle window resize/scroll events and update overlay dimensions 411 $(window).bind('resize scroll',function() { 412 var size = _pageSize(); // Get size 413 414 // Update overlay dimensions based on page size 415 $('#jr_overlay').css({ 416 width: size[0], 417 height: size[1] 418 }); 419 420 var scroll = _scrollSize(); // Get page scroll 421 422 // Update modal position based on scroll 423 $('#jr_wrap').css({ 424 top: scroll[1] + (size[3]/4), 425 left: scroll[0] 426 }); 427 }); 428 429 // Add optional ESC Key functionality 430 if (opts.closeESC) { 431 $(document).bind('keydown',function(event) { 432 // ESC = Keycode 27 433 if (event.keyCode == 27) { 434 element.trigger('closejr'); 435 } 436 }); 437 } 438
439 // afterReject: Customized Function 440 if ($.isFunction(opts.afterReject)) { 441 opts.afterReject(); 442 } 443 444 return true; 445}; 446 447// Based on compatibility data from quirksmode.com 448var _pageSize = function() { 449 var xScroll = window.innerWidth && window.scrollMaxX ? 450 window.innerWidth + window.scrollMaxX : 451 (document.body.scrollWidth > document.body.offsetWidth ? 452 document.body.scrollWidth : document.body.offsetWidth); 453 454 var yScroll = window.innerHeight && window.scrollMaxY ? 455 window.innerHeight + window.scrollMaxY : 456 (document.body.scrollHeight > document.body.offsetHeight ? 457 document.body.scrollHeight : document.body.offsetHeight); 458 459 var windowWidth = window.innerWidth ? window.innerWidth : 460 (document.documentElement && document.documentElement.clientWidth ? 461 document.documentElement.clientWidth : document.body.clientWidth); 462 463 var windowHeight = window.innerHeight ? window.innerHeight : 464 (document.documentElement && document.documentElement.clientHeight ? 465 document.documentElement.clientHeight : document.body.clientHeight); 466 467 return [ 468 xScroll < windowWidth ? xScroll : windowWidth, // Page Width 469 yScroll < windowHeight ? windowHeight : yScroll, // Page Height 470 windowWidth,windowHeight 471 ]; 472}; 473 474 475// Based on compatibility data from quirksmode.com 476var _scrollSize = function() { 477 return [ 478 // scrollSize X 479 window.pageXOffset ? window.pageXOffset : (document.documentElement && 480 document.documentElement.scrollTop ? 481 document.documentElement.scrollLeft : document.body.scrollLeft), 482 483 // scrollSize Y 484 window.pageYOffset ? window.pageYOffset : (document.documentElement && 485 document.documentElement.scrollTop ? 486 document.documentElement.scrollTop : document.body.scrollTop) 487 ]; 488}; 489})(jQuery); 490 491/* 492 * jQuery Browser Plugin 493 * Version 2.4 / jReject 1.0.x 494 * URL: http://jquery.thewikies.com/browser 495 * Description: jQuery Browser Plugin extends browser detection capabilities and 496 * can assign browser selectors to CSS classes. 497 * Author: Nate Cavanaugh, Minhchau Dang, Jonathan Neal, & Gregory Waxman 498 * Updated By: Steven Bower for use with jReject plugin 499 * Copyright: Copyright (c) 2008 Jonathan Neal under dual MIT/GPL license. 500 */ 501 502(function ($) { 503 $.browserTest = function (a, z) { 504 var u = 'unknown', 505 x = 'X', 506 m = function (r, h) { 507 for (var i = 0; i < h.length; i = i + 1) { 508 r = r.replace(h[i][0], h[i][1]); 509 } 510 511 return r; 512 }, c = function (i, a, b, c) { 513 var r = { 514 name: m((a.exec(i) || [u, u])[1], b) 515 }; 516 517 r[r.name] = true; 518 519 if (!r.opera) { 520 r.version = (c.exec(i) || [x, x, x, x])[3]; 521 } 522 else { 523 r.version = window.opera.version(); 524 } 525 526 if (/safari/.test(r.name)) { 527 var safariversion = /(safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/; 528 var res = safariversion.exec(i) 529 if (res && res[3] && res[3] < 400) { 530 r.version = '2.0'; 531 } 532 } 533 534 else if (r.name === 'presto') { 535 r.version = ($.browser.version > 9.27) ? 'futhark' : 'linear_b'; 536 } 537 538 r.versionNumber = parseFloat(r.version, 10) || 0; 539 var minorStart = 1; 540 541 if (r.versionNumber < 100 && r.versionNumber > 9) { 542 minorStart = 2; 543 } 544 545 r.versionX = (r.version !== x) ? r.version.substr(0, minorStart) : x; 546 r.className = r.name + r.versionX; 547 548 return r; 549 }; 550 551 a = (/Opera|Navigator|Minefield|KHTML|Chrome|CriOS/.test(a) ? m(a, [ 552 [/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/, ''], 553 ['Chrome Safari', 'Chrome'], 554 ['CriOS', 'Chrome'], 555 ['KHTML', 'Konqueror'], 556 ['Minefield', 'Firefox'], 557 ['Navigator', 'Netscape'] 558 ]) : a).toLowerCase(); 559 560 $.browser = $.extend((!z) ? $.browser : {}, c(a, 561 /(camino|chrome|crios|firefox|netscape|konqueror|lynx|msie|opera|safari)/, 562 [], 563 /(camino|chrome|crios|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/)); 564 565 $.layout = c(a, /(gecko|konqueror|msie|opera|webkit)/, [ 566 ['konqueror', 'khtml'], 567 ['msie', 'trident'], 568 ['opera', 'presto'] 569 ], /(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/); 570 571 $.os = { 572 name: (/(win|mac|linux|sunos|solaris|iphone|ipad)/. 573 exec(navigator.platform.toLowerCase()) || [u])[0].replace('sunos', 'solaris') 574 }; 575 576 if (!z) { 577 $('html').addClass([$.os.name, $.browser.name, $.browser.className, 578 $.layout.name, $.layout.className].join(' ')); 579 } 580 }; 581 582 $.browserTest(navigator.userAgent); 583}(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.