]>
git.proxmox.com Git - sencha-touch.git/blob - src/examples/toolbars/.sencha/app/microloader/development.js
2 * Sencha Blink - Development
3 * @author Jacky Nguyen <jacky@sencha.com>
6 var head
= document
.head
|| document
.getElementsByTagName('head')[0];
8 function write(content
) {
9 document
.write(content
);
12 function addMeta(name
, content
) {
13 var meta
= document
.createElement('meta');
15 meta
.setAttribute('name', name
);
16 meta
.setAttribute('content', content
);
17 head
.appendChild(meta
);
20 var xhr
= new XMLHttpRequest();
21 xhr
.open('GET', 'bootstrap.json', false);
24 var options
= eval("(" + xhr
.responseText
+ ")"),
25 scripts
= options
.js
|| [],
26 styleSheets
= options
.css
|| [],
27 i
, ln
, path
, platform
, theme
, exclude
;
29 if(options
.platform
&& options
.platforms
&& options
.platforms
[options
.platform
] && options
.platforms
[options
.platform
].js
) {
30 scripts
= options
.platforms
[options
.platform
].js
.concat(scripts
);
33 if (navigator
.userAgent
.match(/IEMobile\/10\.0/)) {
34 var msViewportStyle
= document
.createElement("style");
35 msViewportStyle
.appendChild(
36 document
.createTextNode(
37 "@media screen and (orientation: portrait) {" +
38 "@-ms-viewport {width: 320px !important;}" +
40 "@media screen and (orientation: landscape) {" +
41 "@-ms-viewport {width: 560px !important;}" +
45 document
.getElementsByTagName("head")[0].appendChild(msViewportStyle
);
48 addMeta('viewport', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no');
49 addMeta('apple-mobile-web-app-capable', 'yes');
50 addMeta('apple-touch-fullscreen', 'yes');
55 Ext
.microloaded
= true;
57 var filterPlatform
= window
.Ext
.filterPlatform = function(platform
) {
58 var profileMatch
= false,
59 ua
= navigator
.userAgent
,
62 platform
= [].concat(platform
);
64 function isPhone(ua
) {
65 var isMobile
= /Mobile(\/|\s)/.test(ua
);
70 // - Android with "Mobile" in the UA
72 return /(iPhone|iPod)/.test(ua
) ||
73 (!/(Silk)/.test(ua
) && (/(Android)/.test(ua
) && (/(Android 2)/.test(ua
) || isMobile
))) ||
74 (/(BlackBerry|BB)/.test(ua
) && isMobile
) ||
75 /(Windows Phone)/.test(ua
);
78 function isTablet(ua
) {
79 return !isPhone(ua
) && (/iPad/.test(ua
) || /Android|Silk/.test(ua
) || /(RIM Tablet OS)/.test(ua
) ||
80 (/MSIE 10/.test(ua
) && /; Touch/.test(ua
)));
83 // Check if the ?platform parameter is set in the URL
84 var paramsString
= window
.location
.search
.substr(1),
85 paramsArray
= paramsString
.split("&"),
89 for (i
= 0; i
< paramsArray
.length
; i
++) {
90 var tmpArray
= paramsArray
[i
].split("=");
91 params
[tmpArray
[0]] = tmpArray
[1];
94 testPlatform
= params
.platform
;
96 return platform
.indexOf(testPlatform
) != -1;
99 for (j
= 0, jln
= platform
.length
; j
< jln
; j
++) {
100 switch (platform
[j
]) {
102 profileMatch
= isPhone(ua
);
105 profileMatch
= isTablet(ua
);
108 profileMatch
= !isPhone(ua
) && !isTablet(ua
);
111 profileMatch
= /(iPad|iPhone|iPod)/.test(ua
);
114 profileMatch
= /(Android|Silk)/.test(ua
);
117 profileMatch
= /(BlackBerry|BB)/.test(ua
);
120 profileMatch
= /Safari/.test(ua
) && !(/(BlackBerry|BB)/.test(ua
));
123 profileMatch
= /Chrome/.test(ua
);
126 profileMatch
= /MSIE 10/.test(ua
);
129 profileMatch
= /MSIE 10/.test(ua
) || /Trident/.test(ua
);
132 profileMatch
= /Tizen/.test(ua
);
135 profileMatch
= /Firefox/.test(ua
);
145 for (i
= 0,ln
= styleSheets
.length
; i
< ln
; i
++) {
146 path
= styleSheets
[i
];
148 if (typeof path
!= 'string') {
149 platform
= path
.platform
;
150 exclude
= path
.exclude
;
156 if (!filterPlatform(platform
) || filterPlatform(exclude
)) {
163 if(!Ext
.theme
.name
) {
164 Ext
.theme
.name
= theme
|| 'Default';
168 write('<link rel="stylesheet" href="'+path
+'">');
171 for (i
= 0,ln
= scripts
.length
; i
< ln
; i
++) {
174 if (typeof path
!= 'string') {
175 platform
= path
.platform
;
176 exclude
= path
.exclude
;
181 if (!filterPlatform(platform
) || filterPlatform(exclude
)) {
186 write('<script src="'+path
+'"></'+'script>');