Mercurial > hg > FirefoxAddon
annotate 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 |
rev | line source |
---|---|
0
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
1 var ${package} = { |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
2 onLoad: function() { |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
3 // initialization code |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
4 this.initialized = true; |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
5 this.strings = document.getElementById("${package}-strings"); |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
6 document.getElementById("contentAreaContextMenu") |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
7 .addEventListener("popupshowing", function(e) { this.showContextMenu(e); }, false); |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
8 }, |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
9 |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
10 showContextMenu: function(event) { |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
11 // show or hide the menuitem based on what the context menu is on |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
12 // see http://kb.mozillazine.org/Adding_items_to_menus |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
13 document.getElementById("context-${package}").hidden = gContextMenu.onImage; |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
14 }, |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
15 onMenuItemCommand: function(e) { |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
16 var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
17 .getService(Components.interfaces.nsIPromptService); |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
18 promptService.alert(window, this.strings.getString("helloMessageTitle"), |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
19 this.strings.getString("helloMessage")); |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
20 }, |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
21 onToolbarButtonCommand: function(e) { |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
22 // just reuse the function above. you can change this, obviously! |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
23 ${package}.onMenuItemCommand(e); |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
24 } |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
25 |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
26 }; |
9869cf47fcf8
initial commit of Firefox addon template
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
27 window.addEventListener("load", function(e) { ${package}.onLoad(e); }, false); |