4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/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> * Provides useful information about the current browser.
20 * Should not be manually instantiated unless for unit-testing; access the global instance
21 * stored in {@link Ext#browser} instead. Example:
23 * if (Ext.browser.is.IE) {
24 * // IE specific code here
27 * if (Ext.browser.is.WebKit) {
28 * // WebKit specific code here
31 * console.log("Version " + Ext.browser.version);
33 * For a full list of supported values, refer to: {@link Ext.env.Browser#is}
35 Ext.define('Ext.env.Browser', {
53 webkit: 'AppleWebKit/',
67 <span id='Ext-env-Browser-property-isSecure'> /**
68 </span> * @property {Boolean} isSecure
69 * True if the page is running over SSL
73 <span id='Ext-env-Browser-property-isStrict'> /**
74 </span> * @property {Boolean} isStrict
75 * True if the document is in strict mode
79 <span id='Ext-env-Browser-method-is'> /**
80 </span> * A "hybrid" property, can be either accessed as a method call, i.e:
82 * if (Ext.browser.is('IE')) { ... }
84 * or as an object with boolean properties, i.e:
86 * if (Ext.browser.is.IE) { ... }
88 * Versions can be conveniently checked as well. For example:
90 * if (Ext.browser.is.IE6) { ... } // Equivalent to (Ext.browser.is.IE && Ext.browser.version.equals(6))
92 * Note that only {@link Ext.Version#getMajor major component} and {@link Ext.Version#getShortVersion shortVersion}
93 * value of the version are available via direct property checking.
95 * Supported values are: IE, Firefox, Safari, Chrome, Opera, WebKit, Gecko, Presto, Trident and Other
97 * @param {String} value The OS name to check
103 <span id='Ext-env-Browser-property-name'> /**
104 </span> * @property {String} name
105 * Read-only - the full name of the current browser
106 * Possible values are: IE, Firefox, Safari, Chrome, Opera and Other
110 <span id='Ext-env-Browser-property-version'> /**
111 </span> * @property {Ext.Version} version
112 * Read-only, refer to {@link Ext.Version}
116 <span id='Ext-env-Browser-property-engineName'> /**
117 </span> * @property {String} engineName
118 * Read-only - the full name of the current browser's engine
119 * Possible values are: WebKit, Gecko, Presto, Trident and Other
123 <span id='Ext-env-Browser-property-engineVersion'> /**
124 </span> * @property {String} engineVersion
125 * Read-only, refer to {@link Ext.Version}
129 constructor: function() {
130 var userAgent = this.userAgent = Ext.global.navigator.userAgent,
131 selfClass = this.statics(),
132 browserMatch = userAgent.match(new RegExp('((?:' + Ext.Object.getValues(selfClass.browserPrefixes).join(')|(?:') + '))([\\d\\._]+)')),
133 engineMatch = userAgent.match(new RegExp('((?:' + Ext.Object.getValues(selfClass.enginePrefixes).join(')|(?:') + '))([\\d\\._]+)')),
134 browserName = selfClass.browserNames.other,
136 engineName = selfClass.engineNames.other,
139 this.is = function(name) {
140 return this.is[name] === true;
144 browserName = selfClass.browserNames[Ext.Object.getKey(selfClass.browserPrefixes, browserMatch[1])];
145 browserVersion = browserMatch[2];
149 engineName = selfClass.engineNames[Ext.Object.getKey(selfClass.enginePrefixes, engineMatch[1])];
150 engineVersion = engineMatch[2];
154 engineName: engineName,
155 engineVersion: new Ext.Version(engineVersion),
157 version: new Ext.Version(browserVersion)
160 this.is[this.name] = true;
161 this.is[this.name + (this.version.getMajor() || '')] = true;
162 this.is[this.name + this.version.getShortVersion()] = true;
163 Ext.Object.each(selfClass.browserNames, function(key, name) {
164 this.is[name] = (this.name === name);
167 this.is[this.name] = true;
168 this.is[this.engineName + (this.engineVersion.getMajor() || '')] = true;
169 this.is[this.engineName + this.engineVersion.getShortVersion()] = true;
170 Ext.Object.each(selfClass.engineNames, function(key, name) {
171 this.is[name] = (this.engineName === name);
175 this.isSecure = /^https/i.test(Ext.global.location.protocol);
177 this.isStrict = Ext.global.document.compatMode === "CSS1Compat";
184 <span id='Ext-property-browser'> /**
185 </span> * @property {Ext.env.Browser} browser
187 * Global convenient instance of {@link Ext.env.Browser}.
189 Ext.browser = new Ext.env.Browser();