diff options
Diffstat (limited to 'chrome/content/code')
-rw-r--r-- | chrome/content/code/browserOverlay.xul.js | 24 | ||||
-rw-r--r-- | chrome/content/code/redirectList.xul.js | 51 |
2 files changed, 45 insertions, 30 deletions
diff --git a/chrome/content/code/browserOverlay.xul.js b/chrome/content/code/browserOverlay.xul.js index 5c84859..129da48 100644 --- a/chrome/content/code/browserOverlay.xul.js +++ b/chrome/content/code/browserOverlay.xul.js @@ -4,30 +4,21 @@ var Redirector = Components.classes["@einaregilsson.com/redirector;1"].getServic var RedirectorOverlay = { - name : "Redirector", - initialized : false, strings : null, onLoad : function(event) { try { // initialization code - Redirector.debug("Initializing..."); document.getElementById('contentAreaContextMenu') .addEventListener("popupshowing", function(e) { RedirectorOverlay.showContextMenu(e); }, false); - if (!Redirector.getBoolPref('showContextMenu')) { - document.getElementById('redirector-context').hidden = true; - } - if (!Redirector.getBoolPref('showStatusBarIcon')) { - document.getElementById('redirector-status').hidden = true; - } + document.getElementById('redirector-status').hidden = !Redirector.getBoolPref('showStatusBarIcon'); + document.getElementById('redirector-context').hidden = !Redirector.getBoolPref('showContextMenu'); + this.strings = document.getElementById("redirector-strings"); this.prefObserver.register(); this.setStatusBarImg(); - - Redirector.debug("Finished initialization"); - this.initialized = true; } catch(e) { if (this.strings) { @@ -123,8 +114,15 @@ var RedirectorOverlay = { }, observe : function(subject, topic, data) { - if (topic == 'nsPref:changed' && data == 'extensions.redirector.enabled') { + if (topic != 'nsPref:changed') { + return; + } + if (data == 'extensions.redirector.enabled') { RedirectorOverlay.setStatusBarImg(); + } else if (data == 'extensions.redirector.showStatusBarIcon') { + document.getElementById('redirector-status').hidden = !Redirector.getBoolPref('showStatusBarIcon'); + } else if (data == 'extensions.redirector.showContextMenu') { + document.getElementById('redirector-context').hidden = !Redirector.getBoolPref('showContextMenu'); } } } diff --git a/chrome/content/code/redirectList.xul.js b/chrome/content/code/redirectList.xul.js index c980178..76b450f 100644 --- a/chrome/content/code/redirectList.xul.js +++ b/chrome/content/code/redirectList.xul.js @@ -12,6 +12,23 @@ var RedirectList = { btnUp : null,
btnDown : null,
+ onLoad : function() {
+ try {
+ this.lstRedirects = document.getElementById('lstRedirects');
+ this.lstRedirects.selType = 'single';
+ this.template = document.getElementsByTagName('richlistitem')[0];
+ this.lstRedirects.removeChild(this.template);
+ this.btnDelete = document.getElementById('btnDelete');
+ this.btnEdit = document.getElementById('btnEdit');
+ this.btnUp = document.getElementById('btnUp');
+ this.btnDown = document.getElementById('btnDown');
+ this.addItemsToListBox(Redirector.list);
+ this.strings = document.getElementById('redirector-strings');
+ } catch(e) {
+ alert(e);
+ }
+ },
+
addItemsToListBox : function(items) {
var item, row, value, newItem;
@@ -44,23 +61,6 @@ var RedirectList = { },false);
},
- onLoad : function() {
- try {
- this.lstRedirects = document.getElementById('lstRedirects');
- this.lstRedirects.selType = 'single';
- this.template = document.getElementsByTagName('richlistitem')[0];
- this.lstRedirects.removeChild(this.template);
- this.btnDelete = document.getElementById('btnDelete');
- this.btnEdit = document.getElementById('btnEdit');
- this.btnUp = document.getElementById('btnUp');
- this.btnDown = document.getElementById('btnDown');
- this.addItemsToListBox(Redirector.list);
- this.strings = document.getElementById('redirector-strings');
- } catch(e) {
- alert(e);
- }
- },
-
moveUp : function(){
if (this.lstRedirects.selectedIndex <= 0) {
return;
@@ -123,6 +123,12 @@ var RedirectList = { Redirector.save();
}
},
+
+ buttonKeyPress : function(event) {
+ if (event.keyCode == 13 && !event.originalTarget.disabled) {
+ event.originalTarget.click();
+ }
+ },
deleteRedirect : function() {
var index = this.lstRedirects.selectedIndex;
@@ -148,6 +154,9 @@ var RedirectList = { },
selectionChange : function() {
+ if (!this.lstRedirects) {
+ return;
+ }
var index = this.lstRedirects.selectedIndex;
this.btnEdit.disabled = (index == -1);
@@ -156,6 +165,14 @@ var RedirectList = { this.btnDown.disabled = (index == -1 || index >= Redirector.list.length-1);
},
+ redirectListKeyDown : function(event) {
+ if (event.keyCode == 46) { //Del key
+ this.deleteRedirect();
+ } else if (event.keyCode == 13) { //Enter key
+ this.editRedirect();
+ }
+ },
+
importExport : function(mode, captionKey, func) {
//Mostly borrowed from Adblock Plus
var picker = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
|