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-OS'>/**
19 </span> * @class Ext.env.OS
20 * Provide useful information about the current operating system environment. Access the global instance stored in Ext.os. Example:
21 * <pre><code>
22 * if (Ext.os.is.Windows) {
23 * // Windows specific code here
26 * if (Ext.os.is.iOS) {
27 * // iPad, iPod, iPhone, etc.
30 * console.log("Version " + Ext.os.version);
31 * </code></pre>
33 * For a full list of supported values, refer to: {@link Ext.env.OS#is 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:
58 * <pre><code>
59 * if (Ext.os.is('Android')) { ... }
60 * </code></pre>
62 * or as an object with boolean properties, i.e:
63 * <pre><code>
64 * if (Ext.os.is.Android) { ... }
65 * </code></pre>
67 * Versions can be conveniently checked as well. For example:
68 * <pre><code>
69 * if (Ext.os.is.Android2) { ... } // Equivalent to (Ext.os.is.Android && Ext.os.version.equals(2))
71 * if (Ext.os.is.iOS32) { ... } // Equivalent to (Ext.os.is.iOS && Ext.os.version.equals(3.2))
72 * </code></pre>
74 * Note that only {@link Ext.Version#getMajor major component} and {@link Ext.Version#getShortVersion shortVersion}
75 * value of the version are available via direct property checking.
77 * Supported values are: iOS, iPad, iPhone, iPod, Android, WebOS, BlackBerry, MacOSX, Windows, Linux and Other
79 * @param {String} value The OS name to check
85 <span id='Ext-env-OS-property-name'> /**
86 </span> * Read-only - the full name of the current operating system
87 * Possible values are: iOS, Android, WebOS, BlackBerry, MacOSX, Windows, Linux and Other
92 <span id='Ext-env-OS-property-version'> /**
93 </span> * Read-only, refer to {@link Ext.Version}
98 constructor: function() {
99 var userAgent = Ext.global.navigator.userAgent,
100 platform = Ext.global.navigator.platform,
101 selfClass = this.statics(),
102 osMatch = userAgent.match(new RegExp('((?:' + Ext.Object.getValues(selfClass.osPrefixes).join(')|(?:') + '))([^\\s;]+)')),
108 name = selfClass.osNames[Ext.Object.getKey(selfClass.osPrefixes, osMatch[1])];
109 version = osMatch[2];
111 if (name === 'BlackBerry') {
112 actualVersionMatch = userAgent.match(/Version\/([\d\._]+)/);
114 if (actualVersionMatch) {
115 version = actualVersionMatch[1];
120 name = selfClass.osNames[(userAgent.toLowerCase().match(/mac|win|linux/i) || ['other'])[0]];
125 version: new Ext.Version(version)
128 this.is = function(name) {
129 return this.is[name] === true;
132 if (name === 'iOS') {
133 this.is[platform] = true;
136 this.is[this.name] = true;
137 this.is[this.name + (this.version.getMajor() || '')] = true;
138 this.is[this.name + this.version.getShortVersion()] = true;
140 Ext.Object.each(selfClass.osNames, function(key, name) {
141 this.is[name] = (this.name === name);
148 Ext.os = new Ext.env.OS();