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-is'>/**
19 </span> * @class Ext.is
21 * Determines information about the current platform the application is running on.
26 init : function(navigator) {
27 var platforms = this.platforms,
28 ln = platforms.length,
31 navigator = navigator || window.navigator;
33 for (i = 0; i < ln; i++) {
34 platform = platforms[i];
35 this[platform.identity] = platform.regex.test(navigator[platform.property]);
38 <span id='Ext-is-property-Desktop'> /**
39 </span> * @property Desktop True if the browser is running on a desktop machine
42 this.Desktop = this.Mac || this.Windows || (this.Linux && !this.Android);
43 <span id='Ext-is-property-Tablet'> /**
44 </span> * @property Tablet True if the browser is running on a tablet (iPad)
46 this.Tablet = this.iPad;
47 <span id='Ext-is-property-Phone'> /**
48 </span> * @property Phone True if the browser is running on a phone.
51 this.Phone = !this.Desktop && !this.Tablet;
52 <span id='Ext-is-property-iOS'> /**
53 </span> * @property iOS True if the browser is running on iOS
56 this.iOS = this.iPhone || this.iPad || this.iPod;
58 <span id='Ext-is-property-Standalone'> /**
59 </span> * @property Standalone Detects when application has been saved to homescreen.
62 this.Standalone = !!window.navigator.standalone;
65 <span id='Ext-is-property-iPhone'> /**
66 </span> * @property iPhone True when the browser is running on a iPhone
75 <span id='Ext-is-property-iPod'> /**
76 </span> * @property iPod True when the browser is running on a iPod
85 <span id='Ext-is-property-iPad'> /**
86 </span> * @property iPad True when the browser is running on a iPad
90 property: 'userAgent',
95 <span id='Ext-is-property-Blackberry'> /**
96 </span> * @property Blackberry True when the browser is running on a Blackberry
100 property: 'userAgent',
101 regex: /Blackberry/i,
102 identity: 'Blackberry'
105 <span id='Ext-is-property-Android'> /**
106 </span> * @property Android True when the browser is running on an Android device
110 property: 'userAgent',
115 <span id='Ext-is-property-Mac'> /**
116 </span> * @property Mac True when the browser is running on a Mac
120 property: 'platform',
125 <span id='Ext-is-property-Windows'> /**
126 </span> * @property Windows True when the browser is running on Windows
130 property: 'platform',
135 <span id='Ext-is-property-Linux'> /**
136 </span> * @property Linux True when the browser is running on Linux
140 property: 'platform',
148 <span id='Ext-supports'>/**
149 </span> * @class Ext.supports
151 * Determines information about features are supported in the current environment
158 div = doc.createElement('div'),
164 '<div style="height:30px;width:50px;">',
165 '<div style="height:20px;width:20px;"></div>',
167 '<div style="width: 200px; height: 200px; position: relative; padding: 5px;">',
168 '<div style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></div>',
170 '<div style="float:left; background-color:transparent;"></div>'
173 doc.body.appendChild(div);
175 for (i = 0; i < ln; i++) {
177 this[test.identity] = test.fn.call(this, doc, div);
180 doc.body.removeChild(div);
183 <span id='Ext-supports-property-CSS3BoxShadow'> /**
184 </span> * @property CSS3BoxShadow True if document environment supports the CSS3 box-shadow style.
187 CSS3BoxShadow: Ext.isDefined(document.documentElement.style.boxShadow),
189 <span id='Ext-supports-property-ClassList'> /**
190 </span> * @property ClassList True if document environment supports the HTML5 classList API.
193 ClassList: !!document.documentElement.classList,
195 <span id='Ext-supports-property-OrientationChange'> /**
196 </span> * @property OrientationChange True if the device supports orientation change
199 OrientationChange: ((typeof window.orientation != 'undefined') && ('onorientationchange' in window)),
201 <span id='Ext-supports-property-DeviceMotion'> /**
202 </span> * @property DeviceMotion True if the device supports device motion (acceleration and rotation rate)
205 DeviceMotion: ('ondevicemotion' in window),
207 <span id='Ext-supports-property-Touch'> /**
208 </span> * @property Touch True if the device supports touch
211 // is.Desktop is needed due to the bug in Chrome 5.0.375, Safari 3.1.2
212 // and Safari 4.0 (they all have 'ontouchstart' in the window object).
213 Touch: ('ontouchstart' in window) && (!Ext.is.Desktop),
216 <span id='Ext-supports-property-Transitions'> /**
217 </span> * @property Transitions True if the device supports CSS3 Transitions
221 identity: 'Transitions',
222 fn: function(doc, div) {
230 TE = 'TransitionEnd',
231 transitionEndName = [
233 'transitionend', //Moz bucks the prefixing convention
242 for (; i < ln; i++) {
243 if (div.getStyle(prefix[i] + "TransitionProperty")) {
244 Ext.supports.CSS3Prefix = prefix[i];
245 Ext.supports.CSS3TransitionEnd = transitionEndName[i];
254 <span id='Ext-supports-property-RightMargin'> /**
255 </span> * @property RightMargin True if the device supports right margin.
256 * See https://bugs.webkit.org/show_bug.cgi?id=13343 for why this is needed.
260 identity: 'RightMargin',
261 fn: function(doc, div) {
262 var view = doc.defaultView;
263 return !(view && view.getComputedStyle(div.firstChild.firstChild, null).marginRight != '0px');
267 <span id='Ext-supports-property-DisplayChangeInputSelectionBug'> /**
268 </span> * @property DisplayChangeInputSelectionBug True if INPUT elements lose their
269 * selection when their display style is changed. Essentially, if a text input
270 * has focus and its display style is changed, the I-beam disappears.
272 * This bug is encountered due to the work around in place for the {@link #RightMargin}
273 * bug. This has been observed in Safari 4.0.4 and older, and appears to be fixed
274 * in Safari 5. It's not clear if Safari 4.1 has the bug, but it has the same WebKit
275 * version number as Safari 5 (according to http://unixpapa.com/js/gecko.html).
278 identity: 'DisplayChangeInputSelectionBug',
280 var webKitVersion = Ext.webKitVersion;
281 // WebKit but older than Safari 5 or Chrome 6:
282 return 0 < webKitVersion && webKitVersion < 533;
286 <span id='Ext-supports-property-DisplayChangeTextAreaSelectionBug'> /**
287 </span> * @property DisplayChangeTextAreaSelectionBug True if TEXTAREA elements lose their
288 * selection when their display style is changed. Essentially, if a text area has
289 * focus and its display style is changed, the I-beam disappears.
291 * This bug is encountered due to the work around in place for the {@link #RightMargin}
292 * bug. This has been observed in Chrome 10 and Safari 5 and older, and appears to
293 * be fixed in Chrome 11.
296 identity: 'DisplayChangeTextAreaSelectionBug',
298 var webKitVersion = Ext.webKitVersion;
303 (Chrome) Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US)
304 AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.127
306 (Safari) Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us)
307 AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5
312 (Chrome) Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7)
313 AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57
316 return 0 < webKitVersion && webKitVersion < 534.24;
320 <span id='Ext-supports-property-TransparentColor'> /**
321 </span> * @property TransparentColor True if the device supports transparent color
325 identity: 'TransparentColor',
326 fn: function(doc, div, view) {
327 view = doc.defaultView;
328 return !(view && view.getComputedStyle(div.lastChild, null).backgroundColor != 'transparent');
332 <span id='Ext-supports-property-ComputedStyle'> /**
333 </span> * @property ComputedStyle True if the browser supports document.defaultView.getComputedStyle()
337 identity: 'ComputedStyle',
338 fn: function(doc, div, view) {
339 view = doc.defaultView;
340 return view && view.getComputedStyle;
344 <span id='Ext-supports-property-SVG'> /**
345 </span> * @property SVG True if the device supports SVG
351 return !!doc.createElementNS && !!doc.createElementNS( "http:/" + "/www.w3.org/2000/svg", "svg").createSVGRect;
355 <span id='Ext-supports-property-Canvas'> /**
356 </span> * @property Canvas True if the device supports Canvas
362 return !!doc.createElement('canvas').getContext;
366 <span id='Ext-supports-property-VML'> /**
367 </span> * @property VML True if the device supports VML
373 var d = doc.createElement("div");
374 d.innerHTML = "<!--[if vml]><br><br><![endif]-->";
375 return (d.childNodes.length == 2);
379 <span id='Ext-supports-property-Float'> /**
380 </span> * @property Float True if the device supports CSS float
385 fn: function(doc, div) {
386 return !!div.lastChild.style.cssFloat;
390 <span id='Ext-supports-property-AudioTag'> /**
391 </span> * @property AudioTag True if the device supports the HTML5 audio tag
395 identity: 'AudioTag',
397 return !!doc.createElement('audio').canPlayType;
401 <span id='Ext-supports-property-History'> /**
402 </span> * @property History True if the device supports HTML5 history
408 return !!(window.history && history.pushState);
412 <span id='Ext-supports-property-CSS3DTransform'> /**
413 </span> * @property CSS3DTransform True if the device supports CSS3DTransform
417 identity: 'CSS3DTransform',
419 return (typeof WebKitCSSMatrix != 'undefined' && new WebKitCSSMatrix().hasOwnProperty('m41'));
423 <span id='Ext-supports-property-CSS3LinearGradient'> /**
424 </span> * @property CSS3LinearGradient True if the device supports CSS3 linear gradients
428 identity: 'CSS3LinearGradient',
429 fn: function(doc, div) {
430 var property = 'background-image:',
431 webkit = '-webkit-gradient(linear, left top, right bottom, from(black), to(white))',
432 w3c = 'linear-gradient(left top, black, white)',
434 options = [property + webkit, property + w3c, property + moz];
436 div.style.cssText = options.join(';');
438 return ("" + div.style.backgroundImage).indexOf('gradient') !== -1;
442 <span id='Ext-supports-property-CSS3BorderRadius'> /**
443 </span> * @property CSS3BorderRadius True if the device supports CSS3 border radius
447 identity: 'CSS3BorderRadius',
448 fn: function(doc, div) {
449 var domPrefixes = ['borderRadius', 'BorderRadius', 'MozBorderRadius', 'WebkitBorderRadius', 'OBorderRadius', 'KhtmlBorderRadius'],
452 for (i = 0; i < domPrefixes.length; i++) {
453 if (document.body.style[domPrefixes[i]] !== undefined) {
461 <span id='Ext-supports-property-GeoLocation'> /**
462 </span> * @property GeoLocation True if the device supports GeoLocation
466 identity: 'GeoLocation',
468 return (typeof navigator != 'undefined' && typeof navigator.geolocation != 'undefined') || (typeof google != 'undefined' && typeof google.gears != 'undefined');
471 <span id='Ext-supports-property-MouseEnterLeave'> /**
472 </span> * @property MouseEnterLeave True if the browser supports mouseenter and mouseleave events
476 identity: 'MouseEnterLeave',
477 fn: function(doc, div){
478 return ('onmouseenter' in div && 'onmouseleave' in div);
481 <span id='Ext-supports-property-MouseWheel'> /**
482 </span> * @property MouseWheel True if the browser supports the mousewheel event
486 identity: 'MouseWheel',
487 fn: function(doc, div) {
488 return ('onmousewheel' in div);
491 <span id='Ext-supports-property-Opacity'> /**
492 </span> * @property Opacity True if the browser supports normal css opacity
497 fn: function(doc, div){
498 // Not a strict equal comparison in case opacity can be converted to a number.
499 if (Ext.isIE6 || Ext.isIE7 || Ext.isIE8) {
502 div.firstChild.style.cssText = 'opacity:0.73';
503 return div.firstChild.style.opacity == '0.73';
506 <span id='Ext-supports-property-Placeholder'> /**
507 </span> * @property Placeholder True if the browser supports the HTML5 placeholder attribute on inputs
511 identity: 'Placeholder',
513 return 'placeholder' in doc.createElement('input');
517 <span id='Ext-supports-property-Direct2DBug'> /**
518 </span> * @property Direct2DBug True if when asking for an element's dimension via offsetWidth or offsetHeight,
519 * getBoundingClientRect, etc. the browser returns the subpixel width rounded to the nearest pixel.
523 identity: 'Direct2DBug',
525 return Ext.isString(document.body.style.msTransformOrigin);
528 <span id='Ext-supports-property-BoundingClientRect'> /**
529 </span> * @property BoundingClientRect True if the browser supports the getBoundingClientRect method on elements
533 identity: 'BoundingClientRect',
534 fn: function(doc, div) {
535 return Ext.isFunction(div.getBoundingClientRect);
539 identity: 'IncludePaddingInWidthCalculation',
540 fn: function(doc, div){
541 var el = Ext.get(div.childNodes[1].firstChild);
542 return el.getWidth() == 210;
546 identity: 'IncludePaddingInHeightCalculation',
547 fn: function(doc, div){
548 var el = Ext.get(div.childNodes[1].firstChild);
549 return el.getHeight() == 210;
553 <span id='Ext-supports-property-ArraySort'> /**
554 </span> * @property ArraySort True if the Array sort native method isn't bugged.
558 identity: 'ArraySort',
560 var a = [1,2,3,4,5].sort(function(){ return 0; });
561 return a[0] === 1 && a[1] === 2 && a[2] === 3 && a[3] === 4 && a[4] === 5;
564 <span id='Ext-supports-property-Range'> /**
565 </span> * @property Range True if browser support document.createRange native method.
571 return !!document.createRange;
574 <span id='Ext-supports-property-CreateContextualFragment'> /**
575 </span> * @property CreateContextualFragment True if browser support CreateContextualFragment range native methods.
579 identity: 'CreateContextualFragment',
581 var range = Ext.supports.Range ? document.createRange() : false;
583 return range && !!range.createContextualFragment;
587 <span id='Ext-supports-property-WindowOnError'> /**
588 </span> * @property WindowOnError True if browser supports window.onerror.
592 identity: 'WindowOnError',
594 // sadly, we cannot feature detect this...
595 return Ext.isIE || Ext.isGecko || Ext.webKitVersion >= 534.16; // Chrome 10+