.collectionTreeViewID -> .treeViewID, and add it to Zotero.Item too

Also .collectionTreeViewImage -> .treeViewImage
This commit is contained in:
Dan Stillman 2016-05-09 12:33:12 -04:00
parent cb8b2bda1b
commit 53e1e1a9b7
7 changed files with 24 additions and 18 deletions

View file

@ -291,13 +291,13 @@ var ZoteroItemPane = new function() {
+ (Zotero.isMac ? '⇧⌘' : Zotero.getString('general.keys.ctrlShift'))
+ key + ')';
elem.setAttribute('tooltiptext', tooltip);
elem.setAttribute('image', _translationTarget.collectionTreeViewImage);
elem.setAttribute('image', _translationTarget.treeViewImage);
};
this.setTranslationTarget = function(translationTarget) {
_translationTarget = translationTarget;
Zotero.Prefs.set('feeds.lastTranslationTarget', translationTarget.collectionTreeViewID);
Zotero.Prefs.set('feeds.lastTranslationTarget', translationTarget.treeViewID);
ZoteroItemPane.setTranslateButton();
};

View file

@ -83,13 +83,13 @@ Zotero.defineProperty(Zotero.Collection.prototype, 'parent', {
}
});
Zotero.defineProperty(Zotero.Collection.prototype, 'collectionTreeViewID', {
Zotero.defineProperty(Zotero.Collection.prototype, 'treeViewID', {
get: function () {
return "C" + this.id
}
});
Zotero.defineProperty(Zotero.Collection.prototype, 'collectionTreeViewImage', {
Zotero.defineProperty(Zotero.Collection.prototype, 'treeViewImage', {
get: function () {
return "chrome://zotero/skin/treesource-collection" + Zotero.hiDPISuffix + ".png";
}

View file

@ -162,6 +162,12 @@ Zotero.defineProperty(Zotero.Item.prototype, 'relatedItems', {
get: function() this._getRelatedItems()
});
Zotero.defineProperty(Zotero.Item.prototype, 'treeViewID', {
get: function () {
return this.id
}
});
Zotero.Item.prototype.getID = function() {
Zotero.debug('Item.getID() is deprecated -- use Item.id');
return this._id;

View file

@ -177,13 +177,13 @@ Zotero.defineProperty(Zotero.Library.prototype, 'name', {
}
});
Zotero.defineProperty(Zotero.Library.prototype, 'collectionTreeViewID', {
Zotero.defineProperty(Zotero.Library.prototype, 'treeViewID', {
get: function () {
return "L" + this._libraryID
}
});
Zotero.defineProperty(Zotero.Library.prototype, 'collectionTreeViewImage', {
Zotero.defineProperty(Zotero.Library.prototype, 'treeViewImage', {
get: function () {
return "chrome://zotero/skin/treesource-library" + Zotero.hiDPISuffix + ".png";
}

View file

@ -961,13 +961,13 @@ Zotero.Utilities.Internal = {
return menu;
}
var imageSrc = libraryOrCollection.collectionTreeViewImage;
var imageSrc = libraryOrCollection.treeViewImage;
// Create menuitem for library or collection itself, to be placed either directly in the
// containing menu or as the top item in a submenu
var menuitem = _createMenuitem(
libraryOrCollection.name,
libraryOrCollection.collectionTreeViewID,
libraryOrCollection.treeViewID,
imageSrc,
function (event) {
clickAction(event, libraryOrCollection);
@ -990,7 +990,7 @@ Zotero.Utilities.Internal = {
// Otherwise create a submenu for the target's subcollections
var menu = _createMenu(
libraryOrCollection.name,
libraryOrCollection.collectionTreeViewID,
libraryOrCollection.treeViewID,
imageSrc,
function (event) {
clickAction(event, libraryOrCollection);

View file

@ -51,7 +51,7 @@ describe("Zotero_Browser", function () {
});
it("should save journal article to My Library if the Zotero pane hasn't been opened yet in a Firefox window", function* () {
Zotero.Prefs.set('lastViewedFolder', collection.collectionTreeViewID);
Zotero.Prefs.set('lastViewedFolder', collection.treeViewID);
var win = yield loadBrowserWindow();

View file

@ -90,29 +90,29 @@ describe("Zotero.CollectionTreeView", function() {
it("should open a library and respect stored container state", function* () {
// Collapse B
yield cv.toggleOpenState(cv.getRowIndexByID(col2.collectionTreeViewID));
yield cv.toggleOpenState(cv.getRowIndexByID(col2.treeViewID));
yield cv._rememberOpenStates();
// Close and reopen library
yield cv.toggleOpenState(libraryRow);
yield cv.expandLibrary(userLibraryID);
assert.ok(cv.getRowIndexByID(col1.collectionTreeViewID))
assert.ok(cv.getRowIndexByID(col2.collectionTreeViewID))
assert.isFalse(cv.getRowIndexByID(col3.collectionTreeViewID))
assert.ok(cv.getRowIndexByID(col1.treeViewID))
assert.ok(cv.getRowIndexByID(col2.treeViewID))
assert.isFalse(cv.getRowIndexByID(col3.treeViewID))
});
it("should open a library and all subcollections in recursive mode", function* () {
yield cv.toggleOpenState(cv.getRowIndexByID(col2.collectionTreeViewID));
yield cv.toggleOpenState(cv.getRowIndexByID(col2.treeViewID));
yield cv._rememberOpenStates();
// Close and reopen library
yield cv.toggleOpenState(libraryRow);
yield cv.expandLibrary(userLibraryID, true);
assert.ok(cv.getRowIndexByID(col1.collectionTreeViewID))
assert.ok(cv.getRowIndexByID(col2.collectionTreeViewID))
assert.ok(cv.getRowIndexByID(col3.collectionTreeViewID))
assert.ok(cv.getRowIndexByID(col1.treeViewID))
assert.ok(cv.getRowIndexByID(col2.treeViewID))
assert.ok(cv.getRowIndexByID(col3.treeViewID))
});
});