commit 4657c46d4b46d8224bd9837734a7bce993539dd1
parent c222a3248a94827a9c18d4c55a490acf66ba4ebc
Author: Aurimas Vinckevicius <aurimas.dev@gmail.com>
Date: Fri, 14 Nov 2014 02:34:15 -0600
getClassForObjectType => getObjectsClassForObjectType
Diffstat:
4 files changed, 10 insertions(+), 13 deletions(-)
diff --git 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
@@ -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
@@ -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
@@ -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('_')) {