diff --git a/chrome/content/zotero/bibliography.js b/chrome/content/zotero/bibliography.js index 93f668374..76c08d09d 100644 --- a/chrome/content/zotero/bibliography.js +++ b/chrome/content/zotero/bibliography.js @@ -176,13 +176,13 @@ var Zotero_File_Interface_Bibliography = new function() { // // Change label to "Citation" or "Note" depending on style class - if(document.getElementById("citation")) { + if(document.getElementById("citations")) { if(Zotero.Styles.get(selectedStyle).class == "note") { - var label = Zotero.getString('citation.note'); + var label = Zotero.getString('citation.notes'); } else { - var label = Zotero.getString('citation.citation'); + var label = Zotero.getString('citation.citations'); } - document.getElementById("citation").label = label; + document.getElementById("citations").label = label; } } diff --git a/chrome/content/zotero/bibliography.xul b/chrome/content/zotero/bibliography.xul index 660ea13cf..32a91c2e5 100644 --- a/chrome/content/zotero/bibliography.xul +++ b/chrome/content/zotero/bibliography.xul @@ -19,7 +19,7 @@ - + diff --git a/chrome/content/zotero/fileInterface.js b/chrome/content/zotero/fileInterface.js index 865fa5f81..04dcc6677 100644 --- a/chrome/content/zotero/fileInterface.js +++ b/chrome/content/zotero/fileInterface.js @@ -432,7 +432,7 @@ var Zotero_File_Interface = new function() { * * Does not check that items are actual references (and not notes or attachments) */ - function copyItemsToClipboard(items, style, asHTML) { + function copyItemsToClipboard(items, style, asHTML, asCitations) { // copy to clipboard var transferable = Components.classes["@mozilla.org/widget/transferable;1"]. createInstance(Components.interfaces.nsITransferable); @@ -441,7 +441,7 @@ var Zotero_File_Interface = new function() { var style = Zotero.Styles.get(style); // add HTML - var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(style, items, "html"); + var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(style, items, "html", asCitations); var str = Components.classes["@mozilla.org/supports-string;1"]. createInstance(Components.interfaces.nsISupportsString); str.data = bibliography; @@ -450,7 +450,7 @@ var Zotero_File_Interface = new function() { // add text (or HTML source) if(!asHTML) { - var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(style, items, "text"); + var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(style, items, "text", asCitations); } var str = Components.classes["@mozilla.org/supports-string;1"]. createInstance(Components.interfaces.nsISupportsString); @@ -532,25 +532,12 @@ var Zotero_File_Interface = new function() { // generate bibliography try { if(io.method == 'copy-to-clipboard') { - if (io.mode == 'citation') { - copyCitationToClipboard(items, io.style); - } - else { - copyItemsToClipboard(items, io.style); - } - return; + copyItemsToClipboard(items, io.style, false, io.mode === "citation"); } else { - 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); - } + var style = Zotero.Styles.get(io.style); + var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(style, + items, format, io.mode === "citation"); } } catch(e) { window.alert(Zotero.getString("fileInterface.bibliographyGenerationError")); diff --git a/chrome/content/zotero/xpcom/cite.js b/chrome/content/zotero/xpcom/cite.js index 912c94f42..486f28174 100644 --- a/chrome/content/zotero/xpcom/cite.js +++ b/chrome/content/zotero/xpcom/cite.js @@ -69,13 +69,15 @@ Zotero.Cite = { * @param {String} format The format of the output (html, text, or rtf) * @return {String} Bibliography or item list in specified format */ - "makeFormattedBibliographyOrCitationList":function(style, items, format) { + "makeFormattedBibliographyOrCitationList":function(style, items, format, asCitationList) { var cslEngine = style.csl; cslEngine.setOutputFormat(format); cslEngine.updateItems([item.id for each(item in items)]); - - var bibliography = Zotero.Cite.makeFormattedBibliography(cslEngine, format); - if(bibliography) return bibliography; + + if(!asCitationList) { + var bibliography = Zotero.Cite.makeFormattedBibliography(cslEngine, format); + if(bibliography) return bibliography; + } var styleClass = style.class; var citations = [cslEngine.appendCitationCluster({"citationItems":[{"id":item.id}], "properties":{}}, true)[0][1] @@ -478,4 +480,4 @@ Zotero.Cite.System = { "getAbbreviations":function getAbbreviations() { return {}; } -}; \ No newline at end of file +}; diff --git a/chrome/content/zotero/xpcom/http.js b/chrome/content/zotero/xpcom/http.js index f332fb6b6..5468cc4e7 100644 --- a/chrome/content/zotero/xpcom/http.js +++ b/chrome/content/zotero/xpcom/http.js @@ -626,7 +626,8 @@ Zotero.HTTP = new function() { // (Approximately) how many seconds to wait if the document is left in the loading state and // pageshow is called before we call pageshow with an incomplete document const LOADING_STATE_TIMEOUT = 120; - var firedLoadEvent = 0; + var firedLoadEvent = 0, + loaded = false; /** * Loads the next page @@ -637,6 +638,7 @@ Zotero.HTTP = new function() { var url = urls[currentURL], hiddenBrowser = hiddenBrowsers[currentURL]; firedLoadEvent = 0; + loaded = false; currentURL++; try { Zotero.debug("Zotero.HTTP.processDocuments: Loading "+url); @@ -646,10 +648,9 @@ Zotero.HTTP = new function() { exception(e); return; } else { + if(!dontDelete) Zotero.Browser.deleteHiddenBrowser(hiddenBrowsers); throw(e); } - } finally { - doLoad(); } } else { if(!dontDelete) Zotero.Browser.deleteHiddenBrowser(hiddenBrowsers); @@ -662,19 +663,21 @@ Zotero.HTTP = new function() { * @inner */ var onLoad = function(e) { + if(loaded) return; var hiddenBrowser = e.currentTarget, doc = hiddenBrowser.contentDocument; - if(!doc || doc !== e.target) return; - var url = doc.location.href.toString(); + if(!doc) return; + var url = doc.documentURI; if(url === "about:blank") return; if(doc.readyState === "loading" && (firedLoadEvent++) < 120) { // Try again in a second - Zotero.setTimeout(onLoad.bind(this, e), 1000); + Zotero.setTimeout(onLoad.bind(this, {"currentTarget":hiddenBrowser}), 1000); return; } Zotero.debug("Zotero.HTTP.processDocuments: "+url+" loaded"); hiddenBrowser.removeEventListener("pageshow", onLoad, true); + loaded = true; try { processor(doc); diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index a0561d6ef..ede07c0d5 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -2418,6 +2418,8 @@ Zotero.DragDrop = { * Functions for creating and destroying hidden browser objects **/ Zotero.Browser = new function() { + var nBrowsers = 0; + this.createHiddenBrowser = createHiddenBrowser; this.deleteHiddenBrowser = deleteHiddenBrowser; @@ -2445,21 +2447,19 @@ Zotero.Browser = new function() { hiddenBrowser.docShell.allowJavascript = true; hiddenBrowser.docShell.allowMetaRedirects = false; hiddenBrowser.docShell.allowPlugins = false; - Zotero.debug("Created hidden browser (" - + (win.document.getElementsByTagName('browser').length - 1) + ")"); + Zotero.debug("Created hidden browser (" + (nBrowsers++) + ")"); return hiddenBrowser; } function deleteHiddenBrowser(myBrowsers) { - if(!myBrowsers instanceof Array) myBrowsers = [myBrowsers]; + if(!(myBrowsers instanceof Array)) myBrowsers = [myBrowsers]; for(var i=0; i