|
前面讲了1.4.5 SDK的各个部分所在位置。后面我觉得将挺实在的,作者推荐仔细阅读一些源码,这样有助于提高对Mojo框架的理解,作者更推荐在webOS范围内随意使用源码,当然,要遵循SDK license的。1 P d; g7 [, k6 F
( \ e( c" G" m9 xYou 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.- H- }' l7 T' H% G1 o& q8 g
+ e! m' h u* H6 C9 H
In 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.
( _, h2 Q" s5 y0 Y; K6 w9 _) T' A" g9 O5 K" D U
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.* y$ V6 C5 @7 O2 L
- x, H+ e/ A' `1 ]5 G, ~+ s' l. OSo, 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. |
|