diff --git a/chrome/content/zotero/itemPane.js b/chrome/content/zotero/itemPane.js index e33a97f1b2..eb7a599b5f 100644 --- a/chrome/content/zotero/itemPane.js +++ b/chrome/content/zotero/itemPane.js @@ -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(); }; diff --git a/chrome/content/zotero/xpcom/data/collection.js b/chrome/content/zotero/xpcom/data/collection.js index 1e53b1a2ba..04fefe09a5 100644 --- a/chrome/content/zotero/xpcom/data/collection.js +++ b/chrome/content/zotero/xpcom/data/collection.js @@ -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"; } diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 9d464c43e1..9164ebbb2c 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -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; diff --git a/chrome/content/zotero/xpcom/data/library.js b/chrome/content/zotero/xpcom/data/library.js index 42136fc703..12102efd42 100644 --- a/chrome/content/zotero/xpcom/data/library.js +++ b/chrome/content/zotero/xpcom/data/library.js @@ -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"; } diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index e0ccde01fd..cc3fc7184e 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -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); diff --git a/test/tests/browserTest.js b/test/tests/browserTest.js index 8aadad95ce..183ba5dccd 100644 --- a/test/tests/browserTest.js +++ b/test/tests/browserTest.js @@ -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(); diff --git a/test/tests/collectionTreeViewTest.js b/test/tests/collectionTreeViewTest.js index 54da165b63..a955d560a0 100644 --- a/test/tests/collectionTreeViewTest.js +++ b/test/tests/collectionTreeViewTest.js @@ -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)) }); });