]> git.proxmox.com Git - sencha-touch.git/blob - src/examples/list-search/.sencha/app/microloader/development.js
import Sencha Touch 2.4.2 source
[sencha-touch.git] / src / examples / list-search / .sencha / app / microloader / development.js
1 /**
2 * Sencha Blink - Development
3 * @author Jacky Nguyen <jacky@sencha.com>
4 */
5 (function() {
6 var head = document.head || document.getElementsByTagName('head')[0];
7
8 function write(content) {
9 document.write(content);
10 }
11
12 function addMeta(name, content) {
13 var meta = document.createElement('meta');
14
15 meta.setAttribute('name', name);
16 meta.setAttribute('content', content);
17 head.appendChild(meta);
18 }
19
20 var xhr = new XMLHttpRequest();
21 xhr.open('GET', 'bootstrap.json', false);
22 xhr.send(null);
23
24 var options = eval("(" + xhr.responseText + ")"),
25 scripts = options.js || [],
26 styleSheets = options.css || [],
27 i, ln, path, platform, theme, exclude;
28
29 if(options.platform && options.platforms && options.platforms[options.platform] && options.platforms[options.platform].js) {
30 scripts = options.platforms[options.platform].js.concat(scripts);
31 }
32
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;}" +
39 "}" +
40 "@media screen and (orientation: landscape) {" +
41 "@-ms-viewport {width: 560px !important;}" +
42 "}"
43 )
44 );
45 document.getElementsByTagName("head")[0].appendChild(msViewportStyle);
46 }
47
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');
51
52 if (!window.Ext) {
53 window.Ext = {};
54 }
55 Ext.microloaded = true;
56
57 var filterPlatform = window.Ext.filterPlatform = function(platform) {
58 var profileMatch = false,
59 ua = navigator.userAgent,
60 j, jln;
61
62 platform = [].concat(platform);
63
64 function isPhone(ua) {
65 var isMobile = /Mobile(\/|\s)/.test(ua);
66
67 // Either:
68 // - iOS but not iPad
69 // - Android 2
70 // - Android with "Mobile" in the UA
71
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);
76 }
77
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)));
81 }
82
83 // Check if the ?platform parameter is set in the URL
84 var paramsString = window.location.search.substr(1),
85 paramsArray = paramsString.split("&"),
86 params = {},
87 testPlatform, i;
88
89 for (i = 0; i < paramsArray.length; i++) {
90 var tmpArray = paramsArray[i].split("=");
91 params[tmpArray[0]] = tmpArray[1];
92 }
93
94 testPlatform = params.platform;
95 if (testPlatform) {
96 return platform.indexOf(testPlatform) != -1;
97 }
98
99 for (j = 0, jln = platform.length; j < jln; j++) {
100 switch (platform[j]) {
101 case 'phone':
102 profileMatch = isPhone(ua);
103 break;
104 case 'tablet':
105 profileMatch = isTablet(ua);
106 break;
107 case 'desktop':
108 profileMatch = !isPhone(ua) && !isTablet(ua);
109 break;
110 case 'ios':
111 profileMatch = /(iPad|iPhone|iPod)/.test(ua);
112 break;
113 case 'android':
114 profileMatch = /(Android|Silk)/.test(ua);
115 break;
116 case 'blackberry':
117 profileMatch = /(BlackBerry|BB)/.test(ua);
118 break;
119 case 'safari':
120 profileMatch = /Safari/.test(ua) && !(/(BlackBerry|BB)/.test(ua));
121 break;
122 case 'chrome':
123 profileMatch = /Chrome/.test(ua);
124 break;
125 case 'ie10':
126 profileMatch = /MSIE 10/.test(ua);
127 break;
128 case 'windows':
129 profileMatch = /MSIE 10/.test(ua) || /Trident/.test(ua);
130 break;
131 case 'tizen':
132 profileMatch = /Tizen/.test(ua);
133 break;
134 case 'firefox':
135 profileMatch = /Firefox/.test(ua);
136 }
137 if (profileMatch) {
138 return true;
139 }
140 }
141 return false;
142 };
143
144
145 for (i = 0,ln = styleSheets.length; i < ln; i++) {
146 path = styleSheets[i];
147
148 if (typeof path != 'string') {
149 platform = path.platform;
150 exclude = path.exclude;
151 theme = path.theme;
152 path = path.path;
153 }
154
155 if (platform) {
156 if (!filterPlatform(platform) || filterPlatform(exclude)) {
157 continue;
158 }
159
160 if(!Ext.theme) {
161 Ext.theme = {};
162 }
163 if(!Ext.theme.name) {
164 Ext.theme.name = theme || 'Default';
165 }
166 }
167
168 write('<link rel="stylesheet" href="'+path+'">');
169 }
170
171 for (i = 0,ln = scripts.length; i < ln; i++) {
172 path = scripts[i];
173
174 if (typeof path != 'string') {
175 platform = path.platform;
176 exclude = path.exclude;
177 path = path.path;
178 }
179
180 if (platform) {
181 if (!filterPlatform(platform) || filterPlatform(exclude)) {
182 continue;
183 }
184 }
185
186 write('<script src="'+path+'"></'+'script>');
187 }
188
189 })();