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]);
22 * @property Desktop True if the browser is running on a desktop machine
25 this.Desktop = this.Mac || this.Windows || (this.Linux && !this.Android);
27 * @property Tablet True if the browser is running on a tablet (iPad)
29 this.Tablet = this.iPad;
31 * @property Phone True if the browser is running on a phone.
34 this.Phone = !this.Desktop && !this.Tablet;
36 * @property iOS True if the browser is running on iOS
39 this.iOS = this.iPhone || this.iPad || this.iPod;
42 * @property Standalone Detects when application has been saved to homescreen.
45 this.Standalone = !!window.navigator.standalone;
49 * @property iPhone True when the browser is running on a iPhone
59 * @property iPod True when the browser is running on a iPod
69 * @property iPad True when the browser is running on a iPad
73 property: 'userAgent',
79 * @property Blackberry True when the browser is running on a Blackberry
83 property: 'userAgent',
85 identity: 'Blackberry'
89 * @property Android True when the browser is running on an Android device
93 property: 'userAgent',
99 * @property Mac True when the browser is running on a Mac
103 property: 'platform',
109 * @property Windows True when the browser is running on Windows
113 property: 'platform',
119 * @property Linux True when the browser is running on Linux
123 property: 'platform',
132 * @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);
167 * @property CSS3BoxShadow True if document environment supports the CSS3 box-shadow style.
170 CSS3BoxShadow: Ext.isDefined(document.documentElement.style.boxShadow),
173 * @property ClassList True if document environment supports the HTML5 classList API.
176 ClassList: !!document.documentElement.classList,
179 * @property OrientationChange True if the device supports orientation change
182 OrientationChange: ((typeof window.orientation != 'undefined') && ('onorientationchange' in window)),
185 * @property DeviceMotion True if the device supports device motion (acceleration and rotation rate)
188 DeviceMotion: ('ondevicemotion' in window),
191 * @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),
200 * @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];
238 * @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');
251 * @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');
263 * @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;
275 * @property SVG True if the device supports SVG
281 return !!doc.createElementNS && !!doc.createElementNS( "http:/" + "/www.w3.org/2000/svg", "svg").createSVGRect;
286 * @property Canvas True if the device supports Canvas
292 return !!doc.createElement('canvas').getContext;
297 * @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);
310 * @property Float True if the device supports CSS float
315 fn: function(doc, div) {
316 return !!div.lastChild.style.cssFloat;
321 * @property AudioTag True if the device supports the HTML5 audio tag
325 identity: 'AudioTag',
327 return !!doc.createElement('audio').canPlayType;
332 * @property History True if the device supports HTML5 history
338 return !!(window.history && history.pushState);
343 * @property CSS3DTransform True if the device supports CSS3DTransform
347 identity: 'CSS3DTransform',
349 return (typeof WebKitCSSMatrix != 'undefined' && new WebKitCSSMatrix().hasOwnProperty('m41'));
354 * @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;
373 * @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) {
392 * @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');
402 * @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);
412 * @property MouseWheel True if the browser supports the mousewheel event
416 identity: 'MouseWheel',
417 fn: function(doc, div) {
418 return ('onmousewheel' in div);
422 * @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';
437 * @property Placeholder True if the browser supports the HTML5 placeholder attribute on inputs
441 identity: 'Placeholder',
443 return 'placeholder' in doc.createElement('input');
448 * @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);
459 * @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;
484 * @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;
495 * @property Range True if browser support document.createRange native method.
501 return !!document.createRange;
505 * @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;