Fix Create Bibliography

listbox is gone, but richlistbox is still here as a custom element and
works fine for cases where we don't need virtualization.

groupbox label and richlistitem styles should probably be copied to
somewhere global once tuned a bit.
This commit is contained in:
Abe Jellinek 2022-05-18 19:32:39 -07:00
parent 4c21a42b53
commit 547311ff26
5 changed files with 35 additions and 20 deletions

View file

@ -30,7 +30,7 @@
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Class to provide options for bibliography // Class to provide options for bibliography
// Used by rtfScan.xul, integrationDocPrefs.xul, and bibliography.xul // Used by rtfScan.xul, integrationDocPrefs.xul, and bibliography.xhtml
Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource://gre/modules/Services.jsm");
var Zotero_File_Interface_Bibliography = new function() { var Zotero_File_Interface_Bibliography = new function() {
@ -50,8 +50,10 @@ var Zotero_File_Interface_Bibliography = new function() {
* @param {Object} [args] - Explicit arguments in place of window arguments * @param {Object} [args] - Explicit arguments in place of window arguments
*/ */
this.init = Zotero.Promise.coroutine(function* (args = {}) { this.init = Zotero.Promise.coroutine(function* (args = {}) {
window.addEventListener('dialogaccept', () => this.acceptSelection());
// Set font size from pref // Set font size from pref
// Affects bibliography.xul and integrationDocPrefs.xul // Affects bibliography.xhtml and integrationDocPrefs.xul
var bibContainer = document.getElementById("zotero-bibliography-container"); var bibContainer = document.getElementById("zotero-bibliography-container");
if(bibContainer) { if(bibContainer) {
Zotero.setFontSize(document.getElementById("zotero-bibliography-container")); Zotero.setFontSize(document.getElementById("zotero-bibliography-container"));
@ -86,7 +88,7 @@ var Zotero_File_Interface_Bibliography = new function() {
var styles = Zotero.Styles.getVisible(); var styles = Zotero.Styles.getVisible();
var selectIndex = null; var selectIndex = null;
for (let i=0; i < styles.length; i++) { for (let i=0; i < styles.length; i++) {
var itemNode = document.createElement("listitem"); var itemNode = document.createXULElement("richlistitem");
itemNode.setAttribute("value", styles[i].styleID); itemNode.setAttribute("value", styles[i].styleID);
let title = styles[i].title; let title = styles[i].title;
// Add acronyms to APA and ASA to avoid confusion // Add acronyms to APA and ASA to avoid confusion
@ -94,7 +96,7 @@ var Zotero_File_Interface_Bibliography = new function() {
title = title title = title
.replace(/^American Psychological Association/, "American Psychological Association (APA)") .replace(/^American Psychological Association/, "American Psychological Association (APA)")
.replace(/^American Sociological Association/, "American Sociological Association (ASA)"); .replace(/^American Sociological Association/, "American Sociological Association (ASA)");
itemNode.setAttribute("label", title); itemNode.append(title);
listbox.appendChild(itemNode); listbox.appendChild(itemNode);
if(styles[i].styleID == _io.style) { if(styles[i].styleID == _io.style) {
@ -132,7 +134,7 @@ var Zotero_File_Interface_Bibliography = new function() {
Zotero_File_Interface_Bibliography.styleChanged(); Zotero_File_Interface_Bibliography.styleChanged();
}, 0); }, 0);
// ONLY FOR bibliography.xul: export options // ONLY FOR bibliography.xhtml: export options
if(document.getElementById("save-as-rtf")) { if(document.getElementById("save-as-rtf")) {
var settings = Zotero.Prefs.get("export.bibliographySettings"); var settings = Zotero.Prefs.get("export.bibliographySettings");
try { try {
@ -245,7 +247,7 @@ var Zotero_File_Interface_Bibliography = new function() {
} }
// //
// For bibliography.xul // For bibliography.xhtml
// //
// Change label to "Citation" or "Note" depending on style class // Change label to "Citation" or "Note" depending on style class
@ -320,7 +322,7 @@ var Zotero_File_Interface_Bibliography = new function() {
this.manageStyles = function () { this.manageStyles = function () {
document.documentElement.getButton('cancel').click(); document.querySelector('dialog').getButton('cancel').click();
var win = Zotero.Utilities.Internal.openPreferences('zotero-prefpane-cite', { tab: 'styles-tab' }); var win = Zotero.Utilities.Internal.openPreferences('zotero-prefpane-cite', { tab: 'styles-tab' });
if (isDocPrefs) { if (isDocPrefs) {
Zotero.Utilities.Internal.activate(win); Zotero.Utilities.Internal.activate(win);

View file

@ -2,19 +2,22 @@
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/bibliography.css"?> <?xml-stylesheet href="chrome://zotero/skin/bibliography.css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd"> <!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&zotero.bibliography.title;" buttons="cancel,accept" <window
ondialogaccept="Zotero_File_Interface_Bibliography.acceptSelection()" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="zotero-bibliography" title="&zotero.bibliography.title;"
onload="Zotero_File_Interface_Bibliography.init()"> onload="Zotero_File_Interface_Bibliography.init()">
<dialog
buttons="cancel,accept"
id="zotero-bibliography">
<script src="include.js"/> <script src="include.js"/>
<script src="bibliography.js"/> <script src="bibliography.js"/>
<vbox id="zotero-bibliography-container"> <vbox id="zotero-bibliography-container">
<groupbox> <groupbox>
<caption label="&zotero.bibliography.style.label;"/> <label>&zotero.bibliography.style.label;</label>
<listbox id="style-listbox" onselect="Zotero_File_Interface_Bibliography.styleChanged()"/> <richlistbox id="style-listbox" onselect="Zotero_File_Interface_Bibliography.styleChanged()"/>
<hbox align="right"> <hbox align="right">
<label id="manage-styles" class="text-link" <label id="manage-styles" class="text-link"
onclick="Zotero_File_Interface_Bibliography.manageStyles()">&zotero.bibliography.manageStyles;</label> onclick="Zotero_File_Interface_Bibliography.manageStyles()">&zotero.bibliography.manageStyles;</label>
@ -22,19 +25,19 @@
</groupbox> </groupbox>
<groupbox> <groupbox>
<hbox align="center"> <hbox align="center">
<caption label="&zotero.bibliography.locale.label;"/> <label>&zotero.bibliography.locale.label;</label>
<menulist id="locale-menu" oncommand="Zotero_File_Interface_Bibliography.localeChanged(this.selectedItem.value)"/> <menulist id="locale-menu" oncommand="Zotero_File_Interface_Bibliography.localeChanged(this.selectedItem.value)"/>
</hbox> </hbox>
</groupbox> </groupbox>
<groupbox> <groupbox>
<caption label="&zotero.bibliography.outputMode;"/> <label>&zotero.bibliography.outputMode;</label>
<radiogroup id="output-mode-radio"> <radiogroup id="output-mode-radio">
<radio id="citations"/> <radio id="citations"/>
<radio id="bibliography" label="&zotero.bibliography.bibliography;"/> <radio id="bibliography" label="&zotero.bibliography.bibliography;"/>
</radiogroup> </radiogroup>
</groupbox> </groupbox>
<groupbox> <groupbox>
<caption label="&zotero.bibliography.outputMethod;"/> <label>&zotero.bibliography.outputMethod;</label>
<radiogroup id="output-method-radio"> <radiogroup id="output-method-radio">
<radio id="save-as-rtf" label="&zotero.bibliography.saveAsRTF.label;"/> <radio id="save-as-rtf" label="&zotero.bibliography.saveAsRTF.label;"/>
<radio id="save-as-html" label="&zotero.bibliography.saveAsHTML.label;"/> <radio id="save-as-html" label="&zotero.bibliography.saveAsHTML.label;"/>
@ -43,4 +46,5 @@
</radiogroup> </radiogroup>
</groupbox> </groupbox>
</vbox> </vbox>
</dialog> </dialog>
</window>

View file

@ -836,7 +836,7 @@ var Zotero_File_Interface = new function() {
} }
var io = new Object(); var io = new Object();
var newDialog = window.openDialog("chrome://zotero/content/bibliography.xul", var newDialog = window.openDialog("chrome://zotero/content/bibliography.xhtml",
"_blank","chrome,modal,centerscreen", io); "_blank","chrome,modal,centerscreen", io);
if(!io.method) return; if(!io.method) return;

View file

@ -4,11 +4,20 @@
width: 325pt; width: 325pt;
} }
#style-listbox > richlistitem {
padding: 0.2em 0.4em;
}
groupbox > label:first-child {
margin-top: 0.5em;
font-size: 1.2em;
}
#locale-box .groupbox-body { #locale-box .groupbox-body {
padding-top: 3px; padding-top: 3px;
} }
#locale-box caption { #locale-box label:first-child {
padding-top: 0; padding-top: 0;
padding-bottom: 0; padding-bottom: 0;
} }

View file

@ -18,7 +18,7 @@ describe("Create Bibliography Dialog", function () {
var deferred = Zotero.Promise.defer(); var deferred = Zotero.Promise.defer();
var called = false; var called = false;
waitForWindow("chrome://zotero/content/bibliography.xul", function (dialog) { waitForWindow("chrome://zotero/content/bibliography.xhtml", function (dialog) {
waitForWindow("chrome://zotero/content/preferences/preferences.xul", function (window) { waitForWindow("chrome://zotero/content/preferences/preferences.xul", function (window) {
// Wait for pane switch // Wait for pane switch
(async function () { (async function () {