4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-env-Browser'>/**
19 </span> * @class Ext.env.Browser
21 * Provide useful information about the current browser.
22 * Should not be manually instantiated unless for unit-testing; access the global instance stored in Ext.browser instead. Example:
23 * <pre><code>
24 * if (Ext.browser.is.IE) {
25 * // IE specific code here
28 * if (Ext.browser.is.WebKit) {
29 * // WebKit specific code here
32 * console.log("Version " + Ext.browser.version);
33 * </code></pre>
35 * For a full list of supported values, refer to: {@link Ext.env.Browser#is}
37 * @borrows Ext.Base.extend
39 Ext.define('Ext.env.Browser', {
57 webkit: 'AppleWebKit/',
71 <span id='Ext-env-Browser-property-isSecure'> /**
72 </span> * True if the page is running over SSL
77 <span id='Ext-env-Browser-property-isStrict'> /**
78 </span> * True if the document is in strict mode
83 <span id='Ext-env-Browser-method-is'> /**
84 </span> * A "hybrid" property, can be either accessed as a method call, i.e:
85 * <pre><code>
86 * if (Ext.browser.is('IE')) { ... }
87 * </code></pre>
89 * or as an object with boolean properties, i.e:
90 * <pre><code>
91 * if (Ext.browser.is.IE) { ... }
92 * </code></pre>
94 * Versions can be conveniently checked as well. For example:
95 * <pre><code>
96 * if (Ext.browser.is.IE6) { ... } // Equivalent to (Ext.browser.is.IE && Ext.browser.version.equals(6))
97 * </code></pre>
99 * Note that only {@link Ext.Version#getMajor major component} and {@link Ext.Version#getShortVersion shortVersion}
100 * value of the version are available via direct property checking.
102 * Supported values are: IE, Firefox, Safari, Chrome, Opera, WebKit, Gecko, Presto, Trident and Other
104 * @param {String} value The OS name to check
110 <span id='Ext-env-Browser-property-name'> /**
111 </span> * Read-only - the full name of the current browser
112 * Possible values are: IE, Firefox, Safari, Chrome, Opera and Other
117 <span id='Ext-env-Browser-property-version'> /**
118 </span> * Read-only, refer to {@link Ext.Version}
123 <span id='Ext-env-Browser-property-engineName'> /**
124 </span> * Read-only - the full name of the current browser's engine
125 * Possible values are: WebKit, Gecko, Presto, Trident and Other
130 <span id='Ext-env-Browser-property-engineVersion'> /**
131 </span> * Read-only, refer to {@link Ext.Version}
136 constructor: function() {
137 var userAgent = this.userAgent = Ext.global.navigator.userAgent,
138 selfClass = this.statics(),
139 browserMatch = userAgent.match(new RegExp('((?:' + Ext.Object.getValues(selfClass.browserPrefixes).join(')|(?:') + '))([\\d\\._]+)')),
140 engineMatch = userAgent.match(new RegExp('((?:' + Ext.Object.getValues(selfClass.enginePrefixes).join(')|(?:') + '))([\\d\\._]+)')),
141 browserName = selfClass.browserNames.other,
143 engineName = selfClass.engineNames.other,
146 this.is = function(name) {
147 return this.is[name] === true;
151 browserName = selfClass.browserNames[Ext.Object.getKey(selfClass.browserPrefixes, browserMatch[1])];
152 browserVersion = browserMatch[2];
156 engineName = selfClass.engineNames[Ext.Object.getKey(selfClass.enginePrefixes, engineMatch[1])];
157 engineVersion = engineMatch[2];
161 engineName: engineName,
162 engineVersion: new Ext.Version(engineVersion),
164 version: new Ext.Version(browserVersion)
167 this.is[this.name] = true;
168 this.is[this.name + (this.version.getMajor() || '')] = true;
169 this.is[this.name + this.version.getShortVersion()] = true;
170 Ext.Object.each(selfClass.browserNames, function(key, name) {
171 this.is[name] = (this.name === name);
174 this.is[this.name] = true;
175 this.is[this.engineName + (this.engineVersion.getMajor() || '')] = true;
176 this.is[this.engineName + this.engineVersion.getShortVersion()] = true;
177 Ext.Object.each(selfClass.engineNames, function(key, name) {
178 this.is[name] = (this.engineName === name);
182 this.isSecure = /^https/i.test(Ext.global.location.protocol);
184 this.isStrict = Ext.global.document.compatMode === "CSS1Compat";
191 Ext.browser = new Ext.env.Browser();