3 * Provide useful information about the current operating system environment. Access the global instance stored in Ext.os. Example:
5 * if (Ext.os.is.Windows) {
6 * // Windows specific code here
10 * // iPad, iPod, iPhone, etc.
13 * console.log("Version " + Ext.os.version);
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:
42 * if (Ext.os.is('Android')) { ... }
45 * or as an object with boolean properties, i.e:
47 * if (Ext.os.is.Android) { ... }
50 * Versions can be conveniently checked as well. For example:
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))
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
69 * Read-only - the full name of the current operating system
70 * Possible values are: iOS, Android, WebOS, BlackBerry, MacOSX, Windows, Linux and Other
76 * Read-only, refer to {@link Ext.Version}
81 constructor: function() {
82 var userAgent = Ext.global.navigator.userAgent,
83 platform = Ext.global.navigator.platform,
84 selfClass = this.statics(),
85 osMatch = userAgent.match(new RegExp('((?:' + Ext.Object.getValues(selfClass.osPrefixes).join(')|(?:') + '))([^\\s;]+)')),
91 name = selfClass.osNames[Ext.Object.getKey(selfClass.osPrefixes, osMatch[1])];
94 if (name === 'BlackBerry') {
95 actualVersionMatch = userAgent.match(/Version\/([\d\._]+)/);
97 if (actualVersionMatch) {
98 version = actualVersionMatch[1];
103 name = selfClass.osNames[(userAgent.toLowerCase().match(/mac|win|linux/i) || ['other'])[0]];
108 version: new Ext.Version(version)
111 this.is = function(name) {
112 return this.is[name] === true;
115 if (name === 'iOS') {
116 this.is[platform] = true;
119 this.is[this.name] = true;
120 this.is[this.name + (this.version.getMajor() || '')] = true;
121 this.is[this.name + this.version.getShortVersion()] = true;
123 Ext.Object.each(selfClass.osNames, function(key, name) {
124 this.is[name] = (this.name === name);
131 Ext.os = new Ext.env.OS();