From 49a9c2dba94c1d139c454d115fd6eaa503c88ebf Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Mon, 16 May 2022 14:27:23 -0700 Subject: [PATCH] fx-compat: Fix Export dialog RDF isn't working yet, but CSV works well. --- chrome/content/zotero/charsetMenu.js | 10 +++++----- chrome/content/zotero/exportOptions.js | 13 ++++++++----- .../{exportOptions.xul => exportOptions.xhtml} | 13 +++++++------ chrome/content/zotero/fileInterface.js | 2 +- 4 files changed, 21 insertions(+), 17 deletions(-) rename chrome/content/zotero/{exportOptions.xul => exportOptions.xhtml} (83%) diff --git a/chrome/content/zotero/charsetMenu.js b/chrome/content/zotero/charsetMenu.js index a7fd6106e9..0d4d0a4458 100644 --- a/chrome/content/zotero/charsetMenu.js +++ b/chrome/content/zotero/charsetMenu.js @@ -37,7 +37,7 @@ var Zotero_Charset_Menu = new function() { var charsetMap = {}; // get charset popup and charset RDF - var charsetPopup = document.createElement("menupopup"); + var charsetPopup = document.createXULElement("menupopup"); charsetMenu.appendChild(charsetPopup); var charsets = []; @@ -53,7 +53,7 @@ var Zotero_Charset_Menu = new function() { for (let charset of charsets) { let { label, value } = charset; - let itemNode = document.createElement("menuitem"); + let itemNode = document.createXULElement("menuitem"); itemNode.setAttribute("label", label); itemNode.setAttribute("value", value); @@ -62,7 +62,7 @@ var Zotero_Charset_Menu = new function() { } } else { - var charsetSeparator = document.createElement("menuseparator"); + var charsetSeparator = document.createXULElement("menuseparator"); charsetPopup.appendChild(charsetSeparator); Components.utils.import("resource://gre/modules/CharsetMenu.jsm"); @@ -94,7 +94,7 @@ var Zotero_Charset_Menu = new function() { label = charsets[i].label; // add element - var itemNode = document.createElement("menuitem"); + var itemNode = document.createXULElement("menuitem"); itemNode.setAttribute("label", label); itemNode.setAttribute("value", charset); @@ -109,7 +109,7 @@ var Zotero_Charset_Menu = new function() { } } - var itemNode = document.createElement("menuitem"); + var itemNode = document.createXULElement("menuitem"); itemNode.setAttribute("label", Zotero.getString("charset.autoDetect")); itemNode.setAttribute("value", "auto"); charsetMap["auto"] = itemNode; diff --git a/chrome/content/zotero/exportOptions.js b/chrome/content/zotero/exportOptions.js index 986420558c..3b7bd2295b 100644 --- a/chrome/content/zotero/exportOptions.js +++ b/chrome/content/zotero/exportOptions.js @@ -63,7 +63,7 @@ var Zotero_File_Interface_Export = new function() { // add styles to format popup for(var i in translators) { - var itemNode = document.createElement("menuitem"); + var itemNode = document.createXULElement("menuitem"); itemNode.setAttribute("label", translators[i].label); formatPopup.appendChild(itemNode); @@ -91,7 +91,7 @@ var Zotero_File_Interface_Export = new function() { // right now, option interface supports only boolean values, which // it interprets as checkboxes if(typeof(translators[i].displayOptions[option]) == "boolean") { - let checkbox = document.createElement("checkbox"); + let checkbox = document.createXULElement("checkbox"); checkbox.setAttribute("id", OPTION_PREFIX+option); checkbox.setAttribute("label", optionLabel); optionsBox.insertBefore(checkbox, charsetBox); @@ -102,7 +102,7 @@ var Zotero_File_Interface_Export = new function() { setTimeout(() => this.updateAnnotationsCheckbox()); }; - checkbox = document.createElement("checkbox"); + checkbox = document.createXULElement("checkbox"); checkbox.setAttribute("id", OPTION_PREFIX + 'includeAnnotations'); checkbox.setAttribute( "label", @@ -135,6 +135,9 @@ var Zotero_File_Interface_Export = new function() { this.updateOptions(Zotero.Prefs.get( exportingNotes ? "export.noteTranslatorSettings" : "export.translatorSettings" )); + + document.addEventListener('dialogaccept', () => this.accept()); + document.addEventListener('dialogcancel', () => this.cancel()); } /* @@ -178,9 +181,9 @@ var Zotero_File_Interface_Export = new function() { var isChecked = options[optionName]; } else { // use defaults - var isChecked = (defValue ? "true" : "false"); + isChecked = defValue; } - node.setAttribute("checked", isChecked); + node.checked = isChecked; } } else { // option should be disabled and unchecked to prevent confusion diff --git a/chrome/content/zotero/exportOptions.xul b/chrome/content/zotero/exportOptions.xhtml similarity index 83% rename from chrome/content/zotero/exportOptions.xul rename to chrome/content/zotero/exportOptions.xhtml index 28d21a18e9..c61eb02803 100644 --- a/chrome/content/zotero/exportOptions.xul +++ b/chrome/content/zotero/exportOptions.xhtml @@ -6,13 +6,13 @@ %zoteroDTD; ]> - +