Make "New Note" shortcut key context sensitive

- If a regular item is selected, use that as the parent.
- If a child item is selected, use its parent as the parent.
- Otherwise create a standalone note.
This commit is contained in:
Dan Stillman 2012-04-16 04:01:36 -04:00
parent 2327c5cc98
commit 1c7ac1a9a0

View file

@ -566,8 +566,23 @@ var ZoteroPane = new function()
document.getElementById('zotero-editpane-item-box').itemTypeMenu.menupopup.openPopup(menu, "before_start", 0, 0);
break;
case 'newNote':
// If a regular item is selected, use that as the parent.
// If a child item is selected, use its parent as the parent.
// Otherwise create a standalone note.
var parent = false;
var items = ZoteroPane_Local.getSelectedItems();
if (items.length == 1) {
if (items[0].isRegularItem()) {
parent = items[0].id;
}
else {
parent = items[0].getSource();
}
}
// Use key that's not the modifier as the popup toggle
ZoteroPane_Local.newNote(useShift ? event.altKey : event.shiftKey);
ZoteroPane_Local.newNote(
useShift ? event.altKey : event.shiftKey, parent
);
break;
case 'toggleTagSelector':
ZoteroPane_Local.toggleTagSelector();