.collectionTreeViewID -> .treeViewID, and add it to Zotero.Item too
Also .collectionTreeViewImage -> .treeViewImage
This commit is contained in:
parent
cb8b2bda1b
commit
53e1e1a9b7
7 changed files with 24 additions and 18 deletions
|
@ -291,13 +291,13 @@ var ZoteroItemPane = new function() {
|
||||||
+ (Zotero.isMac ? '⇧⌘' : Zotero.getString('general.keys.ctrlShift'))
|
+ (Zotero.isMac ? '⇧⌘' : Zotero.getString('general.keys.ctrlShift'))
|
||||||
+ key + ')';
|
+ key + ')';
|
||||||
elem.setAttribute('tooltiptext', tooltip);
|
elem.setAttribute('tooltiptext', tooltip);
|
||||||
elem.setAttribute('image', _translationTarget.collectionTreeViewImage);
|
elem.setAttribute('image', _translationTarget.treeViewImage);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
this.setTranslationTarget = function(translationTarget) {
|
this.setTranslationTarget = function(translationTarget) {
|
||||||
_translationTarget = translationTarget;
|
_translationTarget = translationTarget;
|
||||||
Zotero.Prefs.set('feeds.lastTranslationTarget', translationTarget.collectionTreeViewID);
|
Zotero.Prefs.set('feeds.lastTranslationTarget', translationTarget.treeViewID);
|
||||||
ZoteroItemPane.setTranslateButton();
|
ZoteroItemPane.setTranslateButton();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -83,13 +83,13 @@ Zotero.defineProperty(Zotero.Collection.prototype, 'parent', {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Zotero.defineProperty(Zotero.Collection.prototype, 'collectionTreeViewID', {
|
Zotero.defineProperty(Zotero.Collection.prototype, 'treeViewID', {
|
||||||
get: function () {
|
get: function () {
|
||||||
return "C" + this.id
|
return "C" + this.id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Zotero.defineProperty(Zotero.Collection.prototype, 'collectionTreeViewImage', {
|
Zotero.defineProperty(Zotero.Collection.prototype, 'treeViewImage', {
|
||||||
get: function () {
|
get: function () {
|
||||||
return "chrome://zotero/skin/treesource-collection" + Zotero.hiDPISuffix + ".png";
|
return "chrome://zotero/skin/treesource-collection" + Zotero.hiDPISuffix + ".png";
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,6 +162,12 @@ Zotero.defineProperty(Zotero.Item.prototype, 'relatedItems', {
|
||||||
get: function() this._getRelatedItems()
|
get: function() this._getRelatedItems()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Zotero.defineProperty(Zotero.Item.prototype, 'treeViewID', {
|
||||||
|
get: function () {
|
||||||
|
return this.id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Zotero.Item.prototype.getID = function() {
|
Zotero.Item.prototype.getID = function() {
|
||||||
Zotero.debug('Item.getID() is deprecated -- use Item.id');
|
Zotero.debug('Item.getID() is deprecated -- use Item.id');
|
||||||
return this._id;
|
return this._id;
|
||||||
|
|
|
@ -177,13 +177,13 @@ Zotero.defineProperty(Zotero.Library.prototype, 'name', {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Zotero.defineProperty(Zotero.Library.prototype, 'collectionTreeViewID', {
|
Zotero.defineProperty(Zotero.Library.prototype, 'treeViewID', {
|
||||||
get: function () {
|
get: function () {
|
||||||
return "L" + this._libraryID
|
return "L" + this._libraryID
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Zotero.defineProperty(Zotero.Library.prototype, 'collectionTreeViewImage', {
|
Zotero.defineProperty(Zotero.Library.prototype, 'treeViewImage', {
|
||||||
get: function () {
|
get: function () {
|
||||||
return "chrome://zotero/skin/treesource-library" + Zotero.hiDPISuffix + ".png";
|
return "chrome://zotero/skin/treesource-library" + Zotero.hiDPISuffix + ".png";
|
||||||
}
|
}
|
||||||
|
|
|
@ -961,13 +961,13 @@ Zotero.Utilities.Internal = {
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
var imageSrc = libraryOrCollection.collectionTreeViewImage;
|
var imageSrc = libraryOrCollection.treeViewImage;
|
||||||
|
|
||||||
// Create menuitem for library or collection itself, to be placed either directly in the
|
// Create menuitem for library or collection itself, to be placed either directly in the
|
||||||
// containing menu or as the top item in a submenu
|
// containing menu or as the top item in a submenu
|
||||||
var menuitem = _createMenuitem(
|
var menuitem = _createMenuitem(
|
||||||
libraryOrCollection.name,
|
libraryOrCollection.name,
|
||||||
libraryOrCollection.collectionTreeViewID,
|
libraryOrCollection.treeViewID,
|
||||||
imageSrc,
|
imageSrc,
|
||||||
function (event) {
|
function (event) {
|
||||||
clickAction(event, libraryOrCollection);
|
clickAction(event, libraryOrCollection);
|
||||||
|
@ -990,7 +990,7 @@ Zotero.Utilities.Internal = {
|
||||||
// Otherwise create a submenu for the target's subcollections
|
// Otherwise create a submenu for the target's subcollections
|
||||||
var menu = _createMenu(
|
var menu = _createMenu(
|
||||||
libraryOrCollection.name,
|
libraryOrCollection.name,
|
||||||
libraryOrCollection.collectionTreeViewID,
|
libraryOrCollection.treeViewID,
|
||||||
imageSrc,
|
imageSrc,
|
||||||
function (event) {
|
function (event) {
|
||||||
clickAction(event, libraryOrCollection);
|
clickAction(event, libraryOrCollection);
|
||||||
|
|
|
@ -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* () {
|
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();
|
var win = yield loadBrowserWindow();
|
||||||
|
|
||||||
|
|
|
@ -90,29 +90,29 @@ describe("Zotero.CollectionTreeView", function() {
|
||||||
|
|
||||||
it("should open a library and respect stored container state", function* () {
|
it("should open a library and respect stored container state", function* () {
|
||||||
// Collapse B
|
// Collapse B
|
||||||
yield cv.toggleOpenState(cv.getRowIndexByID(col2.collectionTreeViewID));
|
yield cv.toggleOpenState(cv.getRowIndexByID(col2.treeViewID));
|
||||||
yield cv._rememberOpenStates();
|
yield cv._rememberOpenStates();
|
||||||
|
|
||||||
// Close and reopen library
|
// Close and reopen library
|
||||||
yield cv.toggleOpenState(libraryRow);
|
yield cv.toggleOpenState(libraryRow);
|
||||||
yield cv.expandLibrary(userLibraryID);
|
yield cv.expandLibrary(userLibraryID);
|
||||||
|
|
||||||
assert.ok(cv.getRowIndexByID(col1.collectionTreeViewID))
|
assert.ok(cv.getRowIndexByID(col1.treeViewID))
|
||||||
assert.ok(cv.getRowIndexByID(col2.collectionTreeViewID))
|
assert.ok(cv.getRowIndexByID(col2.treeViewID))
|
||||||
assert.isFalse(cv.getRowIndexByID(col3.collectionTreeViewID))
|
assert.isFalse(cv.getRowIndexByID(col3.treeViewID))
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should open a library and all subcollections in recursive mode", function* () {
|
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();
|
yield cv._rememberOpenStates();
|
||||||
|
|
||||||
// Close and reopen library
|
// Close and reopen library
|
||||||
yield cv.toggleOpenState(libraryRow);
|
yield cv.toggleOpenState(libraryRow);
|
||||||
yield cv.expandLibrary(userLibraryID, true);
|
yield cv.expandLibrary(userLibraryID, true);
|
||||||
|
|
||||||
assert.ok(cv.getRowIndexByID(col1.collectionTreeViewID))
|
assert.ok(cv.getRowIndexByID(col1.treeViewID))
|
||||||
assert.ok(cv.getRowIndexByID(col2.collectionTreeViewID))
|
assert.ok(cv.getRowIndexByID(col2.treeViewID))
|
||||||
assert.ok(cv.getRowIndexByID(col3.collectionTreeViewID))
|
assert.ok(cv.getRowIndexByID(col3.treeViewID))
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue