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-OS'>/**
19 </span> * @class Ext.env.OS
20 * Provides useful information about the current operating system environment.
21 * Access the global instance stored in {@link Ext#os}. Example:
23 * if (Ext.os.is.Windows) {
24 * // Windows specific code here
27 * if (Ext.os.is.iOS) {
28 * // iPad, iPod, iPhone, etc.
31 * console.log("Version " + Ext.os.version);
33 * For a full list of supported values, refer to: {@link Ext.env.OS#is}
35 Ext.define('Ext.env.OS', {
42 blackberry: 'BlackBerry',
51 blackberry: 'BlackBerry ',
56 <span id='Ext-env-OS-method-is'> /**
57 </span> * A "hybrid" property, can be either accessed as a method call, i.e:
59 * if (Ext.os.is('Android')) { ... }
61 * or as an object with boolean properties, i.e:
63 * if (Ext.os.is.Android) { ... }
65 * Versions can be conveniently checked as well. For example:
67 * if (Ext.os.is.Android2) { ... } // Equivalent to (Ext.os.is.Android && Ext.os.version.equals(2))
69 * if (Ext.os.is.iOS32) { ... } // Equivalent to (Ext.os.is.iOS && Ext.os.version.equals(3.2))
71 * Note that only {@link Ext.Version#getMajor major component} and {@link Ext.Version#getShortVersion shortVersion}
72 * value of the version are available via direct property checking.
74 * Supported values are: iOS, iPad, iPhone, iPod, Android, WebOS, BlackBerry, MacOSX, Windows, Linux and Other
76 * @param {String} value The OS name to check
82 <span id='Ext-env-OS-property-name'> /**
83 </span> * @property {String} name
84 * Read-only - the full name of the current operating system
85 * Possible values are: iOS, Android, WebOS, BlackBerry, MacOSX, Windows, Linux and Other
89 <span id='Ext-env-OS-property-version'> /**
90 </span> * @property {Ext.Version} version
91 * Read-only, refer to {@link Ext.Version}
95 constructor: function() {
96 var userAgent = Ext.global.navigator.userAgent,
97 platform = Ext.global.navigator.platform,
98 selfClass = this.statics(),
99 osMatch = userAgent.match(new RegExp('((?:' + Ext.Object.getValues(selfClass.osPrefixes).join(')|(?:') + '))([^\\s;]+)')),
105 name = selfClass.osNames[Ext.Object.getKey(selfClass.osPrefixes, osMatch[1])];
106 version = osMatch[2];
108 if (name === 'BlackBerry') {
109 actualVersionMatch = userAgent.match(/Version\/([\d\._]+)/);
111 if (actualVersionMatch) {
112 version = actualVersionMatch[1];
117 name = selfClass.osNames[(userAgent.toLowerCase().match(/mac|win|linux/i) || ['other'])[0]];
122 version: new Ext.Version(version)
125 this.is = function(name) {
126 return this.is[name] === true;
129 if (name === 'iOS') {
130 this.is[platform] = true;
133 this.is[this.name] = true;
134 this.is[this.name + (this.version.getMajor() || '')] = true;
135 this.is[this.name + this.version.getShortVersion()] = true;
137 Ext.Object.each(selfClass.osNames, function(key, name) {
138 this.is[name] = (this.name === name);
145 <span id='Ext-property-os'> /**
146 </span> * @property {Ext.env.OS} os
148 * Global convenient instance of {@link Ext.env.OS}.
150 Ext.os = new Ext.env.OS();