]>
git.proxmox.com Git - sencha-touch.git/blob - src/examples/states/.sencha/app/microloader/testing.js
2 * Sencha Blink - Testing
3 * @author Jacky Nguyen <jacky@sencha.com>
6 var head
= global
.document
.head
|| global
.document
.getElementsByTagName('head')[0],
9 if (typeof Ext
== 'undefined') {
10 global
.Ext
= Ext
= {};
13 function write(content
) {
14 document
.write(content
);
17 function addMeta(name
, content
) {
18 var meta
= document
.createElement('meta');
20 meta
.setAttribute('name', name
);
21 meta
.setAttribute('content', content
);
22 head
.appendChild(meta
);
25 Ext
.blink = function(options
) {
26 var scripts
= options
.js
|| [],
27 styleSheets
= options
.css
|| [],
28 i
, ln
, path
, platform
, theme
, exclude
;
30 if (navigator
.userAgent
.match(/IEMobile\/10\.0/)) {
31 var msViewportStyle
= document
.createElement("style");
32 msViewportStyle
.appendChild(
33 document
.createTextNode(
34 "@media screen and (orientation: portrait) {" +
35 "@-ms-viewport {width: 320px !important;}" +
37 "@media screen and (orientation: landscape) {" +
38 "@-ms-viewport {width: 560px !important;}" +
42 document
.getElementsByTagName("head")[0].appendChild(msViewportStyle
);
44 addMeta('viewport', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no');
45 addMeta('apple-mobile-web-app-capable', 'yes');
46 addMeta('apple-touch-fullscreen', 'yes');
48 Ext
.microloaded
= true;
50 var filterPlatform
= window
.Ext
.filterPlatform = function(platform
) {
51 var profileMatch
= false,
52 ua
= navigator
.userAgent
,
55 platform
= [].concat(platform
);
57 function isPhone(ua
) {
58 var isMobile
= /Mobile(\/|\s)/.test(ua
);
63 // - Android with "Mobile" in the UA
65 return /(iPhone|iPod)/.test(ua
) ||
66 (!/(Silk)/.test(ua
) && (/(Android)/.test(ua
) && (/(Android 2)/.test(ua
) || isMobile
))) ||
67 (/(BlackBerry|BB)/.test(ua
) && isMobile
) ||
68 /(Windows Phone)/.test(ua
);
71 function isTablet(ua
) {
72 return !isPhone(ua
) && (/iPad/.test(ua
) || /Android|Silk/.test(ua
) || /(RIM Tablet OS)/.test(ua
) ||
73 (/MSIE 10/.test(ua
) && /; Touch/.test(ua
)));
76 // Check if the ?platform parameter is set in the URL
77 var paramsString
= window
.location
.search
.substr(1),
78 paramsArray
= paramsString
.split("&"),
82 for (i
= 0; i
< paramsArray
.length
; i
++) {
83 var tmpArray
= paramsArray
[i
].split("=");
84 params
[tmpArray
[0]] = tmpArray
[1];
87 testPlatform
= params
.platform
;
89 return platform
.indexOf(testPlatform
) != -1;
92 for (j
= 0, jln
= platform
.length
; j
< jln
; j
++) {
93 switch (platform
[j
]) {
95 profileMatch
= isPhone(ua
);
98 profileMatch
= isTablet(ua
);
101 profileMatch
= !isPhone(ua
) && !isTablet(ua
);
104 profileMatch
= /(iPad|iPhone|iPod)/.test(ua
);
107 profileMatch
= /(Android|Silk)/.test(ua
);
110 profileMatch
= /(BlackBerry|BB)/.test(ua
);
113 profileMatch
= /Safari/.test(ua
) && !(/(BlackBerry|BB)/.test(ua
));
116 profileMatch
= /Chrome/.test(ua
);
119 profileMatch
= /MSIE 10/.test(ua
);
122 profileMatch
= /MSIE 10/.test(ua
) || /Trident/.test(ua
);
125 profileMatch
= /Tizen/.test(ua
);
128 profileMatch
= /Firefox/.test(ua
);
137 for (i
= 0,ln
= styleSheets
.length
; i
< ln
; i
++) {
138 path
= styleSheets
[i
];
140 if (typeof path
!= 'string') {
141 platform
= path
.platform
;
142 exclude
= path
.exclude
;
148 if (!filterPlatform(platform
) || filterPlatform(exclude
)) {
154 if(!Ext
.theme
.name
) {
155 Ext
.theme
.name
= theme
|| 'Default';
158 write('<link rel="stylesheet" href="'+path
+'">');
161 for (i
= 0,ln
= scripts
.length
; i
< ln
; i
++) {
164 if (typeof path
!= 'string') {
165 platform
= path
.platform
;
166 exclude
= path
.exclude
;
171 if (!filterPlatform(platform
) || filterPlatform(exclude
)) {
176 write('<script src="'+path
+'"></'+'script>');