aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEinar Egilsson2009-10-08 11:41:58 +0000
committerEinar Egilsson2009-10-08 11:41:58 +0000
commit18628591d8bad26265a5a16055285b50e0184b11 (patch)
tree68f3f4df517155bc080be94fbc847929812d3d22
parentfa392246ec57c59614e02645aa0fe74a0bd71ac7 (diff)
Tooltips and accesskeys
git-svn-id: http://einaregilsson.googlecode.com/svn/mozilla/redirector/trunk@257 119bf307-c92d-0410-89bd-8f53e6181181
-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
-rw-r--r--chrome/locale/en-US/redirectList.xul.dtd56
-rw-r--r--chrome/skin/redirector.css5
6 files changed, 122 insertions, 57 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>
diff --git a/chrome/locale/en-US/redirectList.xul.dtd b/chrome/locale/en-US/redirectList.xul.dtd
index 8ad6279..e05b556 100644
--- a/chrome/locale/en-US/redirectList.xul.dtd
+++ b/chrome/locale/en-US/redirectList.xul.dtd
@@ -1,11 +1,65 @@
<!-- $Id$ -->
-<!ENTITY window.title "Redirector Settings">
+<!ENTITY window.title "Redirector">
+
+<!-- ListItems with redirects -->
<!ENTITY colIncludePattern.label "Include pattern">
<!ENTITY colExcludePattern.label "Exclude pattern">
<!ENTITY colRedirectTo.label "Redirect to">
<!ENTITY colEnabled.label "Enabled">
+
+<!-- Buttons -->
<!ENTITY btnAdd.label "Add...">
+<!ENTITY btnAdd.accesskey "A">
+<!ENTITY btnAdd.tooltip "Create a new redirect">
+
<!ENTITY btnEdit.label "Edit...">
+<!ENTITY btnEdit.accesskey "E">
+<!ENTITY btnEdit.tooltip "Edit the selected redirect">
+
<!ENTITY btnDelete.label "Delete">
+<!ENTITY btnDelete.accesskey "D">
+<!ENTITY btnDelete.tooltip "Delete the selected redirect">
+
+<!ENTITY btnUp.label "Up">
+<!ENTITY btnUp.tooltip "Move the selected redirect up">
+
+<!ENTITY btnDown.label "Down">
+<!ENTITY btnDown.tooltip "Move the selected redirect down">
+
<!ENTITY btnImport.label "Import...">
+<!ENTITY btnImport.accesskey "I">
+<!ENTITY btnImport.tooltip "Import redirects from a file">
+
<!ENTITY btnExport.label "Export...">
+<!ENTITY btnExport.accesskey "E">
+<!ENTITY btnExport.tooltip "Export redirects to a file">
+
+
+<!-- Tab headers -->
+<!ENTITY tabRedirects.label "Redirects">
+<!ENTITY tabRedirects.accesskey "R">
+<!ENTITY tabPreferences.label "Preferences">
+<!ENTITY tabPreferences.accesskey "P">
+<!ENTITY tabImportExport.label "Import/Export">
+<!ENTITY tabImportExport.accesskey "m">
+<!ENTITY tabHelp.label "Help">
+<!ENTITY tabHelp.accesskey "H">
+
+<!-- Preferences -->
+<!ENTITY grpGeneralPreferences.label "General">
+<!ENTITY grpDebuggingPreferences.label "Debugging">
+
+<!ENTITY chkEnableRedirector.label "Enable Redirector">
+<!ENTITY chkEnableRedirector.accesskey "E">
+
+<!ENTITY chkShowStatusBarIcon.label "Show status bar icon">
+<!ENTITY chkShowStatusBarIcon.accesskey "s">
+
+<!ENTITY chkShowContextMenu.label "Show context menu">
+<!ENTITY chkShowContextMenu.accesskey "c">
+
+<!ENTITY chkEnableDebugOutput.label "Enable debug output">
+<!ENTITY chkEnableDebugOutput.accesskey "d">
+
+
+
diff --git a/chrome/skin/redirector.css b/chrome/skin/redirector.css
index 2d1bf71..c39905b 100644
--- a/chrome/skin/redirector.css
+++ b/chrome/skin/redirector.css
@@ -1,6 +1,7 @@
/* $Id$ */
.disabledRedirect { color:grey; }
-.redirectListItem { border-bottom:dotted 1px grey; }
+#lstRedirects richlistitem { border-bottom:dotted 1px grey; padding:3px; }
.redirectRows > row > label { font-weight:bold;}
-.editRedirects > row > textbox { width: 350px; } \ No newline at end of file
+.editRedirects > row > textbox { width: 350px; }
+#redirectorSettings > tabbox { margin:4px; } \ No newline at end of file