原文: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