www

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

commit 0be9e73b51e9eacc6a3529717545efbe355e9203
parent eec1ba4c737f6e012fbaa7e1a3a15349c094501a
Author: rmzelle <rintze.zelle@gmail.com>
Date:   Wed, 14 Jan 2015 21:21:00 -0500

Further improvements to Style Editor and Preview
* Clean up code (remove some pre-CSL 0.8.1 code, see also https://github.com/zotero/zotero/commit/e32e6aa2f549065f9b841132bfe97f7d63015ce4 )
* Complete localization
* Save vertical space. Editor: remove "pre-wrap" wrapping, use smaller headers, add grippy to collapse CSL code. Preview: remove groupbox

Diffstat:
Mchrome/content/zotero/tools/csledit.js | 53++++++++++++++++++++---------------------------------
Mchrome/content/zotero/tools/csledit.xul | 45++++++++++++++++++++++++++-------------------
Mchrome/content/zotero/tools/cslpreview.js | 4++--
Mchrome/content/zotero/tools/cslpreview.xul | 38+++++++++++++++++++-------------------
Achrome/locale/en-US/zotero/csledit.dtd | 4++++
Mchrome/locale/en-US/zotero/cslpreview.dtd | 17++++++++---------
Mchrome/locale/en-US/zotero/zotero.dtd | 4++--
Mchrome/locale/en-US/zotero/zotero.properties | 10++++++++--
8 files changed, 89 insertions(+), 86 deletions(-)

diff --git a/chrome/content/zotero/tools/csledit.js b/chrome/content/zotero/tools/csledit.js @@ -69,20 +69,20 @@ var Zotero_CSL_Editor = new function() { } pageList.selectedIndex = 0; - cslList.setAttribute('initialized', true) + cslList.setAttribute('initialized', true); } function refresh() { - var editor = document.getElementById('zotero-csl-editor') + var editor = document.getElementById('zotero-csl-editor'); generateBibliography(editor.value); } this.save = function() { - var editor = document.getElementById('zotero-csl-editor') + var editor = document.getElementById('zotero-csl-editor'); var style = editor.value; const nsIFilePicker = Components.interfaces.nsIFilePicker; var fp = Components.classes["@mozilla.org/filepicker;1"] .createInstance(nsIFilePicker); - fp.init(window, "Save Citation Style", nsIFilePicker.modeSave); + fp.init(window, Zotero.getString('styles.editor.save'), nsIFilePicker.modeSave); fp.appendFilter("Citation Style Language", "*.csl"); //get the filename from the id; we could consider doing even more here like creating the id from filename. var parser = new DOMParser(); @@ -100,7 +100,7 @@ var Zotero_CSL_Editor = new function() { var outputFile = fp.file; Zotero.File.putContents(outputFile, style); } - } + }; function handleKeyPress(event) { if (event.keyCode == 9 && @@ -112,7 +112,7 @@ var Zotero_CSL_Editor = new function() { function loadCSL(cslID) { - var editor = document.getElementById('zotero-csl-editor') + var editor = document.getElementById('zotero-csl-editor'); var style = Zotero.Styles.get(cslID); editor.value = Zotero.File.getContents(style.file); editor.cslID = cslID; @@ -127,26 +127,16 @@ var Zotero_CSL_Editor = new function() { var items = Zotero.getActiveZoteroPane().getSelectedItems(); if (items.length == 0) { - iframe.contentDocument.documentElement.innerHTML = '<html><head><title></title></head><body><p style="color: red">No references selected in Zotero.</p></body></html>'; + iframe.contentDocument.documentElement.innerHTML = '<html><head><title></title></head><body><p style="color: red">' + Zotero.getString('styles.editor.warning.noItems') + '</p></body></html>'; return; } var styleObject, styleEngine; - if (str.indexOf("<defaults") != -1) { - iframe.contentDocument.documentElement.innerHTML = - '<div>' - + "Old-style CSLs are no longer supported." - + '</div>'; - return; - } - else { - try { - styleObject = new Zotero.Style(str); - styleEngine = styleObject.getCiteProc(); - } catch(e) { - iframe.contentDocument.documentElement.innerHTML = '<div>Error parsing '+ - 'style: </div><div>'+e+'</div>'; - throw e; - } + try { + styleObject = new Zotero.Style(str); + styleEngine = styleObject.getCiteProc(); + } catch(e) { + iframe.contentDocument.documentElement.innerHTML = '<div>' + Zotero.getString('styles.editor.warning.parseError') + '</div><div>'+e+'</div>'; + throw e; } var itemIds = [items[i].id for (i in items)]; @@ -167,10 +157,10 @@ var Zotero_CSL_Editor = new function() { var search = document.getElementById('preview-pages'); var loc = document.getElementById('zotero-csl-page-type'); var pos = document.getElementById('zotero-ref-position').selectedItem.value; - var citations = '<h1>Single Citations</h1>'; + var citations = '<h3>' + Zotero.getString('styles.editor.output.individualCitations') + '</h3>'; for (var i=0; i<citation.citationItems.length; i++) { citation.citationItems[i]['suppress-author'] = author; - if (search.value != '') { + if (search.value !== '') { citation.citationItems[i].locator = search.value; citation.citationItems[i].label = loc.selectedItem.value; } @@ -187,21 +177,18 @@ var Zotero_CSL_Editor = new function() { } try { - var multCitations = '<hr><h1>Multi Citations <span style="font-size:smaller;">(all with position "first")</span></h1>' + + var multCitations = '<hr><h3>' + Zotero.getString('styles.editor.output.singleCitation') + '</h3>' + styleEngine.previewCitationCluster(citation, [], [], "html"); // Generate bibliography styleEngine.updateItems(itemIds); - var bibliography = '<hr/><h1>Bibliography</h1>' + + var bibliography = '<hr/><h3>' + Zotero.getString('styles.bibliography') + '</h3>' + Zotero.Cite.makeFormattedBibliography(styleEngine, "html"); iframe.contentDocument.documentElement.innerHTML = - '<div style="white-space: pre-wrap">' - + citations + multCitations + bibliography - + '</div>'; + '<div>' + citations + multCitations + bibliography + '</div>'; } catch(e) { - iframe.contentDocument.documentElement.innerHTML = '<div>Error generating citations '+ - 'and bibliography: </div><div>'+e+'</div>'; + iframe.contentDocument.documentElement.innerHTML = '<div>' + Zotero.getString('styles.editor.warning.renderError') + '</div><div>'+e+'</div>'; throw e; } } @@ -219,4 +206,4 @@ var Zotero_CSL_Editor = new function() { controller.doCommandWithParams(command, params); } } -} +}(); diff --git a/chrome/content/zotero/tools/csledit.xul b/chrome/content/zotero/tools/csledit.xul @@ -26,40 +26,47 @@ <?xml-stylesheet href="chrome://global/skin/global.css"?> <?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?> +<!DOCTYPE window [ + <!ENTITY % csleditDTD SYSTEM "chrome://zotero/locale/csledit.dtd"> %csleditDTD; + <!ENTITY % zoteroDTD SYSTEM "chrome://zotero/locale/zotero.dtd"> %zoteroDTD; +]> + <window id="csl-edit" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="Zotero_CSL_Editor.init();" - title="Zotero Style Editor"> + title="&styles.editor;"> <script src="chrome://zotero/content/include.js"/> <script src="csledit.js"/> <vbox flex="1"> <hbox align="center"> - <button id="preview-refresh-button" label="Refresh" oncommand="Zotero_CSL_Editor.refresh()"/> - <button id="zotero-csl-save" label="Save" oncommand="Zotero_CSL_Editor.save()"/> - <menulist id="zotero-csl-page-type" style="min-height: 1.6em; min-width: 50px" oncommand="Zotero_CSL_Editor.refresh()" /> - <label value=":" /> - <textbox size="5" id="preview-pages" type="timed" timeout="250" oncommand="Zotero_CSL_Editor.refresh()"/> - <checkbox oncommand="Zotero_CSL_Editor.refresh()" id="preview-suppress-author" label="Suppress author" /> - <label value="Citation is:" /> - <menulist id="zotero-ref-position" oncommand="Zotero_CSL_Editor.refresh()"> - <menupopup> - <menuitem label="First" value="0"/> - <menuitem label="Subsequent" value="1"/> - <menuitem label="Ibid" value="2"/> - <menuitem label="Ibid+Locator" value="3"/> - <menuitem label="Near Note" value="4"/> - </menupopup> - </menulist> - <menulist id="zotero-csl-list" style="min-height: 1.6em; min-width: 100px" initialized="false" flex="1" oncommand="Zotero_CSL_Editor.loadCSL(this.selectedItem.value)"/> + <button id="preview-refresh-button" label="&zotero.general.refresh;" oncommand="Zotero_CSL_Editor.refresh()"/> + <button id="zotero-csl-save" label="&zotero.general.saveAs;" oncommand="Zotero_CSL_Editor.save()"/> + <menulist id="zotero-csl-page-type" style="min-height: 1.6em; min-width: 50px" oncommand="Zotero_CSL_Editor.refresh()" /> + <label value=":" /> + <textbox size="5" id="preview-pages" type="timed" timeout="250" oncommand="Zotero_CSL_Editor.refresh()"/> + <checkbox oncommand="Zotero_CSL_Editor.refresh()" id="preview-suppress-author" label="&styles.editor.suppressAuthor;" /> + <label value="&styles.editor.citePosition;" /> + <menulist id="zotero-ref-position" oncommand="Zotero_CSL_Editor.refresh()"> + <menupopup> + <menuitem label="first" value="0"/> + <menuitem label="subsequent" value="1"/> + <menuitem label="ibid" value="2"/> + <menuitem label="ibid-with-locator" value="3"/> + <menuitem label="near-note" value="4"/> + </menupopup> + </menulist> + <menulist id="zotero-csl-list" style="min-height: 1.6em; min-width: 100px" initialized="false" flex="1" oncommand="Zotero_CSL_Editor.loadCSL(this.selectedItem.value)"/> </hbox> <textbox id="zotero-csl-editor" type="timed" timeout="250" multiline="true" flex="1" onkeypress="Zotero_CSL_Editor.handleKeyPress(event)" oncommand="document.getElementById('zotero-csl-list').selectedIndex = -1; Zotero_CSL_Editor.generateBibliography(this.value)"/> - <splitter/> + <splitter id="csledit-splitter" collapse="before" persist="state"> + <grippy/> + </splitter> <iframe id="zotero-csl-preview-box" flex="1" style="padding: 0 1em;background:white" overflow="auto" type="content"/> </vbox> diff --git a/chrome/content/zotero/tools/cslpreview.js b/chrome/content/zotero/tools/cslpreview.js @@ -33,13 +33,13 @@ var Zotero_CSL_Preview = new function() { //refresh(); var iframe = document.getElementById('zotero-csl-preview-box'); - iframe.contentDocument.documentElement.innerHTML = '<html><head><title></title></head><body><p>' + Zotero.getString('cslpreview.instruction') + '</p></body></html>'; + iframe.contentDocument.documentElement.innerHTML = '<html><head><title></title></head><body><p>' + Zotero.getString('styles.preview.instructions') + '</p></body></html>'; } function refresh() { var iframe = document.getElementById('zotero-csl-preview-box'); var items = Zotero.getActiveZoteroPane().getSelectedItems(); if (items.length === 0) { - iframe.contentDocument.documentElement.innerHTML = '<html><head><title></title></head><body><p style="color: red">' + Zotero.getString('cslpreview.warning.noItems') + '</p></body></html>'; + iframe.contentDocument.documentElement.innerHTML = '<html><head><title></title></head><body><p style="color: red">' + Zotero.getString('styles.editor.warning.noItems') + '</p></body></html>'; return; } var progressWin = new Zotero.ProgressWindow(); diff --git a/chrome/content/zotero/tools/cslpreview.xul b/chrome/content/zotero/tools/cslpreview.xul @@ -27,37 +27,37 @@ <?xml-stylesheet href="chrome://global/skin/global.css"?> <?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?> -<!DOCTYPE window SYSTEM "chrome://zotero/locale/cslpreview.dtd"> +<!DOCTYPE window [ + <!ENTITY % cslpreviewDTD SYSTEM "chrome://zotero/locale/cslpreview.dtd"> %cslpreviewDTD; + <!ENTITY % zoteroDTD SYSTEM "chrome://zotero/locale/zotero.dtd"> %zoteroDTD; +]> <window id="csl-preview" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="Zotero_CSL_Preview.init();" - title="&zotero.cslpreview;"> + title="&styles.preview;"> <script src="chrome://zotero/content/include.js"/> <script src="cslpreview.js"/> <vbox flex="1"> - <hbox > <hbox align="center"> - <button id="preview-refresh-button" label="&zotero.cslpreview.refresh;" oncommand="Zotero_CSL_Preview.refresh()"/> - <groupbox orient="horizontal" align="center"> - <label value="&zotero.cslpreview.citationFormat;" /> - <menulist id="citation-format" oncommand="Zotero_CSL_Preview.refresh()"> - <menupopup> - <menuitem value="all" label="&zotero.cslpreview.citationFormat.all;"/> - <menuitem value="author" label="&zotero.cslpreview.citationFormat.author;"/> - <menuitem value="author-date" label="&zotero.cslpreview.citationFormat.authorDate;"/> - <menuitem value="label" label="&zotero.cslpreview.citationFormat.label;"/> - <menuitem value="note" label="&zotero.cslpreview.citationFormat.note;"/> - <menuitem value="numeric" label="&zotero.cslpreview.citationFormat.numeric;"/> - </menupopup> - </menulist> - </groupbox> + <button id="preview-refresh-button" label="&zotero.general.refresh;" oncommand="Zotero_CSL_Preview.refresh()"/> + + <label value="&styles.preview.citationFormat;" /> + <menulist id="citation-format" oncommand="Zotero_CSL_Preview.refresh()"> + <menupopup> + <menuitem value="all" label="&styles.preview.citationFormat.all;"/> + <menuitem value="author" label="&styles.preview.citationFormat.author;"/> + <menuitem value="author-date" label="&styles.preview.citationFormat.authorDate;"/> + <menuitem value="label" label="&styles.preview.citationFormat.label;"/> + <menuitem value="note" label="&styles.preview.citationFormat.note;"/> + <menuitem value="numeric" label="&styles.preview.citationFormat.numeric;"/> + </menupopup> + </menulist> </hbox> - </hbox> - <iframe id="zotero-csl-preview-box" flex="1" style="padding: 0 1em; background:white;" overflow="auto" type="content"/> + <iframe id="zotero-csl-preview-box" flex="1" style="padding: 0 1em; background:white;" overflow="auto" type="content"/> </vbox> </window> diff --git a/chrome/locale/en-US/zotero/csledit.dtd b/chrome/locale/en-US/zotero/csledit.dtd @@ -0,0 +1,4 @@ +<!ENTITY styles.editor "Zotero Style Editor"> + +<!ENTITY styles.editor.suppressAuthor "Suppress Author"> +<!ENTITY styles.editor.citePosition "Cite Position:"> diff --git a/chrome/locale/en-US/zotero/cslpreview.dtd b/chrome/locale/en-US/zotero/cslpreview.dtd @@ -1,10 +1,9 @@ -<!ENTITY zotero.cslpreview "Zotero Style Preview"> -<!ENTITY zotero.cslpreview.refresh "Refresh"> +<!ENTITY styles.preview "Zotero Style Preview"> -<!ENTITY zotero.cslpreview.citationFormat "Citation Format:"> -<!ENTITY zotero.cslpreview.citationFormat.all "all"> -<!ENTITY zotero.cslpreview.citationFormat.author "author"> -<!ENTITY zotero.cslpreview.citationFormat.authorDate "author-date"> -<!ENTITY zotero.cslpreview.citationFormat.label "label"> -<!ENTITY zotero.cslpreview.citationFormat.note "note"> -<!ENTITY zotero.cslpreview.citationFormat.numeric "numeric"> +<!ENTITY styles.preview.citationFormat "Citation Format:"> +<!ENTITY styles.preview.citationFormat.all "all"> +<!ENTITY styles.preview.citationFormat.author "author"> +<!ENTITY styles.preview.citationFormat.authorDate "author-date"> +<!ENTITY styles.preview.citationFormat.label "label"> +<!ENTITY styles.preview.citationFormat.note "note"> +<!ENTITY styles.preview.citationFormat.numeric "numeric"> diff --git a/chrome/locale/en-US/zotero/zotero.dtd b/chrome/locale/en-US/zotero/zotero.dtd @@ -6,6 +6,8 @@ <!ENTITY zotero.general.delete "Delete"> <!ENTITY zotero.general.ok "OK"> <!ENTITY zotero.general.cancel "Cancel"> +<!ENTITY zotero.general.refresh "Refresh"> +<!ENTITY zotero.general.saveAs "Save As…"> <!ENTITY zotero.errorReport.title "Zotero Error Report"> <!ENTITY zotero.errorReport.unrelatedMessages "This may include messages unrelated to Zotero."> @@ -288,5 +290,3 @@ <!ENTITY zotero.attachLink.title "Attach Link to URI"> <!ENTITY zotero.attachLink.label.link "Link:"> <!ENTITY zotero.attachLink.label.title "Title:"> - - diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties @@ -969,5 +969,11 @@ firstRunGuidance.quickFormatMac = Type a title or author to search for a referen firstRunGuidance.toolbarButton.new = Click here to open Zotero, or use the %S keyboard shortcut. firstRunGuidance.toolbarButton.upgrade = The Zotero icon can now be found in the Firefox toolbar. Click the icon to open Zotero, or use the %S keyboard shortcut. -cslpreview.instruction = 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. -cslpreview.warning.noItems = No items selected in Zotero. +styles.bibliography = Bibliography +styles.editor.save = Save Citation Style +styles.editor.warning.noItems = No items selected in Zotero. +styles.editor.warning.parseError = Error parsing style: +styles.editor.warning.renderError = Error generating citations and bibliography: +styles.editor.output.individualCitations = Individual Citations +styles.editor.output.singleCitation = Single Citation (with position "first") +styles.preview.instructions = 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.