diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index 9e3e219fe..d80a18421 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -36,6 +36,7 @@ var ZoteroPane = new function() this.handleKeyDown = handleKeyDown; this.handleKeyUp = handleKeyUp; this.setHighlightedRowsCallback = setHighlightedRowsCallback; + this.handleKeyPress = handleKeyPress; this.newItem = newItem; this.newCollection = newCollection; this.newSearch = newSearch; @@ -329,6 +330,49 @@ var ZoteroPane = new function() } + function handleKeyPress(event, from) { + var key = String.fromCharCode(event.which); + + if (from == 'zotero-collections-tree') { + if (event.keyCode == event.DOM_VK_BACK_SPACE || + event.keyCode == event.DOM_VK_DELETE) { + ZoteroPane.deleteSelectedCollection(); + event.preventDefault(); + return; + } + + if (key == '+' && !(event.ctrlKey || event.altKey || event.metaKey)) { + ZoteroPane.collectionsView.expandAllRows(); + return; + } + else if (key == '-' && !(event.shiftKey || event.ctrlKey || + event.altKey || event.metaKey)) { + ZoteroPane.collectionsView.collapseAllRows(); + return; + } + } + else if (from == 'zotero-items-tree') { + if (event.keyCode == event.DOM_VK_BACK_SPACE || + event.keyCode == event.DOM_VK_DELETE) { + ZoteroPane.deleteSelectedItem(); + event.preventDefault(); + return; + } + + if (key == '+' && !(event.ctrlKey || event.altKey || event.metaKey)) { + ZoteroPane.itemsView.expandAllRows(); + return; + } + else if (key == '-' && !(event.shiftKey || event.ctrlKey || + event.altKey || event.metaKey)) { + ZoteroPane.itemsView.collapseAllRows(); + return; + } + } + + } + + /* * Create a new item * diff --git a/chrome/content/zotero/overlay.xul b/chrome/content/zotero/overlay.xul index cc1c5f34c..e54b3d0d7 100644 --- a/chrome/content/zotero/overlay.xul +++ b/chrome/content/zotero/overlay.xul @@ -125,7 +125,7 @@ onselect="ZoteroPane.onCollectionSelected();" seltype="single" ondragdrop="nsDragAndDrop.drop(event, ZoteroPane.collectionsView)" ondraggesture="if (event.target.localName == 'treechildren') nsDragAndDrop.startDrag(event, ZoteroPane.collectionsView);" - onkeypress="if (event.keyCode == event.DOM_VK_BACK_SPACE || event.keyCode == event.DOM_VK_DELETE){ ZoteroPane.deleteSelectedCollection(); event.preventDefault(); }" + onkeypress="ZoteroPane.handleKeyPress(event, this.id)" flex="1">