Bug 589147 - Update the self module doc and reading-data example for 0.7 and panels. r=myk, a0.7=myk
authorDrew Willcoxon <adw@mozilla.com>
Fri, 20 Aug 2010 23:12:07 -0700
changeset 755 494344c7ce7cbfbf9cd798bb337ecf92c9c550c4
parent 754 3851d63dda7b3c41da0a2a8f368984a79b0cde75
child 756 a58f594784a52cac679861232343585466d28319
push id281
push userdwillcoxon@mozilla.com
push dateSat, 21 Aug 2010 06:13:32 +0000
reviewersmyk
bugs589147
Bug 589147 - Update the self module doc and reading-data example for 0.7 and panels. r=myk, a0.7=myk
examples/reading-data/lib/main.js
packages/jetpack-core/docs/self.md
--- a/examples/reading-data/lib/main.js
+++ b/examples/reading-data/lib/main.js
@@ -1,24 +1,35 @@
 var self = require("self");
+var panels = require("panel");
+var widgets = require("widget");
 
 function replace_mom(html) {
     return html.replace("World", "Mom");
 }
 exports.replace_mom = replace_mom;
 
 exports.main = function(options, callbacks) {
     console.log("My ID is " + self.id);
 
+    // Load the sample HTML into a string.
     var hello_html = self.data.load("sample.html");
-    // we could now modify this sample data and then display it in a Panel or
-    // other UI element. Note that the 0.7 SDK release does not have Panel
-    // yet.. sorry! Watch JEP103 for changes.
+
+    // Let's now modify it...
     hello_html = replace_mom(hello_html);
-    //let p = new Panel(content: hello_html).show();
+
+    // ... and then create a panel that displays it.
+    var my_panel = panels.Panel({
+        contentURL: "data:text/html," + hello_html
+    });
 
-    // or we can pass a URL directly
+    // Load the URL of the sample image.
     var icon_url = self.data.url("mom.png");
-    hello_html.replace("Mom", '<img source="'+icon_url+'">');
-    //let p = new Panel(content: hello_html).show();
 
-    callbacks.quit();
+    // Create a widget that displays the image.  We'll attach the panel to it.
+    // When you click the widget, the panel will pop up.
+    var my_widget = widgets.Widget({
+        label: "Mom",
+        image: icon_url,
+        panel: my_panel
+    });
+    widgets.add(my_widget);
 }
--- a/packages/jetpack-core/docs/self.md
+++ b/packages/jetpack-core/docs/self.md
@@ -33,27 +33,28 @@ as a string. It is most useful for data 
 some way, such as JSON, XML, plain text, or perhaps an HTML template. For
 data that can be displayed directly in a content frame, use `data.url(NAME)`.
 @param name {string} The filename to be read, relative to the 
   package's `data` directory. Each package that uses the `self` module
   will see its own `data` directory.
 @returns {string}
 </api>
 
-<span class="aside">
-The 0.7 SDK release does not have the Panel API yet. Watch 
-[JEP 103](https://wiki.mozilla.org/Labs/Jetpack/Reboot/JEP/103) for updates.
-</span>
-
 <api name="data.url">
 @method
 The `data.url(NAME)` method returns a URL instance that points at an embedded
 data file. It is most useful for data that can be displayed directly in a
 content frame. The URL instance can be passed to a content frame constructor,
 such as the Panel:
 
-    let p = Panel({frame: {content: self.data.url("status.html")}});
-    p.show()
+    var self = require("self");
+    var panels = require("panel");
+    var myPanel = panels.Panel({
+      contentURL: self.data.url("my-panel-content.html")
+    });
+    panels.add(myPanel);
+    myPanel.show();
+
 @param name {string} The filename to be read, relative to the 
   package's `data` directory. Each package that uses the `self` module
   will see its own `data` directory.
 @returns {URL}
 </api>