From 86fa29bf140d9fa63d4f22f5bbefdb91cb3911bd Mon Sep 17 00:00:00 2001 From: Will S Date: Wed, 14 Dec 2011 19:59:57 -0500 Subject: [PATCH] Same functionality as previous commit, but newlines now parsed in tagsbox.xml instead of addTag() function, just like creator newlines are parsed in itembox.xml --- chrome/content/zotero/bindings/tagsbox.xml | 17 +++++++++++++++-- chrome/content/zotero/xpcom/data/item.js | 10 ---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/chrome/content/zotero/bindings/tagsbox.xml b/chrome/content/zotero/bindings/tagsbox.xml index eba3b99f5..771766514 100644 --- a/chrome/content/zotero/bindings/tagsbox.xml +++ b/chrome/content/zotero/bindings/tagsbox.xml @@ -430,8 +430,10 @@ // Tag id encoded as 'tag-1234' var id = row.getAttribute('id').split('-')[1]; + var newlinePresent = (value.search('\r') > -1 || value.search('\n') > -1); + if (saveChanges) { - if (id) { + if (id && newlinePresent != true) { if (value) { // If trying to replace with another existing tag // (which causes a delete of the row), @@ -453,7 +455,18 @@ } // New tag else { - var id = tagsbox.add(value); + //Check for newlines or carriage returns used as delimiters + //in a series of tags added at once. Add each tag + //separately. + if (newlinePresent) { + value = value.replace('\r\n','\n'); + value = value.replace('\r','\n'); + var nameArray = value.split('\n'); + id = this.item.addTags(nameArray); + } + else { + id = tagsbox.add(value); + } if (!id) { this._lastTabIndex--; } diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 90609b8a2..263215ca9 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -3478,16 +3478,6 @@ Zotero.Item.prototype.addTag = function(name, type) { if (!this.id) { throw ('Cannot add tag to unsaved item in Item.addTag()'); } - - //Check for newlines or carriage returns used as delimiters - //in a series of tags added at once. Add each tag - //separately. - if (name.search('\r') > -1 || name.search('\n') > -1) { - name = name.replace('\r\n','\n'); - name = name.replace('\r','\n'); - var nameArray = name.split('\n'); - return this.addTags(nameArray,type); - } name = Zotero.Utilities.trim(name);