1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-env.Browser'>/**
2 </span> * @class Ext.env.Browser
4 * Provide useful information about the current browser.
5 * Should not be manually instantiated unless for unit-testing; access the global instance stored in Ext.browser instead. Example:
6 * <pre><code>
7 * if (Ext.browser.is.IE) {
8 * // IE specific code here
11 * if (Ext.browser.is.WebKit) {
12 * // WebKit specific code here
15 * console.log("Version " + Ext.browser.version);
16 * </code></pre>
18 * For a full list of supported values, refer to: {@link Ext.env.Browser#is}
20 * @borrows Ext.Base.extend
22 Ext.define('Ext.env.Browser', {
40 webkit: 'AppleWebKit/',
54 <span id='Ext-env.Browser-property-isSecure'> /**
55 </span> * True if the page is running over SSL
60 <span id='Ext-env.Browser-property-isStrict'> /**
61 </span> * True if the document is in strict mode
66 <span id='Ext-env.Browser-property-is'> /**
67 </span> * A "hybrid" property, can be either accessed as a method call, i.e:
68 * <pre><code>
69 * if (Ext.browser.is('IE')) { ... }
70 * </code></pre>
72 * or as an object with boolean properties, i.e:
73 * <pre><code>
74 * if (Ext.browser.is.IE) { ... }
75 * </code></pre>
77 * Versions can be conveniently checked as well. For example:
78 * <pre><code>
79 * if (Ext.browser.is.IE6) { ... } // Equivalent to (Ext.browser.is.IE && Ext.browser.version.equals(6))
80 * </code></pre>
82 * Note that only {@link Ext.Version#getMajor major component} and {@link Ext.Version#getShortVersion shortVersion}
83 * value of the version are available via direct property checking.
85 * Supported values are: IE, Firefox, Safari, Chrome, Opera, WebKit, Gecko, Presto, Trident and Other
87 * @param {String} value The OS name to check
92 <span id='Ext-env.Browser-property-name'> /**
93 </span> * Read-only - the full name of the current browser
94 * Possible values are: IE, Firefox, Safari, Chrome, Opera and Other
99 <span id='Ext-env.Browser-property-version'> /**
100 </span> * Read-only, refer to {@link Ext.Version}
105 <span id='Ext-env.Browser-property-engineName'> /**
106 </span> * Read-only - the full name of the current browser's engine
107 * Possible values are: WebKit, Gecko, Presto, Trident and Other
112 <span id='Ext-env.Browser-property-engineVersion'> /**
113 </span> * Read-only, refer to {@link Ext.Version}
118 constructor: function() {
119 var userAgent = this.userAgent = Ext.global.navigator.userAgent,
120 selfClass = this.statics(),
121 browserMatch = userAgent.match(new RegExp('((?:' + Ext.Object.getValues(selfClass.browserPrefixes).join(')|(?:') + '))([\\d\\._]+)')),
122 engineMatch = userAgent.match(new RegExp('((?:' + Ext.Object.getValues(selfClass.enginePrefixes).join(')|(?:') + '))([\\d\\._]+)')),
123 browserName = selfClass.browserNames.other,
125 engineName = selfClass.engineNames.other,
128 this.is = function(name) {
129 return this.is[name] === true;
133 browserName = selfClass.browserNames[Ext.Object.getKey(selfClass.browserPrefixes, browserMatch[1])];
134 browserVersion = browserMatch[2];
138 engineName = selfClass.engineNames[Ext.Object.getKey(selfClass.enginePrefixes, engineMatch[1])];
139 engineVersion = engineMatch[2];
143 engineName: engineName,
144 engineVersion: new Ext.Version(engineVersion),
146 version: new Ext.Version(browserVersion)
149 this.is[this.name] = true;
150 this.is[this.name + (this.version.getMajor() || '')] = true;
151 this.is[this.name + this.version.getShortVersion()] = true;
152 Ext.Object.each(selfClass.browserNames, function(key, name) {
153 this.is[name] = (this.name === name);
156 this.is[this.name] = true;
157 this.is[this.engineName + (this.engineVersion.getMajor() || '')] = true;
158 this.is[this.engineName + this.engineVersion.getShortVersion()] = true;
159 Ext.Object.each(selfClass.engineNames, function(key, name) {
160 this.is[name] = (this.engineName === name);
164 this.isSecure = /^https/i.test(Ext.global.location.protocol);
166 this.isStrict = Ext.global.document.compatMode === "CSS1Compat";
173 Ext.browser = new Ext.env.Browser();
176 </pre></pre></body></html>