aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel Luong2013-05-24 11:27:24 (EDT)
committerlibing wang2013-05-24 12:04:07 (EDT)
commite584b6ce40968df4601bbfaf70b3585bff5fcd81 (patch)
tree9612e9ea2fd2e026b273c419d26b95c6cc9eda50
parentf41e804a6d7af64e52037d083491afcba68e39b4 (diff)
downloadorg.eclipse.orion.client-e584b6ce40968df4601bbfaf70b3585bff5fcd81.zip
org.eclipse.orion.client-e584b6ce40968df4601bbfaf70b3585bff5fcd81.tar.gz
org.eclipse.orion.client-e584b6ce40968df4601bbfaf70b3585bff5fcd81.tar.bz2
Bug 408762 - browserCompatibility is a global
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/browserCompatibility.js52
1 files changed, 30 insertions, 22 deletions
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/browserCompatibility.js b/bundles/org.eclipse.orion.client.ui/web/orion/browserCompatibility.js
index 3179d16..4bb91c7 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/browserCompatibility.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/browserCompatibility.js
@@ -7,29 +7,37 @@
* License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
*
*******************************************************************************/
-/*global window document define login logout localStorage orion alert */
+/*global window document define login logout localStorage orion alert*/
/*jslint browser:true sub:true*/
-function isSupportedBrowser() {
- var userAgent = navigator.userAgent;
- var isSupported = false;
- var VERSION = 1;
- var browserData = [ {name:'Chrome', regExp: /chrome\/(\d+)/i, minVersion: 24},
- {name:'Firefox', regExp: /firefox\/(\d+)/i, minVersion: 5},
- {name:'MSIE', regExp: /msie\s(\d+)/i, minVersion: 10},
- {name:'Safari', regExp: /version\/(\d+).*?safari/i, minVersion: 6}];
-
- browserData.forEach( function( browser ){
- var matches = userAgent.match(browser.regExp);
- if(matches && matches[VERSION] >= browser.minVersion) {
- isSupported = true;
- }
- });
+define(function() {
+ function isSupportedBrowser() {
+ var userAgent = navigator.userAgent;
+ var isSupported = false;
+ var VERSION = 1;
+ var browserData = [ {name:'Chrome', regExp: /chrome\/(\d+)/i, minVersion: 24},
+ {name:'Firefox', regExp: /firefox\/(\d+)/i, minVersion: 5},
+ {name:'MSIE', regExp: /msie\s(\d+)/i, minVersion: 10},
+ {name:'Safari', regExp: /version\/(\d+).*?safari/i, minVersion: 6} ];
- return isSupported;
-}
+ for (var i = 0; i < browserData.length; i++) {
+ var browser = browserData[i];
+ var matches = userAgent.match(browser.regExp);
+ if (matches && matches[VERSION] >= browser.minVersion) {
+ isSupported = true;
+ break;
+ }
+ }
+
+ return isSupported;
+ }
-if (!isSupportedBrowser()) {
- alert("Sorry, your browser is not supported.\n\nTo use Orion, we recommend that you use the latest web browsers from Google Chrome, FireFox, or Safari.\n");
- throw 'unsupported browser';
-} \ No newline at end of file
+ if (!isSupportedBrowser()) {
+ alert("Sorry, your browser is not supported.\n\nTo use Orion, we recommend that you use the latest web browsers from Google Chrome, FireFox, or Safari.\n");
+ throw 'unsupported browser';
+ }
+
+ return {
+ isSupportedBrowser: isSupportedBrowser
+ };
+}); \ No newline at end of file