diff firefoxaddon/template/content/overlay.js_tmpl @ 0:9869cf47fcf8 default tip

initial commit of Firefox addon template
author k0s <k0scist@gmail.com>
date Sun, 28 Mar 2010 16:25:58 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/firefoxaddon/template/content/overlay.js_tmpl	Sun Mar 28 16:25:58 2010 -0400
@@ -0,0 +1,27 @@
+var ${package} = {
+  onLoad: function() {
+    // initialization code
+    this.initialized = true;
+    this.strings = document.getElementById("${package}-strings");
+    document.getElementById("contentAreaContextMenu")
+            .addEventListener("popupshowing", function(e) { this.showContextMenu(e); }, false);
+  },
+
+  showContextMenu: function(event) {
+    // show or hide the menuitem based on what the context menu is on
+    // see http://kb.mozillazine.org/Adding_items_to_menus
+    document.getElementById("context-${package}").hidden = gContextMenu.onImage;
+  },
+  onMenuItemCommand: function(e) {
+    var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+                                  .getService(Components.interfaces.nsIPromptService);
+    promptService.alert(window, this.strings.getString("helloMessageTitle"),
+                                this.strings.getString("helloMessage"));
+  },
+  onToolbarButtonCommand: function(e) {
+    // just reuse the function above.  you can change this, obviously!
+    ${package}.onMenuItemCommand(e);
+  }
+
+};
+window.addEventListener("load", function(e) { ${package}.onLoad(e); }, false);