原文:Sencha Ext JS 5: Supporting Different Themes for Different Devicesjavascript
Sencha Ext JS 5是第一個徹底支持iOS平板的Ext框架。css
爲應用程序添加平板支持,並能根據使用的設備自動切換桌面或基於觸碰的主題(CSS文件)多是至關重要的任務。html
本教程將演示如何將該功能添加到應用程序。java
"builds": {
"testAppDesktop": {
"theme": "TestApp-Desktop"
},
"testAppTouch": {
"theme": "TestApp-Tablet"
}
}
使用如下代碼替換app.json中的output配置:json
"output": {
"base": "${workspace.build.dir}/${build.environment}/${app.name}/${build.id}",
"page": "./index.html",
"manifest": "../${build.id}.json",
"deltas": {
"enable": false
},
"cache": {
"enable": false
}
}
返回命令行提示符,輸入如下命令:
sencha app refresh
這將生產manifest文件:testAppDesktop.json和testAppTouch.jsonbootstrap
使用如下代碼替換App.json中的css配置:瀏覽器
"css": [{
"path": "${build.out.css.dir}/TestApp-all.css",
"bootstrap": true
}]
"bootstrap": {
"manifest": "${build.id}.json"
}
var Ext = Ext || {};
Ext.beforeLoad = function(tags){
var theme = location.href.match(/theme=([\w-]+)/);
theme = (theme && theme[1]) || (tags.desktop ? 'testAppDesktop' : 'testAppTouch');
Ext.manifest = theme;
tags.test = /testMode=true/.test(location.search);
Ext.microloaderTags = tags;
};
返回命令行提示符並輸入如下命令:
sencha app build developmentmarkdown