www

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

commit 0ce329abd1e972b80fc460554b751ee41ada4a87
parent f4804b66b588b0b4d16a233cd2c5e462ff07fcb5
Author: Simon Kornblith <simon@simonster.com>
Date:   Sun, 29 Jan 2012 11:57:49 -0500

Merge branch '3.0'

Diffstat:
Mchrome/content/zotero/integration/editBibliographyDialog.js | 2+-
Mchrome/content/zotero/preferences/preferences.js | 10++++++++++
Mchrome/content/zotero/standalone/standalone.js | 5+++--
Mchrome/content/zotero/xpcom/citeproc.js | 36+++++++++++++++++++-----------------
Mchrome/content/zotero/xpcom/integration.js | 63+++++++++++++++++++++++++++++++++++----------------------------
5 files changed, 68 insertions(+), 48 deletions(-)

diff --git a/chrome/content/zotero/integration/editBibliographyDialog.js b/chrome/content/zotero/integration/editBibliographyDialog.js @@ -302,7 +302,7 @@ var Zotero_Bibliography_Dialog = new function () { */ function _loadItems() { var itemIDs = bibEditInterface.bibliography[0].entry_ids; - var items = Zotero.Items.get(itemIDs); + var items = [Zotero.Cite.getItem(itemID[0]) for each(itemID in itemIDs)]; // delete all existing items from list var itemList = document.getElementById("item-list"); diff --git a/chrome/content/zotero/preferences/preferences.js b/chrome/content/zotero/preferences/preferences.js @@ -74,6 +74,16 @@ var Zotero_Preferences = { function init() { + if(Zotero.isConnector) { + Zotero.activateStandalone(); + window.close(); + return; + } + + observerService.addObserver(function() { + if(Zotero.isConnector) window.close(); + }, "zotero-reloaded", false); + // Display the appropriate modifier keys for the platform var rows = document.getElementById('zotero-prefpane-keys').getElementsByTagName('row'); for (var i=0; i<rows.length; i++) { diff --git a/chrome/content/zotero/standalone/standalone.js b/chrome/content/zotero/standalone/standalone.js @@ -42,7 +42,7 @@ const ZoteroStandalone = new function() { ZoteroPane.makeVisible(); // Run check for corrupt installation, where the wrong Gecko runtime is being used - if(Zotero.isMac) { + if(Zotero.isMac && Zotero.isStandalone) { var greDir = Components.classes["@mozilla.org/file/directory_service;1"] .getService(Components.interfaces.nsIProperties) .get("GreD", Components.interfaces.nsIFile); @@ -65,7 +65,8 @@ const ZoteroStandalone = new function() { hs.store(handlerInfo); } - // Add add-on listeners (not yet hooked up)Services.obs.addObserver(gXPInstallObserver, "addon-install-disabled", false); + // Add add-on listeners (not yet hooked up) + Services.obs.addObserver(gXPInstallObserver, "addon-install-disabled", false); Services.obs.addObserver(gXPInstallObserver, "addon-install-started", false); Services.obs.addObserver(gXPInstallObserver, "addon-install-blocked", false); Services.obs.addObserver(gXPInstallObserver, "addon-install-failed", false); diff --git a/chrome/content/zotero/xpcom/citeproc.js b/chrome/content/zotero/xpcom/citeproc.js @@ -1989,7 +1989,7 @@ CSL.DateParser = function () { }; CSL.Engine = function (sys, style, lang, forceLang) { var attrs, langspec, localexml, locale; - this.processor_version = "1.0.268"; + this.processor_version = "1.0.269"; this.csl_version = "1.0"; this.sys = sys; this.sys.xml = new CSL.System.Xml.Parsing(); @@ -6605,25 +6605,27 @@ CSL.evaluateLabel = function (node, state, Item, item) { } else { myterm = node.strings.term; } - var plural = 0; - if ("locator" === node.strings.term) { - if (item && item.locator) { - if (state.opt.development_extensions.locator_parsing_for_plurals) { - if (!state.tmp.shadow_numbers.locator) { - state.processNumber(false, item, "locator"); + var plural = node.strings.plural; + if ("number" !== typeof plural) { + if ("locator" === node.strings.term) { + if (item && item.locator) { + if (state.opt.development_extensions.locator_parsing_for_plurals) { + if (!state.tmp.shadow_numbers.locator) { + state.processNumber(false, item, "locator"); + } + plural = state.tmp.shadow_numbers.locator.plural; + } else { + plural = CSL.evaluateStringPluralism(item.locator); } - plural = state.tmp.shadow_numbers.locator.plural; - } else { - plural = CSL.evaluateStringPluralism(item.locator); } + } else if (["page", "page-first"].indexOf(node.variables[0]) > -1) { + plural = CSL.evaluateStringPluralism(Item[myterm]); + } else { + if (!state.tmp.shadow_numbers[myterm]) { + state.processNumber(false, Item, myterm); + } + plural = state.tmp.shadow_numbers[myterm].plural; } - } else if (["page", "page-first"].indexOf(node.variables[0]) > -1) { - plural = CSL.evaluateStringPluralism(Item[myterm]); - } else { - if (!state.tmp.shadow_numbers[myterm]) { - state.processNumber(false, Item, myterm); - } - plural = state.tmp.shadow_numbers[myterm].plural; } return CSL.castLabel(state, node, myterm, plural); }; diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js @@ -1579,7 +1579,7 @@ Zotero.Integration.Session = function(doc) { this.omittedItems = {}; this.embeddedItems = {}; this.embeddedZoteroItems = {}; - this.embeddedItemsByURI = {}; + this.embeddedZoteroItemsByURI = {}; this.customBibliographyText = {}; this.reselectedItems = {}; this.resetRequest(doc); @@ -1613,9 +1613,9 @@ Zotero.Integration.Session.prototype.resetRequest = function(doc) { * @param data {Zotero.Integration.DocumentData} */ Zotero.Integration.Session.prototype.setData = function(data) { - var oldStyleID = (this.data && this.data.style.styleID ? this.data.style.styleID : false); + var oldStyle = (this.data && this.data.style ? this.data.style : false); this.data = data; - if(data.style.styleID && oldStyleID != data.style.styleID) { + if(data.style.styleID && (!oldStyle || oldStyle.styleID != data.style.styleID)) { this.styleID = data.style.styleID; try { var getStyle = Zotero.Styles.get(data.style.styleID); @@ -1631,6 +1631,8 @@ Zotero.Integration.Session.prototype.setData = function(data) { } return true; + } else if(oldStyle) { + data.style = oldStyle; } return false; } @@ -1900,37 +1902,25 @@ Zotero.Integration.Session.prototype.lookupItems = function(citation, index) { } if(!zoteroItem) { - // check embedded items - if(citationItem.uris) { - var success = false; - for(var j=0, m=citationItem.uris.length; j<m; j++) { - var embeddedItem = this.embeddedItemsByURI[citationItem.uris[j]]; - if(embeddedItem) { - citationItem.id = embeddedItem.id; - success = true; - break; - } - } - if(success) continue; - } - if(citationItem.itemData) { // add new embedded item var itemData = Zotero.Utilities.deepCopy(citationItem.itemData); - for(var j=0, m=citationItem.uris.length; j<m; j++) { - this.embeddedItemsByURI[citationItem.uris[j]] = itemData; - } // assign a random string as an item ID var anonymousID = Zotero.randomString(); var globalID = itemData.id = citationItem.id = this.data.sessionID+"/"+anonymousID; this.embeddedItems[anonymousID] = itemData; + // assign a Zotero item var surrogateItem = this.embeddedZoteroItems[anonymousID] = new Zotero.Item(); Zotero.Utilities.itemFromCSLJSON(surrogateItem, itemData); surrogateItem.cslItemID = globalID; surrogateItem.cslURIs = citationItem.uris; surrogateItem.cslItemData = itemData; + + for(var j=0, m=citationItem.uris.length; j<m; j++) { + this.embeddedZoteroItemsByURI[citationItem.uris[j]] = surrogateItem; + } } else { // if not already reselected, throw a MissingItemException throw(new Zotero.Integration.MissingItemException( @@ -1940,7 +1930,7 @@ Zotero.Integration.Session.prototype.lookupItems = function(citation, index) { } if(zoteroItem) { - citationItem.id = zoteroItem.id; + citationItem.id = zoteroItem.cslItemID ? zoteroItem.cslItemID : zoteroItem.id; } } } @@ -2297,8 +2287,9 @@ Zotero.Integration.Session.prototype.loadBibliographyData = function(json) { let zoteroItem, needUpdate; for each(var uris in documentData.uncited) { [zoteroItem, needUpdate] = this.uriMap.getZoteroItemForURIs(uris); - if(zoteroItem && !this.citationsByItemID[zoteroItem.id]) { - this.uncitedItems[zoteroItem.id] = true; + var id = zoteroItem.cslItemID ? zoteroItem.cslItemID : zoteroItem.id; + if(zoteroItem && !this.citationsByItemID[id]) { + this.uncitedItems[id] = true; } else { needUpdate = true; } @@ -2327,8 +2318,9 @@ Zotero.Integration.Session.prototype.loadBibliographyData = function(json) { if(!zoteroItem) continue; if(needUpdate) this.bibliographyDataHasChanged = true; - if(this.citationsByItemID[zoteroItem.id] || this.uncitedItems[zoteroItem.id]) { - this.customBibliographyText[zoteroItem.id] = custom[1]; + var id = zoteroItem.cslItemID ? zoteroItem.cslItemID : zoteroItem.id; + if(this.citationsByItemID[id] || this.uncitedItems[id]) { + this.customBibliographyText[id] = custom[1]; } } } else { @@ -2351,8 +2343,9 @@ Zotero.Integration.Session.prototype.loadBibliographyData = function(json) { let zoteroItem, needUpdate; for each(var uris in documentData.omitted) { [zoteroItem, update] = this.uriMap.getZoteroItemForURIs(uris); - if(zoteroItem && this.citationsByItemID[zoteroItem.id]) { - this.omittedItems[zoteroItem.id] = true; + var id = zoteroItem.cslItemID ? zoteroItem.cslItemID : zoteroItem.id; + if(zoteroItem && this.citationsByItemID[id]) { + this.omittedItems[id] = true; } else { needUpdate = true; } @@ -2669,9 +2662,14 @@ Zotero.Integration.URIMap.prototype.add = function(id, uris) { * Gets URIs for a given item ID, and adds to map */ Zotero.Integration.URIMap.prototype.getURIsForItemID = function(id) { + if(typeof id === "string" && id.indexOf("/") !== -1) { + return Zotero.Cite.getItem(id).cslURIs; + } + if(!this.itemIDURIs[id]) { this.itemIDURIs[id] = [Zotero.URI.getItemURI(Zotero.Items.get(id))]; } + return this.itemIDURIs[id]; } @@ -2681,10 +2679,17 @@ Zotero.Integration.URIMap.prototype.getURIsForItemID = function(id) { Zotero.Integration.URIMap.prototype.getZoteroItemForURIs = function(uris) { var zoteroItem = false; var needUpdate = false; + var embeddedItem = false;; for(var i=0, n=uris.length; i<n; i++) { - // Try getting URI directly var uri = uris[i]; + + // First try embedded URI + if(this.session.embeddedZoteroItemsByURI[uri]) { + embeddedItem = this.session.embeddedZoteroItemsByURI[uri]; + } + + // Next try getting URI directly try { zoteroItem = Zotero.URI.getURIItem(uri); if(zoteroItem) { @@ -2743,6 +2748,8 @@ Zotero.Integration.URIMap.prototype.getZoteroItemForURIs = function(uris) { } // cache uris this.itemIDURIs[zoteroItem.id] = uris; + } else if(embeddedItem) { + return [embeddedItem, false]; } return [zoteroItem, needUpdate];