fx-compat: Fix hard confirmation dialog

ID changed to commonDialog so we get commonDialog.css styling for free.
This commit is contained in:
Abe Jellinek 2022-05-24 11:43:45 -06:00
parent 1a1a5924da
commit a2215cb8f6
4 changed files with 40 additions and 43 deletions

View file

@ -25,10 +25,14 @@
Zotero.HardConfirmationDialog = { Zotero.HardConfirmationDialog = {
init: function() { 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]; 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 vbox = document.getElementById('infoContainer');
var sep = vbox.firstChild; var sep = vbox.firstChild;
@ -56,25 +60,25 @@ Zotero.HardConfirmationDialog = {
} }
if (this.io.acceptLabel) { if (this.io.acceptLabel) {
document.documentElement.getButton('accept').label = this.io.acceptLabel dialog.getButton('accept').label = this.io.acceptLabel
} }
if (this.io.extra1Label) { if (this.io.extra1Label) {
document.documentElement.buttons = document.documentElement.buttons + ',extra1'; dialog.buttons = dialog.buttons + ',extra1';
document.documentElement.getButton('extra1').label = this.io.extra1Label dialog.getButton('extra1').label = this.io.extra1Label
} }
if (this.io.extra2Label) { if (this.io.extra2Label) {
document.documentElement.buttons = document.documentElement.buttons + ',extra2'; dialog.buttons = dialog.buttons + ',extra2';
document.documentElement.getButton('extra2').label = this.io.extra2Label dialog.getButton('extra2').label = this.io.extra2Label
} }
}, },
onCheckbox: function(event) { onCheckbox: function(event) {
document.documentElement.getButton('accept').disabled = document.getElementById('commonDialog').getButton('accept').disabled =
!document.getElementById('zotero-hardConfirmationDialog-checkbox').checked; !document.getElementById('zotero-hardConfirmationDialog-checkbox').checked;
}, },
onKeyUp: function(event) { onKeyUp: function(event) {
document.documentElement.getButton('accept').disabled = document.getElementById('commonDialog').getButton('accept').disabled =
document.getElementById('zotero-hardConfirmationDialog-textbox').value != this.io.confirmationText; document.getElementById('zotero-hardConfirmationDialog-textbox').value != this.io.confirmationText;
}, },
@ -84,11 +88,11 @@ Zotero.HardConfirmationDialog = {
onExtra1: function() { onExtra1: function() {
this.io.extra1 = true; this.io.extra1 = true;
document.documentElement.cancelDialog(); document.getElementById('commonDialog').cancelDialog();
}, },
onExtra2: function() { onExtra2: function() {
this.io.extra2 = true; this.io.extra2 = true;
document.documentElement.cancelDialog(); document.getElementById('commonDialog').cancelDialog();
} }
}; };

View file

@ -32,36 +32,29 @@
<!DOCTYPE overlay [ <!ENTITY % zoteroDTD SYSTEM "chrome://zotero/locale/zotero.dtd"> %zoteroDTD; ]> <!DOCTYPE overlay [ <!ENTITY % zoteroDTD SYSTEM "chrome://zotero/locale/zotero.dtd"> %zoteroDTD; ]>
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="" buttons="cancel,accept" xmlns:html="http://www.w3.org/1999/xhtml"
id="zotero-hardConfirmationDialog" title=""
onload="Zotero.HardConfirmationDialog.init(); sizeToContent();" onload="Zotero.HardConfirmationDialog.init(); sizeToContent();"
ondialogaccept="Zotero.HardConfirmationDialog.onAccept();" style="display: flex;">
ondialogextra1="Zotero.HardConfirmationDialog.onExtra1();" <dialog
ondialogextra2="Zotero.HardConfirmationDialog.onExtra2();"> buttons="cancel,accept"
id="commonDialog">
<script src="chrome://zotero/content/include.js"/> <script src="chrome://zotero/content/include.js"/>
<script src="hardConfirmationDialog.js"/> <script src="hardConfirmationDialog.js"/>
<grid> <hbox>
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row>
<hbox id="iconContainer" align="start"><image id="info.icon" class="spaced alert-icon"/></hbox> <hbox id="iconContainer" align="start"><image id="info.icon" class="spaced alert-icon"/></hbox>
<vbox id="infoContainer"> <vbox id="infoContainer" flex="1">
<description id="infoTitle" hidden="true"/> <description id="infoTitle" hidden="true"/>
<description id="infoBody"/> <description id="infoBody"/>
<separator class="thin"/> <separator class="thin"/>
<checkbox id="zotero-hardConfirmationDialog-checkbox" hidden="true" oncommand="Zotero.HardConfirmationDialog.onCheckbox(event)"/> <checkbox id="zotero-hardConfirmationDialog-checkbox" hidden="true" oncommand="Zotero.HardConfirmationDialog.onCheckbox(event)"/>
<textbox id="zotero-hardConfirmationDialog-textbox" hidden="true" onkeyup="Zotero.HardConfirmationDialog.onKeyUp(event)"/> <html:input id="zotero-hardConfirmationDialog-textbox" type="text" hidden="true" onkeyup="Zotero.HardConfirmationDialog.onKeyUp(event)"/>
</vbox> </vbox>
</row> </hbox>
</rows>
</grid>
</dialog> </dialog>
</window>

View file

@ -140,7 +140,7 @@ Zotero.Sync.Data.Local = {
acceptLabel: Zotero.getString('account.confirmDelete.button'), acceptLabel: Zotero.getString('account.confirmDelete.button'),
extra2Label: Zotero.getString('general.moreInformation') extra2Label: Zotero.getString('general.moreInformation')
}; };
win.openDialog("chrome://zotero/content/hardConfirmationDialog.xul", "", win.openDialog("chrome://zotero/content/hardConfirmationDialog.xhtml", "",
"chrome,dialog,modal,centerscreen", io); "chrome,dialog,modal,centerscreen", io);
if (io.accept) { if (io.accept) {

View file

@ -57,7 +57,7 @@ describe("Zotero.Sync.Data.Local", function() {
.dispatchEvent(new Event('command')); .dispatchEvent(new Event('command'));
handled = true; 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 cont = yield Zotero.Sync.Data.Local.checkUser(window, 2, "B");
var resetDataDirFileExists = yield OS.File.exists(resetDataDirFile); var resetDataDirFileExists = yield OS.File.exists(resetDataDirFile);
assert.isTrue(handled); assert.isTrue(handled);
@ -69,7 +69,7 @@ describe("Zotero.Sync.Data.Local", function() {
yield Zotero.Users.setCurrentUserID(1); yield Zotero.Users.setCurrentUserID(1);
yield Zotero.Users.setCurrentUsername("A"); 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 cont = yield Zotero.Sync.Data.Local.checkUser(window, 2, "B");
var resetDataDirFileExists = yield OS.File.exists(resetDataDirFile); var resetDataDirFileExists = yield OS.File.exists(resetDataDirFile);
assert.isFalse(cont); assert.isFalse(cont);
@ -85,7 +85,7 @@ describe("Zotero.Sync.Data.Local", function() {
yield Zotero.Users.setCurrentUserID(1); yield Zotero.Users.setCurrentUserID(1);
yield Zotero.Users.setCurrentUsername("A"); yield Zotero.Users.setCurrentUsername("A");
waitForDialog(null, 'extra1', 'chrome://zotero/content/hardConfirmationDialog.xul'); waitForDialog(null, 'extra1', 'chrome://zotero/content/hardConfirmationDialog.xhtml');
waitForDialog(); waitForDialog();
var cont = yield Zotero.Sync.Data.Local.checkUser(window, 2, "B"); var cont = yield Zotero.Sync.Data.Local.checkUser(window, 2, "B");
var resetDataDirFileExists = yield OS.File.exists(resetDataDirFile); 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/') 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"); yield Zotero.Sync.Data.Local.checkUser(window, 1, "A");
assert.isTrue( assert.isTrue(