Windows Mobile Widget开发全解析
1. crossPlatform层的改进
在开发Windows Mobile应用时,需要对crossPlatform中间件层进行一些小改动。由于Windows Mobile遵循与Opera和Mac OS X相同的核心小部件规范,所以增量变化相当小。
首先,需要检测平台:
if (!!window.widget) {
if (!!widget.getAttention) {
crossPlatform.api = 'opera';
crossPlatform.emptyPref = '';
} else if (!!widget.menu) {
crossPlatform.api = 'windows_mobile';
crossPlatform.emptyPref = null;
} else {
crossPlatform.api = 'mac';
crossPlatform.emptyPref = undefined;
}
}
此平台和Mac、Opera一样依赖widget命名空间,通过检测widget.menu对象来区分它与这两者。有趣的是,这三个平台对于未定义的偏好设置返回不同的值,这些值存储在 emptyPref 变量中。
检测到平台后,还需对偏好获取和设置代码进行更改。由于底层API非常相似,可以扩展Mac/Opera的情况:
超级会员免费看
订阅专栏 解锁全文
1447

被折叠的 条评论
为什么被折叠?



