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.OS'>/**
2 </span> * @class Ext.env.OS
3 * Provide useful information about the current operating system environment. Access the global instance stored in Ext.os. Example:
4 * <pre><code>
5 * if (Ext.os.is.Windows) {
6 * // Windows specific code here
10 * // iPad, iPod, iPhone, etc.
13 * console.log("Version " + Ext.os.version);
14 * </code></pre>
16 * For a full list of supported values, refer to: {@link Ext.env.OS#is Ext.env.OS.is}
18 Ext.define('Ext.env.OS', {
25 blackberry: 'BlackBerry',
34 blackberry: 'BlackBerry ',
40 * A "hybrid" property, can be either accessed as a method call, i.e:
41 * <pre><code>
42 * if (Ext.os.is('Android')) { ... }
43 * </code></pre>
45 * or as an object with boolean properties, i.e:
46 * <pre><code>
47 * if (Ext.os.is.Android) { ... }
48 * </code></pre>
50 * Versions can be conveniently checked as well. For example:
51 * <pre><code>
52 * if (Ext.os.is.Android2) { ... } // Equivalent to (Ext.os.is.Android && Ext.os.version.equals(2))
54 * if (Ext.os.is.iOS32) { ... } // Equivalent to (Ext.os.is.iOS && Ext.os.version.equals(3.2))
55 * </code></pre>
57 * Note that only {@link Ext.Version#getMajor major component} and {@link Ext.Version#getShortVersion shortVersion}
58 * value of the version are available via direct property checking.
60 * Supported values are: iOS, iPad, iPhone, iPod, Android, WebOS, BlackBerry, MacOSX, Windows, Linux and Other
62 * @param {String} value The OS name to check
68 * Read-only - the full name of the current operating system
69 * Possible values are: iOS, Android, WebOS, BlackBerry, MacOSX, Windows, Linux and Other
75 * Read-only, refer to {@link Ext.Version}
80 constructor: function() {
81 var userAgent = Ext.global.navigator.userAgent,
82 platform = Ext.global.navigator.platform,
83 selfClass = this.statics(),
84 osMatch = userAgent.match(new RegExp('((?:' + Ext.Object.getValues(selfClass.osPrefixes).join(')|(?:') + '))([^\\s;]+)')),
90 name = selfClass.osNames[Ext.Object.getKey(selfClass.osPrefixes, osMatch[1])];
93 if (name === 'BlackBerry') {
94 actualVersionMatch = userAgent.match(/Version\/([\d\._]+)/);
96 if (actualVersionMatch) {
97 version = actualVersionMatch[1];
102 name = selfClass.osNames[(userAgent.toLowerCase().match(/mac|win|linux/i) || ['other'])[0]];
107 version: new Ext.Version(version)
110 this.is = function(name) {
111 return this.is[name] === true;
114 if (name === 'iOS') {
115 this.is[platform] = true;
118 this.is[this.name] = true;
119 this.is[this.name + (this.version.getMajor() || '')] = true;
120 this.is[this.name + this.version.getShortVersion()] = true;
122 Ext.Object.each(selfClass.osNames, function(key, name) {
123 this.is[name] = (this.name === name);
130 Ext.os = new Ext.env.OS();
133 </pre></pre></body></html>