1/* 2--- 3 4name: BrowserUpdateWarning 5 6description: Browser Version Check and Warn 7 8version: 1.0.6 9 10license: MIT-style license 11 12authors: 13 - Andy Fleming 14 15requires: [Core/Class, Core/Object, Core/Element.Event] 16 17provides: [BrowserUpdateWarning] 18 19... 20*/ 21 22//################################################################################################################## 23// BrowserUpdateWarning Class 24//################################################################################################################## 25 26 var BrowserUpdateWarning = new Class({ 27 28 Implements: [Options, Events], 29 30 // ------------------------------------------------------------------------------------ 31 // Options 32 // ------------------------------------------------------------------------------------ 33 34 options: { 35 36 showPopup: true, 37 38 // Allow user to close prompt and continue to website 39 allowContinue: false, 40 41 imagesDirectory: 'images/', 42 43 shade: true, 44 opacity: 88, 45 46 // Minimum Versions 47 minVersion_ie: 7, 48 minVersion_safari: 5, 49 minVersion_firefox: 5, 50 minVersion_chrome: 15, 51 minVersion_opera: 10, 52 53 // Update Links 54 updateLink_ie: 'http://windows.microsoft.com/en-US/internet-explorer/downloads/ie', 55 updateLink_safari: 'http://www.apple.com/safari/download/', 56 updateLink_firefox: 'http://getfirefox.com/', 57 updateLink_chrome: 'https://www.google.com/chrome', 58 updateLink_opera: 'http://www.opera.com/download/', 59 60 61 // A list of update options to show to the user 62 downloadOptions: ['ie','safari','firefox','chrome','opera'] 63 64 // Events 65 //onFailure: $empty 66 //onSuccess: $empty 67 68 }, 69 70 // ------------------------------------------------------------------------------------ 71 // Initialize 72 // ------------------------------------------------------------------------------------ 73 74 // Init 75 initialize: function (options) { 76 this.setOptions(options); 77 }, 78 79 80 // ------------------------------------------------------------------------------------ 81 // Check (and warn if necessary) 82 // ------------------------------------------------------------------------------------ 83 84 check: function() { 85 86 var self = this; 87 88 var browsers = ['ie','safari','firefox','chrome','opera']; 89 90 browsers.each(function(key,index) { 91 if(Browser.name == 'ie' && Browser.version == 5) Browser.version = 9; 92 if (Browser.name == key && Browser.version < self.options['minVersion_'+key]) { 93 if (self.options.showPopup) { self.showBrowserUpdateWarning(); } 94 self.fireEvent('onFailure'); 95 return; 96 } 97 }); 98 99 // If all requirements were met, fire success event 100 self.fireEvent('onSuccess'); 101 102 103 }, 104 105 106 // ------------------------------------------------------------------------------------ 107 // showBrowserUpdateWarning 108 // Shows warning; called in check() 109 // ------------------------------------------------------------------------------------ 110 111 showBrowserUpdateWarning: function() { 112 113 var self = this; 114 115 // If the shade is turned on, show it 116 if (self.options.shade) { self.showShade(); } 117 118 var updateLink = self.options['updateLink_'+Browser.name]; 119 120 html = '<div id="BrowserUpdateWarningContent">'; 121 html += '<h1>'+ window.plg_system_browserupdatewarning_language.TIMETOUPGRADE +'</h1>'; 122 html += '<div class="yourBrowser">'; 123 html += '<img src="'+self.options.imagesDirectory+'icon-'+Browser.name+'.png" />'; 124 html += '<a href="'+updateLink+'" target="_blank">'+ window.plg_system_browserupdatewarning_language.UPDATECURRENT +' »</a>'; 125 html += '</div>'; 126 html += '<div class="otherBrowsers">'; 127 this.options.downloadOptions.each(function(key,index) { 128 if (key != Browser.name) { 129 html += '<a href="'+self.options['updateLink_'+key]+'">'; 130 html += '<img src="'+self.options.imagesDirectory+'icon-'+key+'.png" />'; 131 html += window.plg_system_browserupdatewarning_language[key.toUpperCase()]; 132 html += ' »</a>'; 133 } 134 }); 135 html += '</div>'; 136 html += '<div class="whyUpgrade">'; 137 html += '<h2>'+ window.plg_system_browserupdatewarning_language.WHYSHOULDI +'</h2>'; 138 html += '<ul>'; 139 html += '<li>'+ window.plg_system_browserupdatewarning_language.WHYFASTER +'</li>'; 140 html += '<li>'+ window.plg_system_browserupdatewarning_language.WHYRENDER +'</li>'; 141 html += '<li>'+ window.plg_system_browserupdatewarning_language.WHYSAFER +'</li>'; 142 html += '<li>'+ window.plg_system_browserupdatewarning_language.WHYMORE +'</li>'; 143 html += '</ul>'; 144 html += '</div>'; 145 if (self.options.allowContinue) { 146 html += '<a href="javascript:void(0);" class="continueToSite" onclick="'; 147 html += 'document.id(\'BrowserUpdateWarningWrapper\').setStyle(\'dis
147play\',\'none\');'; 148 if (self.options.shade) html += 'document.id(\'BrowserUpdateWarningShade\').setStyle(\'display\',\'none\');'; 149 html += 'var plg_system_browserupdatewarning_cookie = Cookie.write(\'plg_system_browserupdatewarning\', 1);'; 150 html += '">'+ window.plg_system_browserupdatewarning_language.CONTINUE +' »</a>'; 151 } 152 html += '<div style="clear:both"></div>'; 153 154 155 156 html += '</div>'; 157 158 159 // Create DIV element and inject into body 160 divName = 'BrowserUpdateWarningWrapper'; 161 if(Browser.name == 'ie'){ divName += '-ie'; } 162 var div = new Element('div', {id: divName}); 163 div.set('html',html).inject(document.body); 164 165 }, 166 167 // ------------------------------------------------------------------------------------ 168 // showShade 169 // ------------------------------------------------------------------------------------ 170 171 showShade: function() { 172 173 var opacity = this.options.opacity; 174 175 // Create shade and append to body 176 divName = 'BrowserUpdateWarningShade'; 177 if(Browser.name == 'ie'){ divName += '-ie'; } 178 var shade = new Element('div',{id: divName}); 179 shade.setStyle('opacity',(opacity/100)); 180 shade.setStyle('-ms-filter','"progid:DXImageTransform.Microsoft.Alpha(Opacity='+opacity+')"'); 181 shade.setStyle('filter','alpha(opacity = '+opacity+')'); 182 183 shade.inject(document.body); 184 185 } 186 187 188 189 }); // End of Class: BrowserUpdateWarning
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.