diff --git a/chrome/content/zotero/tools/cslpreview.xul b/chrome/content/zotero/tools/cslpreview.xul index 4b7251e11..49f29c7ce 100644 --- a/chrome/content/zotero/tools/cslpreview.xul +++ b/chrome/content/zotero/tools/cslpreview.xul @@ -43,26 +43,29 @@ this.generateBibliography = generateBibliography; function init() { - //refresh(); + //refresh(); + + var iframe = document.getElementById('zotero-csl-preview-box'); + iframe.contentDocument.documentElement.innerHTML = '
Select one or more items in Zotero and click the "Refresh" button to see how these items are rendered by the installed CSL citation styles.
'; } function refresh() { var iframe = document.getElementById('zotero-csl-preview-box'); var items = Zotero.getActiveZoteroPane().getSelectedItems(); - if (items.length == 0) { - iframe.contentDocument.documentElement.innerHTML = 'No references selected in Zotero.
'; + if (items.length === 0) { + iframe.contentDocument.documentElement.innerHTML = 'No items selected in Zotero.
'; return; } var progressWin = new Zotero.ProgressWindow(); // XXX needs its own string really! progressWin.changeHeadline(Zotero.getString("pane.items.menu.createBib.multiple")); var icon = 'chrome://zotero/skin/treeitem-attachment-file.png'; - progressWin.addLines(document.title, icon) + progressWin.addLines(document.title, icon); progressWin.show(); progressWin.startCloseTimer(); var f = function() { var styles = Zotero.Styles.getAll(); // XXX needs its own string really for the title! - var str = 'No references selected in Zotero.
'; + if (items.length === 0) { return ''; } - var authordate = document.getElementById("format-author-date"); - var numeric = document.getElementById("format-numeric"); - Zotero.debug("style class is " + style.class); - if (document.getElementById("format-note").checked == false && style.class == "note") { - Zotero.debug("CSL IGNORE NOTE one"); - return ''; - } - if (document.getElementById("format-in-text").checked == false && style.class == "in-text") { - Zotero.debug("CSL IGNORE IN-TEXT one"); - return ''; - } - var terms = new Object(); - for each(var cat in style.categories) { - Zotero.debug("TERM is " + cat.toString()); - terms[cat.toString()] = true; - } - if (!numeric.checked && terms["numeric"]) { - Zotero.debug("CSL IGNORE this numeric"); - return ''; - } - if (!authordate.checked && terms["author-date"]) { - Zotero.debug("CSL IGNORE this AD"); + var citationFormat = document.getElementById("citation-format").selectedItem.value; + if (citationFormat != "all" && citationFormat != style.categories) { + Zotero.debug("CSL IGNORE: citation format is " + style.categories); return ''; } var styleEngine = style.getCiteProc(); @@ -123,19 +107,17 @@ [], [], "html"); // Generate bibliography - if(!style.hasBibliography) { - var bibliography = ''; - } else { + var bibliography = ''; + if(style.hasBibliography) { styleEngine.updateItems([item.id for each(item in items)]); - var bibliography = '' + Zotero.Cite.makeFormattedBibliography(styleEngine, "html"); + bibliography = Zotero.Cite.makeFormattedBibliography(styleEngine, "html"); } - return '
' + citations + '
' + bibliography; } - } + }(); ]]> @@ -144,18 +126,20 @@