www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

hardConfirmationDialog.js (2614B)


      1 /*
      2     ***** BEGIN LICENSE BLOCK *****
      3     
      4     Copyright © 2016 Center for History and New Media
      5                      George Mason University, Fairfax, Virginia, USA
      6                      http://zotero.org
      7     
      8     This file is part of Zotero.
      9     
     10     Zotero is free software: you can redistribute it and/or modify
     11     it under the terms of the GNU Affero General Public License as published by
     12     the Free Software Foundation, either version 3 of the License, or
     13     (at your option) any later version.
     14     
     15     Zotero is distributed in the hope that it will be useful,
     16     but WITHOUT ANY WARRANTY; without even the implied warranty of
     17     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     18     GNU Affero General Public License for more details.
     19     
     20     You should have received a copy of the GNU Affero General Public License
     21     along with Zotero.  If not, see <http://www.gnu.org/licenses/>.
     22     
     23     ***** END LICENSE BLOCK *****
     24 */
     25 
     26 Zotero.HardConfirmationDialog = {
     27 	init: function() {
     28 		var label, content;
     29 		this.io = window.arguments[0];
     30 		
     31 		var vbox = document.getElementById('infoContainer');
     32 		var sep = vbox.firstChild;
     33 		for (let text of this.io.text) {
     34 			label = document.createElement('label');
     35 			content = document.createTextNode(text);
     36 			label.appendChild(content);
     37 			vbox.insertBefore(label, sep);
     38 		}
     39 		if (this.io.checkboxLabel) {
     40 			var checkbox = document.getElementById('zotero-hardConfirmationDialog-checkbox');
     41 			checkbox.hidden = false;
     42 			checkbox.setAttribute('label', this.io.checkboxLabel);
     43 			this.onCheckbox();
     44 		}
     45 		if (this.io.confirmationText) {
     46 			document.getElementById('zotero-hardConfirmationDialog-textbox').hidden = false;
     47 			this.onKeyUp();
     48 		}
     49 		
     50 		if (this.io.extra1Label) {
     51 			document.documentElement.buttons = document.documentElement.buttons + ',extra1';
     52 			document.documentElement.getButton('extra1').label = this.io.extra1Label
     53 		} if (this.io.acceptLabel) {
     54 			document.documentElement.getButton('accept').label = this.io.acceptLabel
     55 		}
     56 		
     57 		document.documentElement.setAttribute('title', this.io.title);
     58 	},
     59 	
     60 	onCheckbox: function(event) {
     61 		document.documentElement.getButton('accept').disabled = 
     62 			!document.getElementById('zotero-hardConfirmationDialog-checkbox').checked;
     63 	},
     64 	
     65 	onKeyUp: function(event) {
     66 		document.documentElement.getButton('accept').disabled = 
     67 			document.getElementById('zotero-hardConfirmationDialog-textbox').value != this.io.confirmationText;
     68 	},
     69 	
     70 	onAccept: function() {
     71 		this.io.accept = true;
     72 	},
     73 	
     74 	onExtra1: function() {
     75 		this.io.extra1 = true;
     76 		document.documentElement.cancelDialog();
     77 	}
     78 };