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