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-is'>/**
2 </span> * @class Ext.is
4 * Determines information about the current platform the application is running on.
9 init : function(navigator) {
10 var platforms = this.platforms,
11 ln = platforms.length,
14 navigator = navigator || window.navigator;
16 for (i = 0; i < ln; i++) {
17 platform = platforms[i];
18 this[platform.identity] = platform.regex.test(navigator[platform.property]);
21 <span id='Ext-is-property-Desktop'> /**
22 </span> * @property Desktop True if the browser is running on a desktop machine
25 this.Desktop = this.Mac || this.Windows || (this.Linux && !this.Android);
26 <span id='Ext-is-property-Tablet'> /**
27 </span> * @property Tablet True if the browser is running on a tablet (iPad)
29 this.Tablet = this.iPad;
30 <span id='Ext-is-property-Phone'> /**
31 </span> * @property Phone True if the browser is running on a phone.
34 this.Phone = !this.Desktop && !this.Tablet;
35 <span id='Ext-is-property-iOS'> /**
36 </span> * @property iOS True if the browser is running on iOS
39 this.iOS = this.iPhone || this.iPad || this.iPod;
41 <span id='Ext-is-property-Standalone'> /**
42 </span> * @property Standalone Detects when application has been saved to homescreen.
45 this.Standalone = !!window.navigator.standalone;
48 <span id='Ext-is-property-iPhone'> /**
49 </span> * @property iPhone True when the browser is running on a iPhone
58 <span id='Ext-is-property-iPod'> /**
59 </span> * @property iPod True when the browser is running on a iPod
68 <span id='Ext-is-property-iPad'> /**
69 </span> * @property iPad True when the browser is running on a iPad
73 property: 'userAgent',
78 <span id='Ext-is-property-Blackberry'> /**
79 </span> * @property Blackberry True when the browser is running on a Blackberry
83 property: 'userAgent',
85 identity: 'Blackberry'
88 <span id='Ext-is-property-Android'> /**
89 </span> * @property Android True when the browser is running on an Android device
93 property: 'userAgent',
98 <span id='Ext-is-property-Mac'> /**
99 </span> * @property Mac True when the browser is running on a Mac
103 property: 'platform',
108 <span id='Ext-is-property-Windows'> /**
109 </span> * @property Windows True when the browser is running on Windows
113 property: 'platform',
118 <span id='Ext-is-property-Linux'> /**
119 </span> * @property Linux True when the browser is running on Linux
123 property: 'platform',
131 <span id='Ext-supports'>/**
132 </span> * @class Ext.supports
134 * Determines information about features are supported in the current environment
141 div = doc.createElement('div'),
147 '<div style="height:30px;width:50px;">',
148 '<div style="height:20px;width:20px;"></div>',
150 '<div style="width: 200px; height: 200px; position: relative; padding: 5px;">',
151 '<div style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></div>',
153 '<div style="float:left; background-color:transparent;"></div>'
156 doc.body.appendChild(div);
158 for (i = 0; i < ln; i++) {
160 this[test.identity] = test.fn.call(this, doc, div);
163 doc.body.removeChild(div);
166 <span id='Ext-supports-property-CSS3BoxShadow'> /**
167 </span> * @property CSS3BoxShadow True if document environment supports the CSS3 box-shadow style.
170 CSS3BoxShadow: Ext.isDefined(document.documentElement.style.boxShadow),
172 <span id='Ext-supports-property-ClassList'> /**
173 </span> * @property ClassList True if document environment supports the HTML5 classList API.
176 ClassList: !!document.documentElement.classList,
178 <span id='Ext-supports-property-OrientationChange'> /**
179 </span> * @property OrientationChange True if the device supports orientation change
182 OrientationChange: ((typeof window.orientation != 'undefined') && ('onorientationchange' in window)),
184 <span id='Ext-supports-property-DeviceMotion'> /**
185 </span> * @property DeviceMotion True if the device supports device motion (acceleration and rotation rate)
188 DeviceMotion: ('ondevicemotion' in window),
190 <span id='Ext-supports-property-Touch'> /**
191 </span> * @property Touch True if the device supports touch
194 // is.Desktop is needed due to the bug in Chrome 5.0.375, Safari 3.1.2
195 // and Safari 4.0 (they all have 'ontouchstart' in the window object).
196 Touch: ('ontouchstart' in window) && (!Ext.is.Desktop),
199 <span id='Ext-supports-property-Transitions'> /**
200 </span> * @property Transitions True if the device supports CSS3 Transitions
204 identity: 'Transitions',
205 fn: function(doc, div) {
213 TE = 'TransitionEnd',
214 transitionEndName = [
216 'transitionend', //Moz bucks the prefixing convention
225 for (; i < ln; i++) {
226 if (div.getStyle(prefix[i] + "TransitionProperty")) {
227 Ext.supports.CSS3Prefix = prefix[i];
228 Ext.supports.CSS3TransitionEnd = transitionEndName[i];
237 <span id='Ext-supports-property-RightMargin'> /**
238 </span> * @property RightMargin True if the device supports right margin.
239 * See https://bugs.webkit.org/show_bug.cgi?id=13343 for why this is needed.
243 identity: 'RightMargin',
244 fn: function(doc, div, view) {
245 view = doc.defaultView;
246 return !(view && view.getComputedStyle(div.firstChild.firstChild, null).marginRight != '0px');
250 <span id='Ext-supports-property-TransparentColor'> /**
251 </span> * @property TransparentColor True if the device supports transparent color
255 identity: 'TransparentColor',
256 fn: function(doc, div, view) {
257 view = doc.defaultView;
258 return !(view && view.getComputedStyle(div.lastChild, null).backgroundColor != 'transparent');
262 <span id='Ext-supports-property-ComputedStyle'> /**
263 </span> * @property ComputedStyle True if the browser supports document.defaultView.getComputedStyle()
267 identity: 'ComputedStyle',
268 fn: function(doc, div, view) {
269 view = doc.defaultView;
270 return view && view.getComputedStyle;
274 <span id='Ext-supports-property-SVG'> /**
275 </span> * @property SVG True if the device supports SVG
281 return !!doc.createElementNS && !!doc.createElementNS( "http:/" + "/www.w3.org/2000/svg", "svg").createSVGRect;
285 <span id='Ext-supports-property-Canvas'> /**
286 </span> * @property Canvas True if the device supports Canvas
292 return !!doc.createElement('canvas').getContext;
296 <span id='Ext-supports-property-VML'> /**
297 </span> * @property VML True if the device supports VML
303 var d = doc.createElement("div");
304 d.innerHTML = "<!--[if vml]><br><br><![endif]-->";
305 return (d.childNodes.length == 2);
309 <span id='Ext-supports-property-Float'> /**
310 </span> * @property Float True if the device supports CSS float
315 fn: function(doc, div) {
316 return !!div.lastChild.style.cssFloat;
320 <span id='Ext-supports-property-AudioTag'> /**
321 </span> * @property AudioTag True if the device supports the HTML5 audio tag
325 identity: 'AudioTag',
327 return !!doc.createElement('audio').canPlayType;
331 <span id='Ext-supports-property-History'> /**
332 </span> * @property History True if the device supports HTML5 history
338 return !!(window.history && history.pushState);
342 <span id='Ext-supports-property-CSS3DTransform'> /**
343 </span> * @property CSS3DTransform True if the device supports CSS3DTransform
347 identity: 'CSS3DTransform',
349 return (typeof WebKitCSSMatrix != 'undefined' && new WebKitCSSMatrix().hasOwnProperty('m41'));
353 <span id='Ext-supports-property-CSS3LinearGradient'> /**
354 </span> * @property CSS3LinearGradient True if the device supports CSS3 linear gradients
358 identity: 'CSS3LinearGradient',
359 fn: function(doc, div) {
360 var property = 'background-image:',
361 webkit = '-webkit-gradient(linear, left top, right bottom, from(black), to(white))',
362 w3c = 'linear-gradient(left top, black, white)',
364 options = [property + webkit, property + w3c, property + moz];
366 div.style.cssText = options.join(';');
368 return ("" + div.style.backgroundImage).indexOf('gradient') !== -1;
372 <span id='Ext-supports-property-CSS3BorderRadius'> /**
373 </span> * @property CSS3BorderRadius True if the device supports CSS3 border radius
377 identity: 'CSS3BorderRadius',
378 fn: function(doc, div) {
379 var domPrefixes = ['borderRadius', 'BorderRadius', 'MozBorderRadius', 'WebkitBorderRadius', 'OBorderRadius', 'KhtmlBorderRadius'],
382 for (i = 0; i < domPrefixes.length; i++) {
383 if (document.body.style[domPrefixes[i]] !== undefined) {
391 <span id='Ext-supports-property-GeoLocation'> /**
392 </span> * @property GeoLocation True if the device supports GeoLocation
396 identity: 'GeoLocation',
398 return (typeof navigator != 'undefined' && typeof navigator.geolocation != 'undefined') || (typeof google != 'undefined' && typeof google.gears != 'undefined');
401 <span id='Ext-supports-property-MouseEnterLeave'> /**
402 </span> * @property MouseEnterLeave True if the browser supports mouseenter and mouseleave events
406 identity: 'MouseEnterLeave',
407 fn: function(doc, div){
408 return ('onmouseenter' in div && 'onmouseleave' in div);
411 <span id='Ext-supports-property-MouseWheel'> /**
412 </span> * @property MouseWheel True if the browser supports the mousewheel event
416 identity: 'MouseWheel',
417 fn: function(doc, div) {
418 return ('onmousewheel' in div);
421 <span id='Ext-supports-property-Opacity'> /**
422 </span> * @property Opacity True if the browser supports normal css opacity
427 fn: function(doc, div){
428 // Not a strict equal comparison in case opacity can be converted to a number.
429 if (Ext.isIE6 || Ext.isIE7 || Ext.isIE8) {
432 div.firstChild.style.cssText = 'opacity:0.73';
433 return div.firstChild.style.opacity == '0.73';
436 <span id='Ext-supports-property-Placeholder'> /**
437 </span> * @property Placeholder True if the browser supports the HTML5 placeholder attribute on inputs
441 identity: 'Placeholder',
443 return 'placeholder' in doc.createElement('input');
447 <span id='Ext-supports-property-Direct2DBug'> /**
448 </span> * @property Direct2DBug True if when asking for an element's dimension via offsetWidth or offsetHeight,
449 * getBoundingClientRect, etc. the browser returns the subpixel width rounded to the nearest pixel.
453 identity: 'Direct2DBug',
455 return Ext.isString(document.body.style.msTransformOrigin);
458 <span id='Ext-supports-property-BoundingClientRect'> /**
459 </span> * @property BoundingClientRect True if the browser supports the getBoundingClientRect method on elements
463 identity: 'BoundingClientRect',
464 fn: function(doc, div) {
465 return Ext.isFunction(div.getBoundingClientRect);
469 identity: 'IncludePaddingInWidthCalculation',
470 fn: function(doc, div){
471 var el = Ext.get(div.childNodes[1].firstChild);
472 return el.getWidth() == 210;
476 identity: 'IncludePaddingInHeightCalculation',
477 fn: function(doc, div){
478 var el = Ext.get(div.childNodes[1].firstChild);
479 return el.getHeight() == 210;
483 <span id='Ext-supports-property-ArraySort'> /**
484 </span> * @property ArraySort True if the Array sort native method isn't bugged.
488 identity: 'ArraySort',
490 var a = [1,2,3,4,5].sort(function(){ return 0; });
491 return a[0] === 1 && a[1] === 2 && a[2] === 3 && a[3] === 4 && a[4] === 5;
494 <span id='Ext-supports-property-Range'> /**
495 </span> * @property Range True if browser support document.createRange native method.
501 return !!document.createRange;
504 <span id='Ext-supports-property-CreateContextualFragment'> /**
505 </span> * @property CreateContextualFragment True if browser support CreateContextualFragment range native methods.
509 identity: 'CreateContextualFragment',
511 var range = Ext.supports.Range ? document.createRange() : false;
513 return range && !!range.createContextualFragment;
519 </pre></pre></body></html>