From a7b1cc1046fde66e040e996635b7c610629755d9 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Tue, 29 Mar 2011 01:16:02 +0000 Subject: [PATCH] fix citations appearing after a bibliography --- chrome/content/zotero/xpcom/integration.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index ccb49c24d..bec9cda80 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -917,6 +917,7 @@ Zotero.Integration.Document.prototype._updateSession = function(newField, editFi } } else if(fieldCode == "TEMP") { if(newField) { + Zotero.debug("Edit Field index "+i); editFieldIndex = i; editField = field; } else { @@ -995,13 +996,14 @@ Zotero.Integration.Document.prototype._updateDocument = function(forceCitations, this._session.updateUpdateIndices(forceCitations); var deleteCitations = this._session.updateCitations(); this._deleteFields = this._deleteFields.concat([i for(i in deleteCitations)]); + Zotero.debug(this._session.updateIndices); for(var i in this._session.updateIndices) { - citation = this._session.citationsByIndex[i]; + var citation = this._session.citationsByIndex[i]; if(!citation || deleteCitations[i]) continue; var fieldCode = this._session.getCitationField(citation); if(fieldCode != citation.properties.field) { - this._fields[citation.properties.index].setCode(ITEM_CODE+" "+fieldCode); + this._fields[i].setCode(ITEM_CODE+" "+fieldCode); } if(citation.properties.custom) { @@ -1012,10 +1014,10 @@ Zotero.Integration.Document.prototype._updateDocument = function(forceCitations, if(citationText.indexOf("\\") !== -1) { // need to set text as RTF - this._fields[citation.properties.index].setText("{\\rtf "+citationText+"}", true); + this._fields[i].setText("{\\rtf "+citationText+"}", true); } else { // set text as plain - this._fields[citation.properties.index].setText(citationText, false); + this._fields[i].setText(citationText, false); } } @@ -1493,7 +1495,7 @@ Zotero.Integration.Session.prototype.addCitation = function(index, noteIndex, ar } citation.properties.added = true; - citation.properties.index = index; + citation.properties.zoteroIndex = index; citation.properties.noteIndex = noteIndex; this.citationsByIndex[index] = citation; @@ -1505,12 +1507,12 @@ Zotero.Integration.Session.prototype.addCitation = function(index, noteIndex, ar this.bibliographyHasChanged = true; } else { var byItemID = this.citationsByItemID[citationItem.id]; - if(byItemID[byItemID.length-1].properties.index < index) { + if(byItemID[byItemID.length-1].properties.zoteroIndex < index) { // if index is greater than the last index, add to end byItemID.push(citation); } else { // otherwise, splice in at appropriate location - for(var j=0; byItemID[j].properties.index < index && j