aboutsummaryrefslogtreecommitdiff
path: root/chrome/js/browserOverlay.js
diff options
context:
space:
mode:
authorEinar Egilsson2011-09-04 22:53:16 +0200
committerEinar Egilsson2011-09-04 22:53:16 +0200
commit4b612baf4f29178214edec130856d83a40bf473d (patch)
tree20e36e3fcf7a24e829640c2fd605622f14af0edc /chrome/js/browserOverlay.js
parent8fb65cf8aeaaf66636698310c0168929fc1a2ce0 (diff)
Total restructuring of files and deletion of old files
Diffstat (limited to 'chrome/js/browserOverlay.js')
-rw-r--r--chrome/js/browserOverlay.js95
1 files changed, 95 insertions, 0 deletions
diff --git a/chrome/js/browserOverlay.js b/chrome/js/browserOverlay.js
new file mode 100644
index 0000000..ed1ab73
--- /dev/null
+++ b/chrome/js/browserOverlay.js
@@ -0,0 +1,95 @@
+Components.utils.import("chrome://redirector/content/js/redirectorprefs.js");
+Components.utils.import("chrome://redirector/content/js/redirector.js");
+
+var RedirectorOverlay = {
+
+ strings : null,
+ prefs : null,
+
+ onLoad : function(event) {
+ try {
+
+ // initialization code
+ document.getElementById('contentAreaContextMenu')
+ .addEventListener("popupshowing", function(e) { RedirectorOverlay.showContextMenu(e); }, false);
+
+ this.strings = document.getElementById("redirector-strings");
+ this.prefs = new RedirectorPrefs();
+ this.changedPrefs(this.prefs);
+ this.prefs.addListener(this);
+ document.addEventListener('keypress', function(event) {
+ if ((event.charCode == 114) && event.altKey) { //alt+r
+ RedirectorOverlay.toggleEnabled();
+ }
+ }, true);
+ } catch(e) {
+ if (this.strings) {
+ alert(this.strings.getString("initError") + "\n\n" + e);
+ } else {
+ alert(e);
+ }
+ }
+ },
+
+ onUnload : function(event) {
+ this.prefs.dispose();
+ Redirector.debug("Finished cleanup");
+ },
+
+ changedPrefs : function(prefs) {
+ var statusImg = document.getElementById('redirector-statusbar-img');
+
+ if (prefs.enabled) {
+ statusImg.src = 'chrome://redirector/content/images/statusactive.png'
+ statusImg.setAttribute('tooltiptext', this.strings.getString('enabledTooltip'));
+ } else {
+ statusImg.src = 'chrome://redirector/content/images/statusinactive.png'
+ statusImg.setAttribute('tooltiptext', this.strings.getString('disabledTooltip'));
+ }
+
+ document.getElementById('redirector-status').hidden = !prefs.showStatusBarIcon;
+ document.getElementById('redirector-context').hidden = !prefs.showContextMenu;
+ },
+
+ showContextMenu : function(event) {
+ if (gContextMenu.onLink) {
+ document.getElementById("redirector-context").label = this.strings.getString('addLinkUrl');
+ } else {
+ document.getElementById("redirector-context").label = this.strings.getString('addCurrentUrl');
+ }
+ },
+
+ onContextMenuCommand: function(event) {
+ var redirect = new Redirect(window.content.location.href, window.content.location.href);
+ if (gContextMenu.onLink) {
+ redirect.redirectUrl = gContextMenu.link.toString();
+ }
+
+ gBrowser.selectedTab = gBrowser.addTab("chrome://redirector/content/redirector.html");
+ },
+
+ onMenuItemCommand: function(event) {
+ this.openSettings();
+ },
+
+ toggleEnabled : function(event) {
+ this.prefs.enabled = !this.prefs.enabled;
+ },
+
+ openSettings : function() {
+ gBrowser.selectedTab = gBrowser.addTab("chrome://redirector/content/redirector.html");
+ },
+
+ statusBarClick : function(event) {
+ var LEFT = 0, RIGHT = 2;
+
+ if (event.button == LEFT) {
+ RedirectorOverlay.toggleEnabled();
+ } else if (event.button == RIGHT) {
+ this.openSettings();
+ }
+ }
+
+};
+window.addEventListener("load", function(event) { RedirectorOverlay.onLoad(event); }, false);
+window.addEventListener("unload", function(event) { RedirectorOverlay.onUnload(event); }, false);