From 1c7ac1a9a0f502b0d9ee204c67ee8b2f350683c2 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 16 Apr 2012 04:01:36 -0400 Subject: [PATCH] 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. --- chrome/content/zotero/zoteroPane.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index da39c09d2..97f125244 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -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();