view 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 source

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);