Mac OS X Dashboard 开发全解析
1. Dashboard 特定的 JavaScript 代码
完成视觉更改后,需要确保小部件在 Dashboard 上能正确运行。由于苹果的要求,可能需要比其他平台更多的 JavaScript 代码。以下是月相小部件的 JavaScript 代码示例:
// Ensure that the moonPhase namespace exists
var moonPhase = window.moonPhase || {};
// Override the default load method
moonPhase.defaultLoad = moonPhase.load;
moonPhase.load = function () {
// Set the widget's visual style to match the preferred size
if (moonPhase.prefs.size.get() === 'small') {
document.body.style.width = '160px';
document.body.style.backgroundImage = 'url(Default_small.png)';
moonPhase.elements.config.style.height = '125px';
moonPhase.elements.main.style.height = '132px';
moonPhase.elements.moon.style.marginTop = '12px';
超级会员免费看
订阅专栏 解锁全文
15

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



