2016-06-27 16:40:38 +00:00
|
|
|
/*
|
|
|
|
***** BEGIN LICENSE BLOCK *****
|
|
|
|
|
|
|
|
Copyright © 2016 Center for History and New Media
|
|
|
|
George Mason University, Fairfax, Virginia, USA
|
|
|
|
http://zotero.org
|
|
|
|
|
|
|
|
This file is part of Zotero.
|
|
|
|
|
|
|
|
Zotero is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Zotero is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
***** END LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
Zotero.HardConfirmationDialog = {
|
|
|
|
init: function() {
|
2022-05-24 17:43:45 +00:00
|
|
|
document.addEventListener('dialogaccept', () => Zotero.HardConfirmationDialog.onAccept());
|
|
|
|
document.addEventListener('dialogextra1', () => Zotero.HardConfirmationDialog.onExtra1());
|
|
|
|
document.addEventListener('dialogextra2', () => Zotero.HardConfirmationDialog.onExtra2());
|
|
|
|
|
2016-06-27 16:40:38 +00:00
|
|
|
this.io = window.arguments[0];
|
|
|
|
|
2022-05-24 17:43:45 +00:00
|
|
|
Zotero.setFontSize(document.documentElement);
|
|
|
|
var dialog = document.getElementById('commonDialog');
|
2016-06-27 16:40:38 +00:00
|
|
|
var vbox = document.getElementById('infoContainer');
|
|
|
|
var sep = vbox.firstChild;
|
2020-05-23 07:17:34 +00:00
|
|
|
|
|
|
|
document.getElementById('infoBody').textContent = this.io.text;
|
|
|
|
|
|
|
|
if (this.io.title) {
|
|
|
|
document.documentElement.setAttribute('title', this.io.title);
|
|
|
|
|
|
|
|
if (Zotero.isMac) {
|
|
|
|
let elem = document.getElementById('infoTitle');
|
|
|
|
elem.textContent = this.io.title;
|
|
|
|
elem.style.marginBottom = '12px';
|
|
|
|
elem.hidden = false;
|
|
|
|
}
|
2016-06-27 16:40:38 +00:00
|
|
|
}
|
|
|
|
if (this.io.checkboxLabel) {
|
|
|
|
var checkbox = document.getElementById('zotero-hardConfirmationDialog-checkbox');
|
|
|
|
checkbox.hidden = false;
|
|
|
|
checkbox.setAttribute('label', this.io.checkboxLabel);
|
|
|
|
this.onCheckbox();
|
|
|
|
}
|
|
|
|
if (this.io.confirmationText) {
|
|
|
|
document.getElementById('zotero-hardConfirmationDialog-textbox').hidden = false;
|
|
|
|
this.onKeyUp();
|
|
|
|
}
|
|
|
|
|
2020-05-23 07:17:34 +00:00
|
|
|
if (this.io.acceptLabel) {
|
2022-05-24 17:43:45 +00:00
|
|
|
dialog.getButton('accept').label = this.io.acceptLabel
|
2020-05-23 07:17:34 +00:00
|
|
|
}
|
2016-06-27 16:40:38 +00:00
|
|
|
if (this.io.extra1Label) {
|
2022-05-24 17:43:45 +00:00
|
|
|
dialog.buttons = dialog.buttons + ',extra1';
|
|
|
|
dialog.getButton('extra1').label = this.io.extra1Label
|
2016-06-27 16:40:38 +00:00
|
|
|
}
|
2020-05-23 07:17:34 +00:00
|
|
|
if (this.io.extra2Label) {
|
2022-05-24 17:43:45 +00:00
|
|
|
dialog.buttons = dialog.buttons + ',extra2';
|
|
|
|
dialog.getButton('extra2').label = this.io.extra2Label
|
2020-05-23 07:17:34 +00:00
|
|
|
}
|
2016-06-27 16:40:38 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onCheckbox: function(event) {
|
2022-05-24 17:43:45 +00:00
|
|
|
document.getElementById('commonDialog').getButton('accept').disabled =
|
2016-06-27 16:40:38 +00:00
|
|
|
!document.getElementById('zotero-hardConfirmationDialog-checkbox').checked;
|
|
|
|
},
|
|
|
|
|
|
|
|
onKeyUp: function(event) {
|
2022-05-24 17:43:45 +00:00
|
|
|
document.getElementById('commonDialog').getButton('accept').disabled =
|
2016-06-27 16:40:38 +00:00
|
|
|
document.getElementById('zotero-hardConfirmationDialog-textbox').value != this.io.confirmationText;
|
|
|
|
},
|
|
|
|
|
|
|
|
onAccept: function() {
|
|
|
|
this.io.accept = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
onExtra1: function() {
|
|
|
|
this.io.extra1 = true;
|
2022-05-24 17:43:45 +00:00
|
|
|
document.getElementById('commonDialog').cancelDialog();
|
2020-05-23 07:17:34 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onExtra2: function() {
|
|
|
|
this.io.extra2 = true;
|
2022-05-24 17:43:45 +00:00
|
|
|
document.getElementById('commonDialog').cancelDialog();
|
2016-06-27 16:40:38 +00:00
|
|
|
}
|
|
|
|
};
|