diff --git a/chrome/content/zotero/xpcom/api.js b/chrome/content/zotero/xpcom/api.js index 2a38a569bd..a732c78001 100644 --- a/chrome/content/zotero/xpcom/api.js +++ b/chrome/content/zotero/xpcom/api.js @@ -201,7 +201,7 @@ Zotero.API.Data = { var params = this.parsePath(path); //Zotero.debug(params); - return Zotero.DataObjectUtilities.getClassForObjectType(params.objectType) + return Zotero.DataObjectUtilities.getObjectsClassForObjectType(params.objectType) .apiDataGenerator(params); } }; diff --git a/chrome/content/zotero/xpcom/data/dataObject.js b/chrome/content/zotero/xpcom/data/dataObject.js index 8452e9e0a3..092f554617 100644 --- a/chrome/content/zotero/xpcom/data/dataObject.js +++ b/chrome/content/zotero/xpcom/data/dataObject.js @@ -70,6 +70,10 @@ Zotero.defineProperty(Zotero.DataObject.prototype, 'parentID', { set: function(v) this._setParentID(v) }); +Zotero.defineProperty(Zotero.DataObject.prototype, 'ObjectsClass', { + get: function() Zotero.DataObjectUtilities.getObjectsClassForObjectType(this.objectType) +}); + Zotero.DataObject.prototype._get = function (field) { if (this['_' + field] !== null) { @@ -135,7 +139,7 @@ Zotero.DataObject.prototype._getParentID = function () { if (!this._parentKey) { return false; } - return this._parentID = this._getClass().getIDFromLibraryAndKey(this._libraryID, this._parentKey); + return this._parentID = this.ObjectsClass.getIDFromLibraryAndKey(this._libraryID, this._parentKey); } @@ -148,7 +152,7 @@ Zotero.DataObject.prototype._getParentID = function () { Zotero.DataObject.prototype._setParentID = function (id) { return this._setParentKey( id - ? this._getClass().getLibraryAndKeyFromID(Zotero.DataObjectUtilities.checkDataID(id))[1] + ? this.ObjectsClass.getLibraryAndKeyFromID(Zotero.DataObjectUtilities.checkDataID(id))[1] : null ); } @@ -368,13 +372,6 @@ Zotero.DataObject.prototype._requireData = function (dataType) { } } -/** - * Returns a global Zotero class object given a data object. (e.g. Zotero.Items) - * @return {obj} One of Zotero data classes - */ -Zotero.DataObject.prototype._getClass = function () { - return Zotero.DataObjectUtilities.getClassForObjectType(this._objectType); -} /** * Loads data for a given data type diff --git a/chrome/content/zotero/xpcom/data/dataObjectUtilities.js b/chrome/content/zotero/xpcom/data/dataObjectUtilities.js index 854419f439..fa70c0b9c0 100644 --- a/chrome/content/zotero/xpcom/data/dataObjectUtilities.js +++ b/chrome/content/zotero/xpcom/data/dataObjectUtilities.js @@ -59,12 +59,12 @@ Zotero.DataObjectUtilities = { }, - "getObjectTypePlural": function getObjectTypePlural(objectType) { + "getObjectTypePlural": function(objectType) { return objectType == 'search' ? 'searches' : objectType + 's'; }, - "getClassForObjectType": function getClassForObjectType(objectType) { + "getObjectsClassForObjectType": function(objectType) { var objectTypePlural = this.getObjectTypePlural(objectType); var className = objectTypePlural[0].toUpperCase() + objectTypePlural.substr(1); return Zotero[className] diff --git a/chrome/content/zotero/xpcom/search.js b/chrome/content/zotero/xpcom/search.js index 4a81d05c8c..ad60732603 100644 --- a/chrome/content/zotero/xpcom/search.js +++ b/chrome/content/zotero/xpcom/search.js @@ -1201,7 +1201,7 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () { let objLibraryID; let objKey = condition.value; let objectType = condition.name == 'collection' ? 'collection' : 'search'; - let objectTypeClass = Zotero.DataObjectUtilities.getClassForObjectType(objectType); + let objectTypeClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(objectType); // Old-style library-key hash if (objKey.contains('_')) {