diff --git a/chrome/content/zotero/bibliography.js b/chrome/content/zotero/bibliography.js index 3e1bd00e28..93f6683749 100644 --- a/chrome/content/zotero/bibliography.js +++ b/chrome/content/zotero/bibliography.js @@ -95,9 +95,24 @@ var Zotero_File_Interface_Bibliography = new function() { // ONLY FOR bibliography.xul: export options if(document.getElementById("save-as-rtf")) { + var settings = Zotero.Prefs.get("export.bibliographySettings"); + try { + settings = JSON.parse(settings); + var mode = settings.mode; + var method = settings.method; + } + // If not JSON, assume it's the previous format-as-a-string + catch (e) { + method = settings; + } + if (!mode) mode = "bibliography"; + if (!method) method = "save-as-rtf"; + // restore saved bibliographic settings - document.getElementById('output-radio').selectedItem = - document.getElementById(Zotero.Prefs.get("export.bibliographySettings")); + document.getElementById('output-mode-radio').selectedItem = + document.getElementById(mode); + document.getElementById('output-method-radio').selectedItem = + document.getElementById(method); } // ONLY FOR integrationDocPrefs.xul: update status of displayAs, set @@ -126,7 +141,7 @@ var Zotero_File_Interface_Bibliography = new function() { } /* - * ONLY FOR integrationDocPrefs.xul: called when style is changed + * Called when style is changed */ function styleChanged(index) { // When called from init(), selectedItem isn't yet set @@ -139,6 +154,10 @@ var Zotero_File_Interface_Bibliography = new function() { var selectedStyle = selectedItem.getAttribute('value'); + // + // For integrationDocPrefs.xul + // + // update status of displayAs box based on style class if(document.getElementById("displayAs")) { var isNote = Zotero.Styles.get(selectedStyle).class == "note"; @@ -151,16 +170,32 @@ var Zotero_File_Interface_Bibliography = new function() { document.getElementById("bookmarks").disabled = isNote; document.getElementById("bookmarks-caption").disabled = isNote; } + + // + // For bibliography.xul + // + + // Change label to "Citation" or "Note" depending on style class + if(document.getElementById("citation")) { + if(Zotero.Styles.get(selectedStyle).class == "note") { + var label = Zotero.getString('citation.note'); + } else { + var label = Zotero.getString('citation.citation'); + } + document.getElementById("citation").label = label; + } } function acceptSelection() { // collect code _io.style = document.getElementById("style-listbox").selectedItem.value; - if(document.getElementById("output-radio")) { + if(document.getElementById("output-method-radio")) { // collect settings - _io.output = document.getElementById("output-radio").selectedItem.id; + _io.mode = document.getElementById("output-mode-radio").selectedItem.id; + _io.method = document.getElementById("output-method-radio").selectedItem.id; // save settings - Zotero.Prefs.set("export.bibliographySettings", _io.output); + Zotero.Prefs.set("export.bibliographySettings", + JSON.stringify({ mode: _io.mode, method: _io.method })); } // ONLY FOR integrationDocPrefs.xul: collect displayAs diff --git a/chrome/content/zotero/bibliography.xul b/chrome/content/zotero/bibliography.xul index ff3c3f53d8..660ea13cff 100644 --- a/chrome/content/zotero/bibliography.xul +++ b/chrome/content/zotero/bibliography.xul @@ -14,11 +14,18 @@ - + - - + + + + + + + + + diff --git a/chrome/content/zotero/fileInterface.js b/chrome/content/zotero/fileInterface.js index d74c8af86b..3e53d00c34 100644 --- a/chrome/content/zotero/fileInterface.js +++ b/chrome/content/zotero/fileInterface.js @@ -489,30 +489,43 @@ var Zotero_File_Interface = new function() { var newDialog = window.openDialog("chrome://zotero/content/bibliography.xul", "_blank","chrome,modal,centerscreen", io); - if(!io.output) return; + if(!io.method) return; // determine output format var format = "html"; - if(io.output == "save-as-rtf") { + if(io.method == "save-as-rtf") { format = "rtf"; } // generate bibliography try { - if(io.output == 'copy-to-clipboard') { - copyItemsToClipboard(items, io.style); + if(io.method == 'copy-to-clipboard') { + if (io.mode == 'citation') { + copyCitationToClipboard(items, io.style); + } + else { + copyItemsToClipboard(items, io.style); + } return; } else { - var style = Zotero.Styles.get(io.style); - var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(style, items, format); + if (io.mode == 'citation') { + var csl = Zotero.Styles.get(format).csl; + csl.updateItems([item.id for each(item in items)]); + var citation = {citationItems:[{id:item.id} for each(item in items)], properties:{}}; + var bibliography = csl.previewCitationCluster(citation, [], [], "html"); + } + else { + var style = Zotero.Styles.get(io.style); + var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(style, items, format); + } } } catch(e) { window.alert(Zotero.getString("fileInterface.bibliographyGenerationError")); throw(e); } - if(io.output == "print") { + if(io.method == "print") { // printable bibliography, using a hidden browser var browser = Zotero.Browser.createHiddenBrowser(window); @@ -549,7 +562,7 @@ var Zotero_File_Interface = new function() { browser.addEventListener("pageshow", listener, false); browser.loadURIWithFlags("data:text/html;charset=utf-8,"+encodeURI(bibliography), Components.interfaces.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY, null, "utf-8", null); - } else if(io.output == "save-as-html") { + } else if(io.method == "save-as-html") { var fStream = _saveBibliography(name, "HTML"); if(fStream !== false) { @@ -575,7 +588,7 @@ var Zotero_File_Interface = new function() { os.close(); fStream.close(); } - } else if(io.output == "save-as-rtf") { + } else if(io.method == "save-as-rtf") { var fStream = _saveBibliography(name, "RTF"); if(fStream !== false) { fStream.write(bibliography, bibliography.length); diff --git a/chrome/locale/en-US/zotero/zotero.dtd b/chrome/locale/en-US/zotero/zotero.dtd index 97c1dbc327..a77b5088bb 100644 --- a/chrome/locale/en-US/zotero/zotero.dtd +++ b/chrome/locale/en-US/zotero/zotero.dtd @@ -131,9 +131,11 @@ - + - + + + diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index 0d454ef540..3d0eb16bdb 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -567,6 +567,8 @@ citation.multipleSources = Multiple Sources… citation.singleSource = Single Source… citation.showEditor = Show Editor… citation.hideEditor = Hide Editor… +citation.citation = Citation +citation.note = Note report.title.default = Zotero Report report.parentItem = Parent Item: