diff options
author | Einar Egilsson | 2009-10-07 12:54:34 +0000 |
---|---|---|
committer | Einar Egilsson | 2009-10-07 12:54:34 +0000 |
commit | 756a6c22bbed654423bb4976e95968cff4fee49d (patch) | |
tree | 77b370f482939d2bc5e87e958db778dba5ebbf17 /chrome | |
parent | eb5ee94ad622ac89b886cc74fcb8cd8328b1fbaf (diff) |
Prompt before delete, disable edit and delete buttons properly. Use checkboxes for setting enabled/disabled status of redirects.
git-svn-id: http://einaregilsson.googlecode.com/svn/mozilla/redirector/trunk@255 119bf307-c92d-0410-89bd-8f53e6181181
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/content/code/redirectList.xul.js | 49 | ||||
-rw-r--r-- | chrome/content/ui/editRedirect.xul | 5 | ||||
-rw-r--r-- | chrome/content/ui/redirectList.xul | 11 | ||||
-rw-r--r-- | chrome/locale/en-US/redirectList.xul.dtd | 1 | ||||
-rw-r--r-- | chrome/locale/en-US/redirector.properties | 4 |
5 files changed, 41 insertions, 29 deletions
diff --git a/chrome/content/code/redirectList.xul.js b/chrome/content/code/redirectList.xul.js index c7ebcd7..81dd4a4 100644 --- a/chrome/content/code/redirectList.xul.js +++ b/chrome/content/code/redirectList.xul.js @@ -9,7 +9,6 @@ var RedirectList = { lstRedirects: null,
btnDelete : null,
btnEdit : null,
- btnDisable : null,
addItemsToListBox : function(items) {
@@ -21,10 +20,24 @@ var RedirectList = { newItem.getElementsByAttribute('name', 'dscrIncludePattern')[0].setAttribute('value', item.includePattern);
newItem.getElementsByAttribute('name', 'dscrExcludePattern')[0].setAttribute('value', item.excludePattern);
newItem.getElementsByAttribute('name', 'dscrRedirectTo')[0].setAttribute('value', item.redirectUrl);
+ var checkEnabled = newItem.getElementsByAttribute('name', 'chkEnabled')[0];
+ checkEnabled.setAttribute('checked', !item.disabled);
newItem.item = item;
this.lstRedirects.appendChild(newItem);
newItem.setAttribute('selected', false);
}
+
+ //Enable, disable functionality
+ this.lstRedirects.addEventListener('click', function(ev) {
+ if (ev.originalTarget && ev.originalTarget.tagName == 'checkbox') {
+ var parent = ev.originalTarget.parentNode;
+ while (!parent.item) {
+ parent = parent.parentNode;
+ }
+ parent.item.disabled = !ev.originalTarget.hasAttribute('checked');
+ Redirector.save();
+ }
+ },false);
},
onLoad : function() {
@@ -35,7 +48,6 @@ var RedirectList = { this.lstRedirects.removeChild(this.template);
this.btnDelete = document.getElementById('btnDelete');
this.btnEdit = document.getElementById('btnEdit');
- this.btnDisable = document.getElementById('btnDisable');
this.addItemsToListBox(Redirector.list);
this.strings = document.getElementById('redirector-strings');
} catch(e) {
@@ -102,19 +114,12 @@ var RedirectList = { }
},
- toggleDisabled : function() {
- var listItem = this.lstRedirects.selectedItem;
- if (!listItem) {
- return;
- }
- var redirect = listItem.item;
- redirect.disabled = !redirect.disabled;
- Redirector.save();
- this.btnDisable.setAttribute('label', this.strings.getString(redirect.disabled ? 'enable' : 'disable'));
- },
-
editRedirect : function() {
+ if (this.lstRedirects.selectedIndex == -1) {
+ return;
+ }
+ //.selectedItem is still there after it has been removed, that's why we have the .selectedIndex check above as well
var listItem = this.lstRedirects.selectedItem;
if (!listItem) {
return;
@@ -136,10 +141,18 @@ var RedirectList = { if (index == -1) {
return;
}
-
+
+ var text = this.strings.getString("deleteConfirmationText");
+ var title = this.strings.getString("deleteConfirmationTitle");
+ var reallyDelete = Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Ci.nsIPromptService).confirm(null, title, text);
+ if (!reallyDelete) {
+ return;
+ }
+
try {
this.lstRedirects.removeChild(this.lstRedirects.children[index]);
Redirector.deleteAt(index);
+ this.selectionChange();
} catch(e) {
alert(e);
}
@@ -150,14 +163,6 @@ var RedirectList = { this.btnEdit.disabled = (index == -1);
this.btnDelete.disabled = (index == -1);
- this.btnDisable.disabled = (index == -1);
- var redirect = this.lstRedirects.selectedItem.item;
- try {
- if (index != -1) {
- this.btnDisable.setAttribute('label', this.strings.getString(redirect.disabled ? 'enable' : 'disable'));
- this.lstRedirects.selectedItem.setAttribute('disabled', true);
- }
- }catch(e){alert(e);}
},
importExport : function(mode, captionKey, func) {
diff --git a/chrome/content/ui/editRedirect.xul b/chrome/content/ui/editRedirect.xul index 103d1b5..22d4a8d 100644 --- a/chrome/content/ui/editRedirect.xul +++ b/chrome/content/ui/editRedirect.xul @@ -47,7 +47,10 @@ </row>
<row align="center">
<text value="&chkUnescapeMatches.label;" />
- <checkbox id="chkUnescapeMatches" label="" taborder="7"/>
+ <hbox>
+ <checkbox id="chkUnescapeMatches" label="" taborder="7"/>
+ <spacer flex="1" />
+ </hbox>
</row>
</rows>
</grid>
diff --git a/chrome/content/ui/redirectList.xul b/chrome/content/ui/redirectList.xul index 643a699..8317b15 100644 --- a/chrome/content/ui/redirectList.xul +++ b/chrome/content/ui/redirectList.xul @@ -6,8 +6,8 @@ orient="vertical"
onload="RedirectList.onLoad();"
buttons="accept"
- width="600px"
- height="400px"
+ width="650px"
+ height="500px"
windowtype="redirectorSettings"
xmlns:nc="http://home.netscape.com/NC-rdf#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
@@ -19,7 +19,7 @@ </stringbundleset>
<vbox>
- <richlistbox seltype="single" id="lstRedirects" style="margin-bottom:5px; border:solid 1px grey;" height="330px" ondblclick="RedirectList.editRedirect();" onselect="RedirectList.selectionChange();">
+ <richlistbox seltype="single" id="lstRedirects" style="margin-bottom:5px; border:solid 1px grey;" height="430px" ondblclick="RedirectList.editRedirect();" onselect="RedirectList.selectionChange();">
<richlistitem style="border-bottom:dotted 1px grey;" selected="false">
<grid>
<cols>
@@ -37,6 +37,10 @@ <label style="font-weight:bold;" value="&colRedirectTo.label;:" />
<description name="dscrRedirectTo" />
</row>
+ <row>
+ <label style="font-weight:bold;" value="&colEnabled.label;:" />
+ <hbox><checkbox checked="false" name="chkEnabled" label="" /> <spacer flex="1"/></hbox>
+ </row>
</rows>
</grid>
</richlistitem>
@@ -45,7 +49,6 @@ <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="btnDisable" onclick="RedirectList.toggleDisabled();" label="&btnDisable.label;" disabled="true" />
<button id="btnImport" onclick="RedirectList.import();" label="&btnImport.label;"/>
<button id="btnExport" onclick="RedirectList.export();" label="&btnExport.label;"/>
<button id="btnHelp" onclick="RedirectList.openHelp();" label="&btnHelp.label;"/>
diff --git a/chrome/locale/en-US/redirectList.xul.dtd b/chrome/locale/en-US/redirectList.xul.dtd index 5379647..c8892cc 100644 --- a/chrome/locale/en-US/redirectList.xul.dtd +++ b/chrome/locale/en-US/redirectList.xul.dtd @@ -3,6 +3,7 @@ <!ENTITY colIncludePattern.label "Include pattern"> <!ENTITY colExcludePattern.label "Exclude pattern"> <!ENTITY colRedirectTo.label "Redirect to"> +<!ENTITY colEnabled.label "Enabled"> <!ENTITY btnAdd.label "Add..."> <!ENTITY btnEdit.label "Edit..."> <!ENTITY btnDelete.label "Delete"> diff --git a/chrome/locale/en-US/redirector.properties b/chrome/locale/en-US/redirector.properties index 6b4ecf7..b57025b 100644 --- a/chrome/locale/en-US/redirector.properties +++ b/chrome/locale/en-US/redirector.properties @@ -15,5 +15,5 @@ xpathDeprecated=XPath patterns are no longer supported as of version 1.5.1, plea redirectorFiles=Redirector files (*.rdx) exportCaption=Export redirects... importCaption=Import redirects... -disable=Disable -enable=Enable
\ No newline at end of file +deleteConfirmationText=Are you sure you want to permanently delete this redirect? +deleteConfirmationTitle=Delete redirect? |