From 79efa85482f4f9c1e66102267bfd9d57030e64e7 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 19 Oct 2006 20:35:28 +0000 Subject: [PATCH] - Default to double-field mode in setCreator() if not specified - Allow creator type to be specified as name rather than id in setCreator() - Use object rather than array in getCreator() --- chrome/content/zotero/xpcom/data_access.js | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/chrome/content/zotero/xpcom/data_access.js b/chrome/content/zotero/xpcom/data_access.js index deacaf435..ae2eb048c 100644 --- a/chrome/content/zotero/xpcom/data_access.js +++ b/chrome/content/zotero/xpcom/data_access.js @@ -270,15 +270,21 @@ Zotero.Item.prototype.getCreators = function(){ * Set or update the creator at the specified position * * _orderIndex_: the position of this creator in the item (from 0) - * _fieldMode_: 0 for double-field, 1 for single-field mode + * _creatorTypeID_: id or type name + * _fieldMode_: 0 for double-field, 1 for single-field mode (default 0) * - * If single-field mode, _firstName_ is ignored + * If fieldMode==1, _firstName_ is ignored */ Zotero.Item.prototype.setCreator = function(orderIndex, firstName, lastName, creatorTypeID, fieldMode){ if (this.getID() && !this._creatorsLoaded){ this._loadCreators(); } + // Default to double-field mode if not specified + if (!fieldMode){ + fieldMode = 0; + } + if (fieldMode==1 || !firstName){ firstName = ''; } @@ -287,6 +293,8 @@ Zotero.Item.prototype.setCreator = function(orderIndex, firstName, lastName, cre lastName = ''; } + creatorTypeID = Zotero.CreatorTypes.getID(creatorTypeID); + // If creator at this position hasn't changed, cancel if (this._creators.has(orderIndex) && this._creators.get(orderIndex)['firstName']==firstName && @@ -1746,11 +1754,12 @@ Zotero.Item.prototype._loadCreators = function(){ this._creators = new Zotero.Hash(); for (var i=0; i