|
前面讲了1.4.5 SDK的各个部分所在位置。后面我觉得将挺实在的,作者推荐仔细阅读一些源码,这样有助于提高对Mojo框架的理解,作者更推荐在webOS范围内随意使用源码,当然,要遵循SDK license的。
8 h* O; [! Z7 O j
s, B$ r \# q+ v7 ^) TYou may not realize it, but if you have the webOS SDK installed on your system, you’ve got the source for the Mojo framework there right on your machine available for reading. On Windows, we install it in the “share/refcode/webos-framework” folder under the location where the SDK lives (usually c:\Program Files\Palm\SDK), next to the code samples and webOS application source. On Mac, it’s in /opt/PalmSDK/share/refcode/framework.
! W# @/ z$ h! l# m! ?. J0 y
3 s4 {/ n7 f, J+ {% i( mIn this folder, you’ll first find another folder with a number. In the 1.4.5 SDK, that’s 337, and it matches an internal “submission” number we use to control what version of the framework ships on the device. In that folder, most of the actual source code is in the “javascripts” folder, but the version of Prototype we use is in the “builtins” folder. The “templates” folder holds HTML template files used in building the widgets in the system, “stylesheets” holds the CSS files used by the system, and “resources” and “formats” have JSON that’s used to handle our various locales.
0 a$ u4 E* w! u |* K* A" A d* ~! C+ @0 S- D5 p
Reading the framework source can be a bit daunting, but it’s been invaluable for me in understanding how Mojo works. It also can be a great place to look to see how parameters that you pass into calls are actually used and how the various JavaScript objects are put together. Some of the classes, like Mojo.Controller.SceneController, have some useful properties (e.g. sceneName, stageController and window) that are used in our sample code but are currently missing from our documentation — we’re working on filling these gaps now. (However, don’t rely on any properties or methods that start with an underscore, as that’s a signal that the data is for internal-use-only.) There are some useful comments, but as with a lot of code, the comments sometimes have aged more than the code they describe, so reading the code is essential for knowing things like when you can omit an argument.! `# r0 y, @% z% h5 _
4 ]1 D- R# n$ y" M* w( `So, I encourage you to dive in and explore the framework source, along with the source for many of our Palm apps, which you’ll also find installed with the SDK. A quick note on licensing: use of the framework and app source code is governed by the terms of the SDK license agreement, which is permissive but not open-source. You’re free to explore the code, learn from it, and even reuse it, as long as you’re working on webOS applications—the license currently does not allow use outside of webOS. |
|