fx-compat: Fix hard confirmation dialog
ID changed to commonDialog so we get commonDialog.css styling for free.
This commit is contained in:
parent
1a1a5924da
commit
a2215cb8f6
4 changed files with 40 additions and 43 deletions
|
@ -25,10 +25,14 @@
|
|||
|
||||
Zotero.HardConfirmationDialog = {
|
||||
init: function() {
|
||||
document.addEventListener('dialogaccept', () => Zotero.HardConfirmationDialog.onAccept());
|
||||
document.addEventListener('dialogextra1', () => Zotero.HardConfirmationDialog.onExtra1());
|
||||
document.addEventListener('dialogextra2', () => Zotero.HardConfirmationDialog.onExtra2());
|
||||
|
||||
this.io = window.arguments[0];
|
||||
|
||||
Zotero.setFontSize(document.getElementById('zotero-hardConfirmationDialog'));
|
||||
|
||||
Zotero.setFontSize(document.documentElement);
|
||||
var dialog = document.getElementById('commonDialog');
|
||||
var vbox = document.getElementById('infoContainer');
|
||||
var sep = vbox.firstChild;
|
||||
|
||||
|
@ -56,25 +60,25 @@ Zotero.HardConfirmationDialog = {
|
|||
}
|
||||
|
||||
if (this.io.acceptLabel) {
|
||||
document.documentElement.getButton('accept').label = this.io.acceptLabel
|
||||
dialog.getButton('accept').label = this.io.acceptLabel
|
||||
}
|
||||
if (this.io.extra1Label) {
|
||||
document.documentElement.buttons = document.documentElement.buttons + ',extra1';
|
||||
document.documentElement.getButton('extra1').label = this.io.extra1Label
|
||||
dialog.buttons = dialog.buttons + ',extra1';
|
||||
dialog.getButton('extra1').label = this.io.extra1Label
|
||||
}
|
||||
if (this.io.extra2Label) {
|
||||
document.documentElement.buttons = document.documentElement.buttons + ',extra2';
|
||||
document.documentElement.getButton('extra2').label = this.io.extra2Label
|
||||
dialog.buttons = dialog.buttons + ',extra2';
|
||||
dialog.getButton('extra2').label = this.io.extra2Label
|
||||
}
|
||||
},
|
||||
|
||||
onCheckbox: function(event) {
|
||||
document.documentElement.getButton('accept').disabled =
|
||||
document.getElementById('commonDialog').getButton('accept').disabled =
|
||||
!document.getElementById('zotero-hardConfirmationDialog-checkbox').checked;
|
||||
},
|
||||
|
||||
onKeyUp: function(event) {
|
||||
document.documentElement.getButton('accept').disabled =
|
||||
document.getElementById('commonDialog').getButton('accept').disabled =
|
||||
document.getElementById('zotero-hardConfirmationDialog-textbox').value != this.io.confirmationText;
|
||||
},
|
||||
|
||||
|
@ -84,11 +88,11 @@ Zotero.HardConfirmationDialog = {
|
|||
|
||||
onExtra1: function() {
|
||||
this.io.extra1 = true;
|
||||
document.documentElement.cancelDialog();
|
||||
document.getElementById('commonDialog').cancelDialog();
|
||||
},
|
||||
|
||||
onExtra2: function() {
|
||||
this.io.extra2 = true;
|
||||
document.documentElement.cancelDialog();
|
||||
document.getElementById('commonDialog').cancelDialog();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -32,36 +32,29 @@
|
|||
|
||||
<!DOCTYPE overlay [ <!ENTITY % zoteroDTD SYSTEM "chrome://zotero/locale/zotero.dtd"> %zoteroDTD; ]>
|
||||
|
||||
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="" buttons="cancel,accept"
|
||||
id="zotero-hardConfirmationDialog"
|
||||
onload="Zotero.HardConfirmationDialog.init(); sizeToContent();"
|
||||
ondialogaccept="Zotero.HardConfirmationDialog.onAccept();"
|
||||
ondialogextra1="Zotero.HardConfirmationDialog.onExtra1();"
|
||||
ondialogextra2="Zotero.HardConfirmationDialog.onExtra2();">
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
title=""
|
||||
onload="Zotero.HardConfirmationDialog.init(); sizeToContent();"
|
||||
style="display: flex;">
|
||||
<dialog
|
||||
buttons="cancel,accept"
|
||||
id="commonDialog">
|
||||
|
||||
<script src="chrome://zotero/content/include.js"/>
|
||||
<script src="hardConfirmationDialog.js"/>
|
||||
|
||||
<grid>
|
||||
<columns>
|
||||
<column/>
|
||||
<column flex="1"/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<hbox id="iconContainer" align="start"><image id="info.icon" class="spaced alert-icon"/></hbox>
|
||||
<vbox id="infoContainer">
|
||||
<description id="infoTitle" hidden="true"/>
|
||||
<description id="infoBody"/>
|
||||
<hbox>
|
||||
<hbox id="iconContainer" align="start"><image id="info.icon" class="spaced alert-icon"/></hbox>
|
||||
<vbox id="infoContainer" flex="1">
|
||||
<description id="infoTitle" hidden="true"/>
|
||||
<description id="infoBody"/>
|
||||
|
||||
<separator class="thin"/>
|
||||
|
||||
<checkbox id="zotero-hardConfirmationDialog-checkbox" hidden="true" oncommand="Zotero.HardConfirmationDialog.onCheckbox(event)"/>
|
||||
<textbox id="zotero-hardConfirmationDialog-textbox" hidden="true" onkeyup="Zotero.HardConfirmationDialog.onKeyUp(event)"/>
|
||||
</vbox>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<separator class="thin"/>
|
||||
|
||||
<checkbox id="zotero-hardConfirmationDialog-checkbox" hidden="true" oncommand="Zotero.HardConfirmationDialog.onCheckbox(event)"/>
|
||||
<html:input id="zotero-hardConfirmationDialog-textbox" type="text" hidden="true" onkeyup="Zotero.HardConfirmationDialog.onKeyUp(event)"/>
|
||||
</vbox>
|
||||
</hbox>
|
||||
</dialog>
|
||||
</window>
|
|
@ -140,7 +140,7 @@ Zotero.Sync.Data.Local = {
|
|||
acceptLabel: Zotero.getString('account.confirmDelete.button'),
|
||||
extra2Label: Zotero.getString('general.moreInformation')
|
||||
};
|
||||
win.openDialog("chrome://zotero/content/hardConfirmationDialog.xul", "",
|
||||
win.openDialog("chrome://zotero/content/hardConfirmationDialog.xhtml", "",
|
||||
"chrome,dialog,modal,centerscreen", io);
|
||||
|
||||
if (io.accept) {
|
||||
|
|
|
@ -57,7 +57,7 @@ describe("Zotero.Sync.Data.Local", function() {
|
|||
.dispatchEvent(new Event('command'));
|
||||
|
||||
handled = true;
|
||||
}, 'accept', 'chrome://zotero/content/hardConfirmationDialog.xul');
|
||||
}, 'accept', 'chrome://zotero/content/hardConfirmationDialog.xhtml');
|
||||
var cont = yield Zotero.Sync.Data.Local.checkUser(window, 2, "B");
|
||||
var resetDataDirFileExists = yield OS.File.exists(resetDataDirFile);
|
||||
assert.isTrue(handled);
|
||||
|
@ -69,7 +69,7 @@ describe("Zotero.Sync.Data.Local", function() {
|
|||
yield Zotero.Users.setCurrentUserID(1);
|
||||
yield Zotero.Users.setCurrentUsername("A");
|
||||
|
||||
waitForDialog(false, 'cancel', 'chrome://zotero/content/hardConfirmationDialog.xul');
|
||||
waitForDialog(false, 'cancel', 'chrome://zotero/content/hardConfirmationDialog.xhtml');
|
||||
var cont = yield Zotero.Sync.Data.Local.checkUser(window, 2, "B");
|
||||
var resetDataDirFileExists = yield OS.File.exists(resetDataDirFile);
|
||||
assert.isFalse(cont);
|
||||
|
@ -85,7 +85,7 @@ describe("Zotero.Sync.Data.Local", function() {
|
|||
yield Zotero.Users.setCurrentUserID(1);
|
||||
yield Zotero.Users.setCurrentUsername("A");
|
||||
|
||||
waitForDialog(null, 'extra1', 'chrome://zotero/content/hardConfirmationDialog.xul');
|
||||
waitForDialog(null, 'extra1', 'chrome://zotero/content/hardConfirmationDialog.xhtml');
|
||||
waitForDialog();
|
||||
var cont = yield Zotero.Sync.Data.Local.checkUser(window, 2, "B");
|
||||
var resetDataDirFileExists = yield OS.File.exists(resetDataDirFile);
|
||||
|
@ -110,7 +110,7 @@ describe("Zotero.Sync.Data.Local", function() {
|
|||
item2.toJSON().relations[pred][0].startsWith('http://zotero.org/users/local/')
|
||||
);
|
||||
|
||||
waitForDialog(false, 'accept', 'chrome://zotero/content/hardConfirmationDialog.xul');
|
||||
waitForDialog(false, 'accept', 'chrome://zotero/content/hardConfirmationDialog.xhtml');
|
||||
yield Zotero.Sync.Data.Local.checkUser(window, 1, "A");
|
||||
|
||||
assert.isTrue(
|
||||
|
|
Loading…
Add table
Reference in a new issue