Revert "Make citing work via right-click"
This reverts commit f95832d4a9
.
No longer necessary with deasyncification.
This commit is contained in:
parent
285dac425c
commit
d871e2540b
|
@ -126,6 +126,7 @@ var Zotero_File_Interface = new function() {
|
||||||
this.exportItems = exportItems;
|
this.exportItems = exportItems;
|
||||||
this.bibliographyFromCollection = bibliographyFromCollection;
|
this.bibliographyFromCollection = bibliographyFromCollection;
|
||||||
this.bibliographyFromItems = bibliographyFromItems;
|
this.bibliographyFromItems = bibliographyFromItems;
|
||||||
|
this.copyItemsToClipboard = copyItemsToClipboard;
|
||||||
this.copyCitationToClipboard = copyCitationToClipboard;
|
this.copyCitationToClipboard = copyCitationToClipboard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -407,7 +408,7 @@ var Zotero_File_Interface = new function() {
|
||||||
*
|
*
|
||||||
* Does not check that items are actual references (and not notes or attachments)
|
* Does not check that items are actual references (and not notes or attachments)
|
||||||
*/
|
*/
|
||||||
this.copyItemsToClipboard = Zotero.Promise.coroutine(function* (items, style, locale, asHTML, asCitations) {
|
function copyItemsToClipboard(items, style, locale, asHTML, asCitations) {
|
||||||
// copy to clipboard
|
// copy to clipboard
|
||||||
var transferable = Components.classes["@mozilla.org/widget/transferable;1"].
|
var transferable = Components.classes["@mozilla.org/widget/transferable;1"].
|
||||||
createInstance(Components.interfaces.nsITransferable);
|
createInstance(Components.interfaces.nsITransferable);
|
||||||
|
@ -417,7 +418,7 @@ var Zotero_File_Interface = new function() {
|
||||||
var cslEngine = style.getCiteProc(locale);
|
var cslEngine = style.getCiteProc(locale);
|
||||||
|
|
||||||
// add HTML
|
// add HTML
|
||||||
var bibliography = yield Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, "html", asCitations);
|
var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, "html", asCitations);
|
||||||
var str = Components.classes["@mozilla.org/supports-string;1"].
|
var str = Components.classes["@mozilla.org/supports-string;1"].
|
||||||
createInstance(Components.interfaces.nsISupportsString);
|
createInstance(Components.interfaces.nsISupportsString);
|
||||||
str.data = bibliography;
|
str.data = bibliography;
|
||||||
|
@ -427,7 +428,7 @@ var Zotero_File_Interface = new function() {
|
||||||
// add text (or HTML source)
|
// add text (or HTML source)
|
||||||
if(!asHTML) {
|
if(!asHTML) {
|
||||||
cslEngine = style.getCiteProc(locale);
|
cslEngine = style.getCiteProc(locale);
|
||||||
var bibliography = yield Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, "text", asCitations);
|
var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, "text", asCitations);
|
||||||
}
|
}
|
||||||
var str = Components.classes["@mozilla.org/supports-string;1"].
|
var str = Components.classes["@mozilla.org/supports-string;1"].
|
||||||
createInstance(Components.interfaces.nsISupportsString);
|
createInstance(Components.interfaces.nsISupportsString);
|
||||||
|
@ -436,7 +437,7 @@ var Zotero_File_Interface = new function() {
|
||||||
transferable.setTransferData("text/unicode", str, bibliography.length*2);
|
transferable.setTransferData("text/unicode", str, bibliography.length*2);
|
||||||
|
|
||||||
clipboardService.setData(transferable, null, Components.interfaces.nsIClipboard.kGlobalClipboard);
|
clipboardService.setData(transferable, null, Components.interfaces.nsIClipboard.kGlobalClipboard);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -483,7 +484,7 @@ var Zotero_File_Interface = new function() {
|
||||||
/*
|
/*
|
||||||
* Shows bibliography options and creates a bibliography
|
* Shows bibliography options and creates a bibliography
|
||||||
*/
|
*/
|
||||||
let _doBibliographyOptions = Zotero.Promise.coroutine(function* (name, items) {
|
function _doBibliographyOptions(name, items) {
|
||||||
// make sure at least one item is not a standalone note or attachment
|
// make sure at least one item is not a standalone note or attachment
|
||||||
var haveRegularItem = false;
|
var haveRegularItem = false;
|
||||||
for each(var item in items) {
|
for each(var item in items) {
|
||||||
|
@ -515,12 +516,12 @@ var Zotero_File_Interface = new function() {
|
||||||
// generate bibliography
|
// generate bibliography
|
||||||
try {
|
try {
|
||||||
if(io.method == 'copy-to-clipboard') {
|
if(io.method == 'copy-to-clipboard') {
|
||||||
yield Zotero_File_Interface.copyItemsToClipboard(items, io.style, locale, false, io.mode === "citations");
|
Zotero_File_Interface.copyItemsToClipboard(items, io.style, locale, false, io.mode === "citations");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var style = Zotero.Styles.get(io.style);
|
var style = Zotero.Styles.get(io.style);
|
||||||
var cslEngine = style.getCiteProc(locale);
|
var cslEngine = style.getCiteProc(locale);
|
||||||
var bibliography = yield Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine,
|
var bibliography = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine,
|
||||||
items, format, io.mode === "citations");
|
items, format, io.mode === "citations");
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
@ -598,7 +599,7 @@ var Zotero_File_Interface = new function() {
|
||||||
fStream.close();
|
fStream.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
|
||||||
function _saveBibliography(name, format) {
|
function _saveBibliography(name, format) {
|
||||||
|
|
|
@ -71,9 +71,9 @@ Zotero.Cite = {
|
||||||
* @param {String} format The format of the output (html, text, or rtf)
|
* @param {String} format The format of the output (html, text, or rtf)
|
||||||
* @return {String} Bibliography or item list in specified format
|
* @return {String} Bibliography or item list in specified format
|
||||||
*/
|
*/
|
||||||
"makeFormattedBibliographyOrCitationList":Zotero.Promise.coroutine(function* (cslEngine, items, format, asCitationList) {
|
"makeFormattedBibliographyOrCitationList":function(cslEngine, items, format, asCitationList) {
|
||||||
cslEngine.setOutputFormat(format);
|
cslEngine.setOutputFormat(format);
|
||||||
yield cslEngine.updateItems(items.map(item => item.id));
|
cslEngine.updateItems(items.map(item => item.id));
|
||||||
|
|
||||||
if(!asCitationList) {
|
if(!asCitationList) {
|
||||||
var bibliography = Zotero.Cite.makeFormattedBibliography(cslEngine, format);
|
var bibliography = Zotero.Cite.makeFormattedBibliography(cslEngine, format);
|
||||||
|
@ -84,7 +84,7 @@ Zotero.Cite = {
|
||||||
var citations=[];
|
var citations=[];
|
||||||
for (var i=0, ilen=items.length; i<ilen; i++) {
|
for (var i=0, ilen=items.length; i<ilen; i++) {
|
||||||
var item = items[i];
|
var item = items[i];
|
||||||
var outList = yield cslEngine.appendCitationCluster({"citationItems":[{"id":item.id}], "properties":{}}, true);
|
var outList = cslEngine.appendCitationCluster({"citationItems":[{"id":item.id}], "properties":{}}, true);
|
||||||
for (var j=0, jlen=outList.length; j<jlen; j++) {
|
for (var j=0, jlen=outList.length; j<jlen; j++) {
|
||||||
var citationPos = outList[j][0];
|
var citationPos = outList[j][0];
|
||||||
citations[citationPos] = outList[j][1];
|
citations[citationPos] = outList[j][1];
|
||||||
|
@ -124,7 +124,7 @@ Zotero.Cite = {
|
||||||
return "<\\rtf \n"+citations.join("\\\n")+"\n}";
|
return "<\\rtf \n"+citations.join("\\\n")+"\n}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a formatted bibliography
|
* Makes a formatted bibliography
|
||||||
|
@ -492,45 +492,9 @@ Zotero.Cite.System = function(automaticJournalAbbreviations) {
|
||||||
if(automaticJournalAbbreviations) {
|
if(automaticJournalAbbreviations) {
|
||||||
this.getAbbreviation = Zotero.Cite.getAbbreviation;
|
this.getAbbreviation = Zotero.Cite.getAbbreviation;
|
||||||
}
|
}
|
||||||
this.items = {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.Cite.System.prototype = {
|
Zotero.Cite.System.prototype = {
|
||||||
/**
|
|
||||||
* Asynchronously fetch item and convert to CSL JSON
|
|
||||||
*/
|
|
||||||
"addItem":Zotero.Promise.coroutine(function* (zoteroItem) {
|
|
||||||
if (typeof(zoteroItem) != "object") {
|
|
||||||
if (this.items.hasOwnProperty(zoteroItem)) return;
|
|
||||||
zoteroItem = yield Zotero.Items.getAsync(zoteroItem);
|
|
||||||
}
|
|
||||||
if (this.items.hasOwnProperty(zoteroItem.id)) return;
|
|
||||||
let item = yield Zotero.Utilities.itemToCSLJSON(zoteroItem);
|
|
||||||
item.id = zoteroItem.id;
|
|
||||||
|
|
||||||
if (!Zotero.Prefs.get("export.citePaperJournalArticleURL")) {
|
|
||||||
var itemType = Zotero.ItemTypes.getName(zoteroItem.itemTypeID);
|
|
||||||
// don't return URL or accessed information for journal articles if a
|
|
||||||
// pages field exists
|
|
||||||
if (["journalArticle", "newspaperArticle", "magazineArticle"].indexOf(itemType) !== -1
|
|
||||||
&& item.pages
|
|
||||||
) {
|
|
||||||
delete item.URL;
|
|
||||||
delete item.accessed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.items[item.id] = item;
|
|
||||||
}),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Asynchronously fetch items and convert them to CSL JSON
|
|
||||||
*/
|
|
||||||
"addItems":Zotero.Promise.coroutine(function* (items) {
|
|
||||||
for (let item of items) {
|
|
||||||
yield this.addItem(item);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* citeproc-js system function for getting items
|
* citeproc-js system function for getting items
|
||||||
* See http://gsl-nagoya-u.net/http/pub/citeproc-doc.html#retrieveitem
|
* See http://gsl-nagoya-u.net/http/pub/citeproc-doc.html#retrieveitem
|
||||||
|
@ -538,8 +502,11 @@ Zotero.Cite.System.prototype = {
|
||||||
* @return {Object} citeproc-js item
|
* @return {Object} citeproc-js item
|
||||||
*/
|
*/
|
||||||
"retrieveItem":function retrieveItem(item) {
|
"retrieveItem":function retrieveItem(item) {
|
||||||
let slashIndex;
|
var zoteroItem, slashIndex;
|
||||||
if(typeof item === "string" && (slashIndex = item.indexOf("/")) !== -1) {
|
if(typeof item === "object" && item !== null && item instanceof Zotero.Item) {
|
||||||
|
//if(this._cache[item.id]) return this._cache[item.id];
|
||||||
|
zoteroItem = item;
|
||||||
|
} else if(typeof item === "string" && (slashIndex = item.indexOf("/")) !== -1) {
|
||||||
// is an embedded item
|
// is an embedded item
|
||||||
var sessionID = item.substr(0, slashIndex);
|
var sessionID = item.substr(0, slashIndex);
|
||||||
var session = Zotero.Integration.sessions[sessionID]
|
var session = Zotero.Integration.sessions[sessionID]
|
||||||
|
@ -550,8 +517,37 @@ Zotero.Cite.System.prototype = {
|
||||||
return embeddedCitation;
|
return embeddedCitation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// is an item ID
|
||||||
|
//if(this._cache[item]) return this._cache[item];
|
||||||
|
try {
|
||||||
|
zoteroItem = Zotero.Items.get(item);
|
||||||
|
} catch(e) {}
|
||||||
}
|
}
|
||||||
return this.items[item];
|
|
||||||
|
if(!zoteroItem) {
|
||||||
|
throw "Zotero.Cite.System.retrieveItem called on non-item "+item;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error("Unimplemented");
|
||||||
|
var cslItem = Zotero.Utilities.itemToCSLJSON(zoteroItem);
|
||||||
|
|
||||||
|
// TEMP: citeproc-js currently expects the id property to be the item DB id
|
||||||
|
cslItem.id = zoteroItem.id;
|
||||||
|
|
||||||
|
if (!Zotero.Prefs.get("export.citePaperJournalArticleURL")) {
|
||||||
|
var itemType = Zotero.ItemTypes.getName(zoteroItem.itemTypeID);
|
||||||
|
// don't return URL or accessed information for journal articles if a
|
||||||
|
// pages field exists
|
||||||
|
if (["journalArticle", "newspaperArticle", "magazineArticle"].indexOf(itemType) !== -1
|
||||||
|
&& zoteroItem.getField("pages")
|
||||||
|
) {
|
||||||
|
delete cslItem.URL;
|
||||||
|
delete cslItem.accessed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cslItem;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -579,20 +575,3 @@ Zotero.Cite.System.prototype = {
|
||||||
return str.value;
|
return str.value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Zotero.Cite.AsyncCiteProc = function() {
|
|
||||||
Zotero.CiteProc.CSL.Engine.apply(this, arguments);
|
|
||||||
}
|
|
||||||
Zotero.Cite.AsyncCiteProc.prototype = Object.create(Zotero.CiteProc.CSL.Engine.prototype);
|
|
||||||
Zotero.Cite.AsyncCiteProc.prototype.updateItems = Zotero.Promise.coroutine(function*(items) {
|
|
||||||
yield this.sys.addItems(items);
|
|
||||||
Zotero.CiteProc.CSL.Engine.prototype.updateItems.call(this, items);
|
|
||||||
});
|
|
||||||
Zotero.Cite.AsyncCiteProc.prototype.appendCitationCluster = Zotero.Promise.coroutine(function*(citation, isRegistered) {
|
|
||||||
if (!isRegistered) {
|
|
||||||
for (let citationItem of citation.citationItems) {
|
|
||||||
yield this.sys.addItem(citationItem.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Zotero.CiteProc.CSL.Engine.prototype.appendCitationCluster.call(this, citation, isRegistered);
|
|
||||||
});
|
|
||||||
|
|
|
@ -691,7 +691,7 @@ Zotero.Style.prototype.getCiteProc = function(locale, automaticJournalAbbreviati
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var citeproc = new Zotero.Cite.AsyncCiteProc(
|
var citeproc = new Zotero.CiteProc.CSL.Engine(
|
||||||
new Zotero.Cite.System(automaticJournalAbbreviations),
|
new Zotero.Cite.System(automaticJournalAbbreviations),
|
||||||
xml,
|
xml,
|
||||||
locale,
|
locale,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user