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