1/* 2 * jReject (jQuery Browser Rejection Plugin) 3 * Version 0.7.1 4 * URL: http://jreject.turnwheel.com/ 5 * Description: jReject gives you a customizable and easy solution to reject/allowing specific browsers access to your pages 6 * Author: Steven Bower (TurnWheel Designs) http://turnwheel.com/ 7 * Copyright: Copyright (c) 2009-2010 Steven Bower under dual MIT/GPL license. 8 * Depends On: jQuery Browser Plugin (http://jquery.thewikies.com/browser) 9*/ 10 11(function($) { 12 $.reject = function(opts) { 13 var opts = $.extend(true,{ 14 reject : { // Rejection flags for specific browsers 15 all: false, // Covers Everything (Nothing blocked) 16 msie5: true,msie6: true // Covers MSIE 5-6 (Blocked by default) 17 /* 18 Possibilities are endless... 19 20 msie: false,msie5: true,msie6: true,msie7: false,msie8: false, // MSIE Flags (Global, 5-8) 21 firefox: false,firefox1: false,firefox2: false,firefox3: false, // Firefox Flags (Global, 1-3) 22 konqueror: false,konqueror1: false,konqueror2: false,konqueror3: false, // Konqueror Flags (Global, 1-3) 23 chrome: false,chrome1: false,chrome2: false,chrome3: false,chrome4: false, // Chrome Flags (Global, 1-4) 24 safari: false,safari2: false,safari3: false,safari4: false, // Safari Flags (Global, 1-4) 25 opera: false,opera7: false,opera8: false,opera9: false,opera10: false, // Opera Flags (Global, 7-10) 26 gecko: false,webkit: false,trident: false,khtml: false,presto: false, // Rendering Engines (Gecko, Webkit, Trident, KHTML, Presto) 27 win: false,mac: false,linux : false,solaris : false,iphone: false, // Operating Systems (Win, Mac, Linux, Solaris, iPhone) 28 unknown: false // Unknown covers everything else 29 */ 30 }, 31 display: [], // What browsers to display and their order (default set below) 32 browserInfo: { // Settings for which browsers to display 33 firefox: { 34 text: 'Firefox', // Text below the icon 35 url: 'http://www.mozilla.com/it/firefox/' // URL For icon/text link 36 }, 37 safari: { 38 text: 'Safari', 39 url: 'http://www.apple.com/it/safari/download/' 40 }, 41 opera: { 42 text: 'Opera', 43 url: 'http://www.opera.com/download/' 44 }, 45 chrome: { 46 text: 'Chrome', 47 url: 'http://www.google.it/chrome/' 48 }, 49 msie: { 50 text: 'Internet Explorer', 51 url: 'http://windows.microsoft.com/it-IT/internet-explorer/products/ie/home' 52 }, 53 gcf: { 54 text: 'Google Chrome Frame', 55 url: 'http://code.google.com/chrome/chromeframe/', 56 allow: { all: false, msie: true } // This browser option will only be displayed for MSIE 57 } 58 }, 59 header: 'Attenzione!', // Header of pop-up window 60 paragraph1: 'Per una corretta visualizzazione e per usufruire delle funzionalitá WEB 2.0 di questo sito, occorre eseguire un aggiornamento.', // Paragraph 1 61 paragraph2: 'Basterá semplicemente cliccare sull\' icona sottostante corrispondente al vostro browser per accedere al sito ufficiale ed effettuare gratuitamente l\'aggiornamento', // Paragraph 2 62 close: true, // Allow closing of window 63 closeMessage: 'Chiudendo questa finestra sarai consapevole che il sito potrebbe non funzionare correttamente', // Message displayed below closing link 64 closeLink: 'Chiudi', // Text for closing link 65 closeURL: '#', // Close URL 66 closeESC: true, // Allow closing of window with esc key 67 closeCookie: false, // If cookies should be used to remmember if the window was closed (see cookieSettings for more options) 68 // Cookie settings are only used if closeCookie is true 69 cookieSettings: { 70 path: '/', // Path for the cookie to be saved on (should be root domain in most cases) 71 expires: 0 // Expiration Date (in seconds), 0 (default) means it ends with the current session 72 }, 73 imagePath: './images/', // Path where images are located 74 overlayBgColor: '#000', // Background color for overlay 75 overlayOpacity: 0.8, // Background transparency (0-1) 76 fadeInTime: 'fast', // Fade in time on open ('slow','medium','fast' or integer in ms) 77 fadeOutTime: 'fast' // Fade out time on close ('slow','medium','fast' or integer in ms) 78 },opts); 79 80 // Set default browsers to display if not already defined 81 if (opts.display.length < 1) opts.display = ['firefox','chrome','msie','safari','opera','gcf']; 82 83 // beforeRject: Customized Function 84 if ($.isFunction(opts.beforeReject)) opts.beforeReject(opts); 85 86 // Disable 'closeESC' if closing is disabled (mutually exclusive) 87 if (!opts.close) opts.closeESC = false; 88 89 // This function parses the advanced browser options 90 var browserCheck = function(settings) { 91 // Check 1: Look for 'all' forced setting 92 // Check 2: Operating System (eg. 'win','mac','linux','solaris','iphone') 93 // Check 3: Rendering engine (eg. 'webkit', 'gecko', 'trident') 94 // Check 4: Browser name (eg. 'firefox','msie','chrome') 95 // Check 5: Browser+major version (eg. 'firefox3','msie7','chrome4') 96 return (settings['all'] ? true : false) ||
97 (settings[$.os.name] ? true : false) || 98 (settings[$.layout.name] ? true : false) || 99 (settings[$.browser.name] ? true : false) || 100 (settings[$.browser.className] ? true : false); 101 }; 102 103 // Determine if we need to display rejection for this browser, or exit 104 if (!browserCheck(opts.reject)) { 105 // onFail: Customized Function 106 if ($.isFunction(opts.onFail)) opts.onFail(opts); 107 return false; 108 } 109 110 // If user can close and set to remmember close, initiate cookie functions 111 if (opts.close && opts.closeCookie) { 112 var COOKIE_NAME = 'jreject-close'; // Local global setting for the name of the cookie used 113 114 // Cookies Function: Handles creating/retrieving/deleting cookies 115 // Cookies are only used for opts.closeCookie parameter functionality 116 var _cookie = function(name, value) { 117 if (typeof value != 'undefined') { 118 var expires = ''; 119 120 // Check if we need to set an expiration date 121 if (opts.cookieSettings.expires != 0) { 122 var date = new Date(); 123 date.setTime(date.getTime()+(opts.cookieSettings.expires)); 124 var expires = "; expires="+date.toGMTString(); 125 } 126 127 // Get path from settings 128 var path = opts.cookieSettings.path || '/'; 129 130 // Set Cookie with parameters 131 document.cookie = name+'='+encodeURIComponent(value == null ? '' : value)+expires+'; path='+path; 132 } 133 else { // Get cookie value 134 var cookie,val = null; 135 136 if (document.cookie && document.cookie != '') { 137 var cookies = document.cookie.split(';'); 138 139 // Loop through all cookie values 140 for (var i = 0; i < cookies.length; ++i) { 141 cookie = $.trim(cookies[i]); 142 143 // Does this cookie string begin with the name we want? 144 if (cookie.substring(0,name.length+1) == (name+'=')) { 145 val = decodeURIComponent(cookie.substring(name.length+1)); 146 break; 147 } 148 } 149 } 150 151 return val; // Return cookie value 152 } 153 }; 154 155 // If cookie is set, return false and don't display rejection 156 if (_cookie(COOKIE_NAME) != null) return false; 157 } 158 159 // Load background overlay (jr_overlay) + Main wrapper (jr_wrap) + 160 // Inner Wrapper (jr_inner) w/ opts.header (jr_header) + 161 // opts.paragraph1/opts.paragraph2 if set 162 var html = '<div id="jr_overlay"></div><div id="jr_wrap"><div id="jr_inner"><h1 id="jr_header">'+opts.header+'</h1>'+ 163 (opts.paragraph1 === '' ? '' : '<p>'+opts.paragraph1+'</p>')+(opts.paragraph2 === '' ? '' : '<p>'+opts.paragraph2+'</p>')+'<ul>'; 164 165 var displayNum = 0; // Tracks number of browsers being displayed 166 // Generate the browsers to display 167 for (var x in opts.display) { 168 var browser = opts.display[x]; // Current Browser 169 var info = opts.browserInfo[browser] || false; // Browser Information 170 171 // If no info exists for this browser 172 // or if this browser is not suppose to display to this user 173 if (!info || (info['allow'] != undefined && !browserCheck(info['allow']))) continue; 174 175 var url = info.url || '#'; // URL to link text/icon to 176 // Generate HTML for this browser option 177 html += '<li id="jr_'+browser+'"><div class="jr_icon"></div>'+ 178 '<div><a href="'+url+'">'+(info.text || 'Unknown')+'</a></div></li>'; 179 ++displayNum; // Increment number of browser being displayed 180 } 181 182 // Close list and #jr_list 183 html += '</ul><div id="jr_close">'+ 184 // Display close links/message if set 185 (opts.close ? '<a href="'+opts.closeURL+'">'+opts.closeLink+'</a><p>'+opts.closeMessage+'</p>' : '')+'</div>'+ 186 // Close #jr_inner and #jr_wrap 187 '</div></div>'; 188 189 var element = $('<div>'+html+'</div>'); // Create element 190 var size = _pageSize(); // Get page size 191 var scroll = _scrollSize(); // Get page scroll 192 193 // This function handles closing this reject window 194 element.bind('closejr',function() { // When clicked, fadeOut and remove all elements 195 if (!opts.close) return false; // Make sure the ability to close is set 196 if ($.isFunction(opts.beforeClose)) opts.beforeClose(opts); // Customized Function 197 198 $(this).unbind('closejr'); // Remove binding function 199 200 // Fade out background and modal wrapper 201 $('#jr_overlay,#jr_wrap').fadeOut(opts.fadeOutTime,function() { 202 $(this).remove(); // Remove element from DOM 203 204 // afterClose: Customized Function 205 if ($.isFunction(opts.afterClose)) opts.afterClose(opts); 206 }); 207 208 $('embed, object, select, applet').show(); // Show elements that were hidden 209 210 if (opts.closeCookie) _cookie(COOKIE_NAME,'true'); // Set close cookie for next run 211 return true; 212 }); 213 214 // Traverse through the DOM and 215 // Apply CSS Rules to elements
216 element.find('#jr_overlay').css({ // Creates 'background' (div) 217 width: size[0], 218 height: size[1], 219 position: 'absolute', 220 top: 0, 221 left: 0, 222 background: opts.overlayBgColor, 223 zIndex: 200, 224 opacity: opts.overlayOpacity, 225 padding: 0, 226 margin: 0 227 }).next('#jr_wrap').css({ // Wrapper for our pop-up (div) 228 position: 'absolute', 229 width: '100%', 230 top: scroll[1]+(size[3]/4), 231 left: scroll[0], 232 zIndex: 300, 233 textAlign: 'center', 234 padding: 0, 235 margin: 0 236 }).children('#jr_inner').css({ // Wrapper for inner centered content (div) 237 background: '#FFF', 238 border: '1px solid #CCC', 239 fontFamily: '"Lucida Grande","Lucida Sans Unicode",Arial,Verdana,sans-serif', 240 color: '#4F4F4F', 241 margin: '0 auto', 242 position: 'relative', 243 height: 'auto', 244 minWidth: displayNum*100, 245 maxWidth: displayNum*140, 246 width: $.layout.name == 'trident' ? displayNum*155 : 'auto', // min/maxWidth not supported by IE 247 padding: 20, 248 fontSize: 12 249 }).children('#jr_header').css({ // Header (h1) 250 display: 'block', 251 fontSize: '1.3em', 252 marginBottom: '0.5em', 253 color: '#333', 254 fontFamily: 'Helvetica,Arial,sans-serif', 255 fontWeight: 'bold', 256 textAlign: 'left', 257 padding: 5, 258 margin: 0 259 }).nextAll('p').css({ // Paragraphs (p) 260 textAlign: 'left', 261 padding: 5, 262 margin: 0 263 }).siblings('ul').css({ // Browser list (ul) 264 listStyleImage: 'none', 265 listStylePosition: 'outside', 266 listStyleType: 'none', 267 margin: 0, 268 padding: 0 269 }).children('li').css({ // Browser list items (li) 270 background: 'transparent url("'+opts.imagePath+'background_browser.gif") no-repeat scroll left top', 271 cusor: 'pointer', 272 'float': 'left', 273 width: 120, 274 height: 122, 275 margin: '0 10px 10px 10px', 276 padding: 0, 277 textAlign: 'center' 278 }).children('.jr_icon').css({ // Icons (div) 279 width: 100, 280 height: 100, 281 margin: '1px auto', 282 padding: 0, 283 background: 'transparent no-repeat scroll left top', 284 cursor: 'pointer' 285 }).each(function() { // Dynamically sets the icon background image 286 var self = $(this); 287 self.css('background','transparent url('+opts.imagePath+'browser_'+(self.parent('li').attr('id').replace(/jr_/,''))+'.gif) no-repeat scroll left top'); 288 self.click(function() { 289 window.open($(this).next('div').children('a').attr('href'),'jr_'+Math.round(Math.random()*11)); 290 return false; 291 }); 292 }).siblings('div').css({ // Text under the browser icon (div) 293 color: '#808080', 294 fontSize: '0.8em', 295 height: 18, 296 lineHeight: '17px', 297 margin: '1px auto', 298 padding: 0, 299 width: 118, 300 textAlign: 'center' 301 }).children('a').css({ // Text link (a) 302 color: '#333', 303 textDecoration: 'none', 304 padding: 0, 305 margin: 0 306 }).hover(function() { // Underline effect (a:hover) 307 $(this).css('textDecoration','underline'); 308 },function() { 309 $(this).css('textDecoration','none'); 310 }).click(function() { // Make links open in new window (a) 311 window.open($(this).attr('href'),'jr_'+Math.round(Math.random()*11)); 312 return false; 313 }).parents('#jr_inner').children('#jr_close').css({ // Close window option (div) 314 margin: '0 0 0 50px', 315 clear: 'both', 316 textAlign: 'left', 317 padding: 0, 318 margin: 0 319 }).children('a').css({ // Close window link (a) 320 color: '#000', 321 display: 'block', 322 width: 'auto', 323 margin: 0, 324 padding: 0, 325 textDecoration: 'underline' 326 }).click(function() { // Bind closing event 327 $(this).trigger('closejr'); 328 329 // If plain anchor is set, return false so there is no page jump 330 if (opts.closeURL === '#') return false; 331 }).nextAll('p').css({ // Add padding to close link/text 332 padding: '10px 0 0 0', 333 margin: 0 334 }); 335 336 // Set focus (fixes ESC key issues with forms and other focus bugs) 337 $('#jr_overlay').focus(); 338 339 // Hide elements that won't display properly 340 $('embed, object, select, applet').hide(); 341 342 // Append element to body of document to display 343 $('body').append(element.hide().fadeIn(opts.fadeInTime)); 344 345 // Handle window resize/scroll events and update overlay dimensions 346 $(window).bind('resize scroll',function() { 347 var size = _pageSize(); // Get size 348 349 // Update overlay dimensions based on page size 350 $('#jr_overlay').css({ width: size[0],height: size[1] }); 351 352 var scroll = _scrollSize(); // Get page scroll 353 354 // Update modal position based on scroll 355 $('#jr_wrap').css({ top: scroll[1] + (size[3]/4),left: scroll[0] }); 356 }); 357 358 // Add optional ESC Key functionality 359 if (opts.closeESC) { 360 $(document).bind('keydown',function(event) { 361 // ESC = Keycode 27 362 if (event.keyCode == 27) element.trigger('closejr'); 363 }); 364 } 365
366 // afterReject: Customized Function 367 if ($.isFunction(opts.afterReject)) opts.afterReject(opts); 368 369 return true; 370 }; 371 372 // Based on compatibility data from quirksmode.com 373 var _pageSize = function() { 374 var xScroll = window.innerWidth && window.scrollMaxX ? window.innerWidth + window.scrollMaxX : 375 (document.body.scrollWidth > document.body.offsetWidth ? 376 document.body.scrollWidth : document.body.offsetWidth); 377 378 var yScroll = window.innerHeight && window.scrollMaxY ? window.innerHeight + window.scrollMaxY : 379 (document.body.scrollHeight > document.body.offsetHeight ? 380 document.body.scrollHeight : document.body.offsetHeight); 381 382 var windowWidth = window.innerWidth ? window.innerWidth : 383 (document.documentElement && document.documentElement.clientWidth ? 384 document.documentElement.clientWidth : document.body.clientWidth); 385 386 var windowHeight = window.innerHeight ? window.innerHeight : 387 (document.documentElement && document.documentElement.clientHeight ? 388 document.documentElement.clientHeight : document.body.clientHeight); 389 390 return [ 391 xScroll < windowWidth ? xScroll : windowWidth, // Page Width 392 yScroll < windowHeight ? windowHeight : yScroll, // Page Height 393 windowWidth,windowHeight 394 ]; 395 }; 396 397 398 // Based on compatibility data from quirksmode.com 399 var _scrollSize = function() { 400 return [ 401 // scrollSize X 402 window.pageXOffset ? window.pageXOffset : (document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollLeft : document.body.scrollLeft), 403 // scrollSize Y 404 window.pageYOffset ? window.pageYOffset : (document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) 405 ]; 406 }; 407})(jQuery); 408 409 410/* 411 jQuery Browser Plugin 412 * Version 2.4 413 * 2010-02-03 414 * URL: http://jquery.thewikies.com/browser 415 * Description: jQuery Browser Plugin extends browser detection capabilities and can assign browser selectors to CSS classes. 416 * Author: Nate Cavanaugh, Minhchau Dang, Jonathan Neal, & Gregory Waxman 417 * Copyright: Copyright (c) 2008 Jonathan Neal under dual MIT/GPL license. 418 * 419*/ 420(function(b){b.browserTest=function(d,f){var g=function(c,a){for(var e=0;e<a.length;e+=1)c=c.replace(a[e][0],a[e][1]);return c},h=function(c,a,e,i){a={name:g((a.exec(c)||["unknown","unknown"])[1],e)};a[a.name]=true;a.version=a.opera?window.opera.version():(i.exec(c)||["X","X","X","X"])[3];if(/safari/.test(a.name)&&a.version>400)a.version="2.0";else if(a.name==="presto")a.version=b.browser.version>9.27?"futhark":"linear_b";a.versionNumber=parseFloat(a.version,10)||0;c=1;if(a.versionNumber<100&&a.versionNumber> 4219)c=2;a.versionX=a.version!=="X"?a.version.substr(0,c):"X";a.className=a.name+a.versionX;return a};d=(/Opera|Navigator|Minefield|KHTML|Chrome/.test(d)?g(d,[[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/,""],["Chrome Safari","Chrome"],["KHTML","Konqueror"],["Minefield","Firefox"],["Navigator","Netscape"]]):d).toLowerCase();b.browser=b.extend(!f?b.browser:{},h(d,/(camino|chrome|firefox|netscape|konqueror|lynx|msie|opera|safari)/,[],/(camino|chrome|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/)); 422b.layout=h(d,/(gecko|konqueror|msie|opera|webkit)/,[["konqueror","khtml"],["msie","trident"],["opera","presto"]],/(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/);b.os={name:(/(win|mac|linux|sunos|solaris|iphone)/.exec(navigator.platform.toLowerCase())||["unknown"])[0].replace("sunos","solaris")};f||b("html").addClass([b.os.name,b.browser.name,b.browser.className,b.layout.name,b.layout.className].join(" "))};b.browserTest(navigator.userAgent)})(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.