diff --git a/chrome/content/zotero/tools/csledit.xul b/chrome/content/zotero/tools/csledit.xul index abc04f5466..87bd96ce7f 100644 --- a/chrome/content/zotero/tools/csledit.xul +++ b/chrome/content/zotero/tools/csledit.xul @@ -42,7 +42,6 @@ this.loadCSL = loadCSL; this.generateBibliography = generateBibliography; this.refresh = refresh; - function init() { var cslList = document.getElementById('zotero-csl-list'); if (cslList.getAttribute('initialized') == 'true') { @@ -72,6 +71,30 @@ generateBibliography(editor.value); } + this.save = function() { + 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); + //get the filename from the id; we could consider doing even more here like creating the id from filename. + var parser = new DOMParser(); + var doc = parser.parseFromString(style, 'text/xml'); + var filename = doc.getElementsByTagName("id"); + if (filename) { + filename = filename[0].textContent; + fp.defaultString = filename.replace(/.+\//, "") + ".csl"; + } + else { + fp.defaultString = "untitled.csl"; + } + var rv = fp.show(); + if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) { + var outputFile = fp.file; + Zotero.File.putContents(outputFile, style); + } + } function handleKeyPress(event) { if (event.keyCode == 9 && @@ -145,7 +168,14 @@ citation.citationItems[i].locator = search.value; citation.citationItems[i].label = loc.selectedItem.value; } - citation.citationItems[i].position = parseInt(pos, 10); + if (pos == 4) { + //near note is a subsequent citation with near note set to true; + citation.citationItems[i].position = 1; + citation.citationItems[i]["near-note"] = true; + } + else { + citation.citationItems[i].position = parseInt(pos, 10); + { var subcitation = [citation.citationItems[i]]; citations += styleEngine.makeCitationCluster(subcitation) + '
'; } @@ -189,6 +219,7 @@ +