parent
9a23031c12
commit
bc47ee46c8
3 changed files with 37 additions and 22 deletions
|
@ -254,19 +254,12 @@
|
|||
* Display buttons at top of item pane depending on context
|
||||
*/
|
||||
updateItemPaneButtons() {
|
||||
let container;
|
||||
let container = this.getCurrentPane();
|
||||
|
||||
if (!this.data.length) {
|
||||
container.renderCustomHead();
|
||||
return;
|
||||
}
|
||||
else if (this.data.length > 1) {
|
||||
container = this._messagePane;
|
||||
}
|
||||
else if (this.data[0].isNote()) {
|
||||
container = this._noteEditor;
|
||||
}
|
||||
else {
|
||||
container = this._itemDetails;
|
||||
}
|
||||
|
||||
// My Publications buttons
|
||||
var isPublications = this.collectionTreeRow.isPublications();
|
||||
|
@ -303,7 +296,7 @@
|
|||
renderPublicationsHead(data) {
|
||||
let { doc, append } = data;
|
||||
let button = doc.createXULElement("button");
|
||||
button.id = 'zotero-item-pane-my-publications-button';
|
||||
button.classList.add('item-pane-my-publications-button');
|
||||
|
||||
let hiddenItemsSelected = this.data.some(item => !item.inPublications);
|
||||
let str, onclick;
|
||||
|
@ -323,14 +316,14 @@
|
|||
renderTrashHead(data) {
|
||||
let { doc, append } = data;
|
||||
let restoreButton = doc.createXULElement("button");
|
||||
restoreButton.id = "zotero-item-restore-button";
|
||||
restoreButton.classList.add("item-restore-button");
|
||||
restoreButton.dataset.l10nId = "menu-restoreToLibrary";
|
||||
restoreButton.addEventListener("command", () => {
|
||||
ZoteroPane.restoreSelectedItems();
|
||||
});
|
||||
|
||||
let deleteButton = doc.createXULElement("button");
|
||||
deleteButton.id = "zotero-item-delete-button";
|
||||
deleteButton.classList.add("item-delete-button");
|
||||
deleteButton.dataset.l10nId = "menu-deletePermanently";
|
||||
deleteButton.addEventListener("command", () => {
|
||||
ZoteroPane.deleteSelectedItems();
|
||||
|
@ -343,13 +336,13 @@
|
|||
let { doc, append } = data;
|
||||
|
||||
let toggleReadButton = doc.createXULElement("button");
|
||||
toggleReadButton.id = "zotero-feed-item-toggleRead-button";
|
||||
toggleReadButton.classList.add("feed-item-toggleRead-button");
|
||||
toggleReadButton.addEventListener("command", () => {
|
||||
ZoteroPane.toggleSelectedItemsRead();
|
||||
});
|
||||
|
||||
let addToButton = document.createElement("button", { is: "split-menu-button" });
|
||||
addToButton.id = "zotero-feed-item-addTo-button";
|
||||
addToButton.classList.add("feed-item-addTo-button");
|
||||
addToButton.setAttribute("popup", "zotero-item-addTo-menu");
|
||||
addToButton.addEventListener("command", () => this.translateSelectedItems());
|
||||
|
||||
|
@ -371,7 +364,7 @@
|
|||
}
|
||||
|
||||
setReadLabel(isRead) {
|
||||
var elem = document.getElementById('zotero-feed-item-toggleRead-button');
|
||||
var elem = this.getCurrentPane().querySelector('.feed-item-toggleRead-button');
|
||||
var label = Zotero.getString('pane.item.' + (isRead ? 'markAsUnread' : 'markAsRead'));
|
||||
elem.label = label;
|
||||
|
||||
|
@ -389,7 +382,7 @@
|
|||
}
|
||||
|
||||
buildTranslateSelectContextMenu(event) {
|
||||
var menu = document.getElementById('zotero-item-addTo-menu');
|
||||
var menu = document.querySelector('#zotero-item-addTo-menu');
|
||||
// Don't trigger rebuilding on nested popupmenu open/close
|
||||
if (event.target != menu) {
|
||||
return;
|
||||
|
@ -442,7 +435,7 @@
|
|||
setTranslateButton() {
|
||||
if (!this._translationTarget) return;
|
||||
var label = Zotero.getString('pane.item.addTo', this._translationTarget.name);
|
||||
var elem = document.getElementById('zotero-feed-item-addTo-button');
|
||||
var elem = this.getCurrentPane().querySelector('.feed-item-addTo-button');
|
||||
elem.label = label;
|
||||
|
||||
var key = Zotero.Keys.getKeyForCommand('saveToZotero');
|
||||
|
@ -461,6 +454,28 @@
|
|||
this.setTranslateButton();
|
||||
}
|
||||
|
||||
getCurrentPane(mode = undefined) {
|
||||
if (!mode) {
|
||||
// Guess a mode from the current data
|
||||
if (!this.data.length || this.data.length > 1) {
|
||||
mode = "message";
|
||||
}
|
||||
else if (this.data[0].isNote()) {
|
||||
mode = "note";
|
||||
}
|
||||
else {
|
||||
mode = "item";
|
||||
}
|
||||
}
|
||||
let map = {
|
||||
message: "_messagePane",
|
||||
item: "_itemDetails",
|
||||
note: "_noteEditor",
|
||||
duplicates: "_duplicatesPane",
|
||||
};
|
||||
return this[map[mode]];
|
||||
}
|
||||
|
||||
static get observedAttributes() {
|
||||
return ['collapsed', 'width', 'height', 'view-type'];
|
||||
}
|
||||
|
|
|
@ -1145,12 +1145,12 @@ describe("Item pane", function () {
|
|||
item.isRead = true;
|
||||
yield item.saveTx();
|
||||
|
||||
let button = doc.getElementById('zotero-feed-item-toggleRead-button');
|
||||
let button = ZoteroPane.itemPane.getCurrentPane().querySelector('.feed-item-toggleRead-button');
|
||||
|
||||
assert.equal(button.label, Zotero.getString('pane.item.markAsUnread'));
|
||||
yield item.toggleRead(false);
|
||||
// Button is re-created
|
||||
button = doc.getElementById('zotero-feed-item-toggleRead-button');
|
||||
button = ZoteroPane.itemPane.getCurrentPane().querySelector('.feed-item-toggleRead-button');
|
||||
assert.equal(button.label, Zotero.getString('pane.item.markAsRead'));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -856,7 +856,7 @@ describe("Zotero.ItemTree", function() {
|
|||
yield itemsView.selectItem(attachment.id);
|
||||
yield Zotero.Promise.delay();
|
||||
|
||||
var box = win.document.getElementById('zotero-item-pane-my-publications-button');
|
||||
var box = zp.itemPane.getCurrentPane().querySelector('.item-pane-my-publications-button');
|
||||
assert.isFalse(box.hidden);
|
||||
});
|
||||
|
||||
|
@ -872,7 +872,7 @@ describe("Zotero.ItemTree", function() {
|
|||
|
||||
yield itemsView.selectItem(attachment.id);
|
||||
|
||||
var box = win.document.getElementById('zotero-item-pane-my-publications-button');
|
||||
var box = zp.itemPane.getCurrentPane().querySelector('.item-pane-my-publications-button');
|
||||
// box is not created if it shouldn't show
|
||||
assert.isNull(box);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue