aboutsummaryrefslogtreecommitdiff
path: root/chrome/content
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/content')
-rw-r--r--chrome/content/code/browserOverlay.xul.js24
-rw-r--r--chrome/content/code/redirectList.xul.js51
-rw-r--r--chrome/content/ui/browserOverlay.xul6
-rw-r--r--chrome/content/ui/redirectList.xul37
4 files changed, 64 insertions, 54 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);
diff --git a/chrome/content/ui/browserOverlay.xul b/chrome/content/ui/browserOverlay.xul
index f12d0ff..77bab92 100644
--- a/chrome/content/ui/browserOverlay.xul
+++ b/chrome/content/ui/browserOverlay.xul
@@ -23,12 +23,6 @@
</popup>
<statusbar id="status-bar">
<statusbarpanel id="redirector-status">
- <!-- Put back in later
- <menupopup id="redirector-status-popup" position="at_pointer">
- <menuitem label="&RedirectorManageRedirects.label;" accesskey="&RedirectorManageRedirects.accesskey;" oncommand="RedirectorOverlay.openSettings();" />
- <menuitem label="&RedirectorHelp.label;" accesskey="&RedirectorHelp.accesskey;" oncommand="Redirector.openHelp();" />
- </menupopup>
- -->
<image id="redirector-statusbar-img" src="chrome://redirector/content/images/statusactive.PNG"
tooltiptext="Redirector is enabled;"
style="width:16px; height:16px;"
diff --git a/chrome/content/ui/redirectList.xul b/chrome/content/ui/redirectList.xul
index 3d5cdc2..02b1b72 100644
--- a/chrome/content/ui/redirectList.xul
+++ b/chrome/content/ui/redirectList.xul
@@ -10,6 +10,7 @@
buttons="accept"
width="650px"
height="500px"
+ id="redirectorSettings"
windowtype="redirectorSettings"
xmlns:nc="http://home.netscape.com/NC-rdf#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
@@ -21,15 +22,15 @@
</stringbundleset>
<tabbox flex="1" >
<tabs>
- <tab label="Redirects" />
- <tab label="Preferences" />
- <tab label="Import / Export" />
- <tab label="Help" />
+ <tab label="&tabRedirects.label;" accesskey="&tabRedirects.accesskey;" />
+ <tab label="&tabPreferences.label;" accesskey="&tabPreferences.accesskey;" />
+ <tab label="&tabImportExport.label;" accesskey="&tabImportExport.accesskey;" />
+ <tab label="&tabHelp.label;" accesskey="&tabHelp.accesskey;" />
</tabs>
<tabpanels flex="1">
<tabpanel flex="1">
<vbox flex="1">
- <richlistbox seltype="single" id="lstRedirects" flex="1" ondblclick="RedirectList.editRedirect();" onselect="RedirectList.selectionChange();">
+ <richlistbox seltype="single" id="lstRedirects" flex="1" ondblclick="RedirectList.editRedirect();" onselect="RedirectList.selectionChange();" onkeydown="RedirectList.redirectListKeyDown(event);">
<richlistitem class="redirectListItem" selected="false">
<grid>
<cols />
@@ -55,35 +56,35 @@
</richlistitem>
</richlistbox>
<hbox>
- <button id="btnAdd" onclick="RedirectList.addRedirect();" label="&btnAdd.label;" disabled="false" />
- <button id="btnEdit" onclick="RedirectList.editRedirect();" label="&btnEdit.label;" disabled="true" />
- <button id="btnDelete" onclick="RedirectList.deleteRedirect();" label="&btnDelete.label;" disabled="true" />
- <button id="btnUp" onclick="RedirectList.moveUp();" label="UP" disabled="false" />
- <button id="btnDown" onclick="RedirectList.moveDown();" label="Down" />
+ <button id="btnAdd" onclick="RedirectList.addRedirect();" accesskey="&btnAdd.accesskey;" onkeypress="RedirectList.buttonKeyPress(event);" label="&btnAdd.label;" tooltiptext="&btnAdd.tooltip;" disabled="false" />
+ <button id="btnEdit" onclick="RedirectList.editRedirect();" accesskey="&btnEdit.accesskey;" onkeypress="RedirectList.buttonKeyPress(event);" label="&btnEdit.label;" tooltiptext="&btnEdit.tooltip;" disabled="true" />
+ <button id="btnDelete" onclick="RedirectList.deleteRedirect();" accesskey="&btnDelete.accesskey;" onkeypress="RedirectList.buttonKeyPress(event);" label="&btnDelete.label;" tooltiptext="&btnDelete.tooltip;" disabled="true" />
+ <button id="btnUp" onclick="RedirectList.moveUp();" onkeypress="RedirectList.buttonKeyPress(event);" label="&btnUp.label;" tooltiptext="&btnUp.tooltip;" disabled="false" />
+ <button id="btnDown" onclick="RedirectList.moveDown();" onkeypress="RedirectList.buttonKeyPress(event);" tooltiptext="&btnDown.tooltip;" label="&btnDown.label;" />
</hbox>
</vbox>
</tabpanel>
<tabpanel>
<vbox flex="1">
<groupbox>
- <caption label="General" />
+ <caption label="&grpGeneralPreferences.label;" />
<hbox>
- <checkbox label="Enable Redirector" />
+ <checkbox label="&chkEnableRedirector.label;" accesskey="&chkEnableRedirector.accesskey;" />
<spacer flex="1" />
</hbox>
<hbox>
- <checkbox label="Show status bar icon" />
+ <checkbox label="&chkShowStatusBarIcon.label;" accesskey="&chkShowStatusBarIcon.accesskey;" />
<spacer flex="1" />
</hbox>
<hbox>
- <checkbox label="Show context menu" />
+ <checkbox label="&chkShowContextMenu.label;" accesskey="&chkShowContextMenu.accesskey;" />
<spacer flex="1" />
</hbox>
</groupbox>
<groupbox>
- <caption label="Debugging" />
+ <caption label="&grpDebuggingPreferences.label;" />
<hbox>
- <checkbox label="Enable debug output" />
+ <checkbox label="&chkEnableDebugOutput.label;" accesskey="&chkEnableDebugOutput.accesskey;" />
<spacer flex="1" />
</hbox>
</groupbox>
@@ -92,8 +93,8 @@
</tabpanel>
<tabpanel>
<vbox>
- <button id="btnImport" onclick="RedirectList.import();" label="&btnImport.label;"/>
- <button id="btnExport" onclick="RedirectList.export();" label="&btnExport.label;"/>
+ <button id="btnImport" accesskey="&btnImport.accesskey;" onclick="RedirectList.import();" label="&btnImport.label;"/>
+ <button id="btnExport" accesskey="&btnExport.accesskey;" onclick="RedirectList.export();" label="&btnExport.label;"/>
<spacer flex="1" />
</vbox>
</tabpanel>