fx-compat: Item box: Fix item type menulist
- Use IDs as list item values - Use addEventListener() so events are actually received - Put menulist inside <td> * This causes a small appearance regression at the moment because <td> margins/padding are a bit off, but that issue is visible on all other fields already.
This commit is contained in:
parent
c2ce5c7596
commit
3566d1fc1f
2 changed files with 12 additions and 10 deletions
|
@ -752,26 +752,28 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
addItemTypeMenu() {
|
addItemTypeMenu() {
|
||||||
|
var td = document.createElement('td');
|
||||||
var menulist = document.createXULElement("menulist", { is: "menulist-item-types" });
|
var menulist = document.createXULElement("menulist", { is: "menulist-item-types" });
|
||||||
menulist.id = "item-type-menu";
|
menulist.id = "item-type-menu";
|
||||||
menulist.className = "zotero-clicky";
|
menulist.className = "zotero-clicky";
|
||||||
menulist.onCommand = (event) => {
|
menulist.addEventListener('command', (event) => {
|
||||||
var target = event.target;
|
var target = event.target;
|
||||||
this.changeTypeTo(target.value, target);
|
this.changeTypeTo(target.value, target);
|
||||||
};
|
});
|
||||||
menulist.onFocus = (event) => {
|
menulist.addEventListener('focus', () => {
|
||||||
this.ensureElementIsVisible(menulist);
|
this.ensureElementIsVisible(menulist);
|
||||||
};
|
});
|
||||||
menulist.onKeyPress = (event) => {
|
menulist.addEventListener('keypress', (event) => {
|
||||||
if (event.keyCode == event.DOM_VK_TAB) {
|
if (event.keyCode == event.DOM_VK_TAB) {
|
||||||
this.itemTypeMenuTab(event);
|
this.itemTypeMenuTab(event);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
this._infoTable.firstChild.appendChild(menulist);
|
td.appendChild(menulist);
|
||||||
|
this._infoTable.firstChild.appendChild(td);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateItemTypeMenuSelection() {
|
updateItemTypeMenuSelection() {
|
||||||
this.itemTypeMenu.value = this.item.itemType;
|
this.itemTypeMenu.value = this.item.itemTypeID;
|
||||||
}
|
}
|
||||||
|
|
||||||
addDynamicRow(label, value, beforeElement) {
|
addDynamicRow(label, value, beforeElement) {
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
var itemTypes = [];
|
var itemTypes = [];
|
||||||
for (let i = 0; i < t.length; i++) {
|
for (let i = 0; i < t.length; i++) {
|
||||||
itemTypes.push({
|
itemTypes.push({
|
||||||
name: t[i].name,
|
id: t[i].id,
|
||||||
localized: Zotero.ItemTypes.getLocalizedString(t[i].id)
|
localized: Zotero.ItemTypes.getLocalizedString(t[i].id)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
for (let i = 0; i < itemTypes.length; i++) {
|
for (let i = 0; i < itemTypes.length; i++) {
|
||||||
let name = itemTypes[i].name;
|
let name = itemTypes[i].name;
|
||||||
if (name != 'attachment' && name != 'note' && name != 'annotation') {
|
if (name != 'attachment' && name != 'note' && name != 'annotation') {
|
||||||
this.appendItem(itemTypes[i].localized, itemTypes[i].name);
|
this.appendItem(itemTypes[i].localized, itemTypes[i].id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue