Closes #85, Button(s) to expand/collapse all notes in a view
Hit + to expand all tree rows, - to collapse. Works in both collections tree and items tree. Probably could've thought of that 8 months ago when we created the ticket...
This commit is contained in:
parent
38416da753
commit
4740d85d49
|
@ -36,6 +36,7 @@ var ZoteroPane = new function()
|
||||||
this.handleKeyDown = handleKeyDown;
|
this.handleKeyDown = handleKeyDown;
|
||||||
this.handleKeyUp = handleKeyUp;
|
this.handleKeyUp = handleKeyUp;
|
||||||
this.setHighlightedRowsCallback = setHighlightedRowsCallback;
|
this.setHighlightedRowsCallback = setHighlightedRowsCallback;
|
||||||
|
this.handleKeyPress = handleKeyPress;
|
||||||
this.newItem = newItem;
|
this.newItem = newItem;
|
||||||
this.newCollection = newCollection;
|
this.newCollection = newCollection;
|
||||||
this.newSearch = newSearch;
|
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
|
* Create a new item
|
||||||
*
|
*
|
||||||
|
|
|
@ -125,7 +125,7 @@
|
||||||
onselect="ZoteroPane.onCollectionSelected();" seltype="single"
|
onselect="ZoteroPane.onCollectionSelected();" seltype="single"
|
||||||
ondragdrop="nsDragAndDrop.drop(event, ZoteroPane.collectionsView)"
|
ondragdrop="nsDragAndDrop.drop(event, ZoteroPane.collectionsView)"
|
||||||
ondraggesture="if (event.target.localName == 'treechildren') nsDragAndDrop.startDrag(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">
|
flex="1">
|
||||||
<treecols>
|
<treecols>
|
||||||
<treecol
|
<treecol
|
||||||
|
@ -183,7 +183,7 @@
|
||||||
ondblclick="ZoteroPane.onDoubleClick(event, this);"
|
ondblclick="ZoteroPane.onDoubleClick(event, this);"
|
||||||
enableColumnDrag="true"
|
enableColumnDrag="true"
|
||||||
onfocus="if (ZoteroPane.itemsView.rowCount && !ZoteroPane.itemsView.selection.count) { ZoteroPane.itemsView.selection.select(0); }"
|
onfocus="if (ZoteroPane.itemsView.rowCount && !ZoteroPane.itemsView.selection.count) { ZoteroPane.itemsView.selection.select(0); }"
|
||||||
onkeypress="if (event.keyCode == event.DOM_VK_BACK_SPACE || event.keyCode == event.DOM_VK_DELETE){ ZoteroPane.deleteSelectedItem(); event.preventDefault(); }"
|
onkeypress="ZoteroPane.handleKeyPress(event, this.id)"
|
||||||
onselect="ZoteroPane.itemSelected();"
|
onselect="ZoteroPane.itemSelected();"
|
||||||
ondraggesture="if (event.target.localName == 'treechildren') nsDragAndDrop.startDrag(event,ZoteroPane.itemsView);"
|
ondraggesture="if (event.target.localName == 'treechildren') nsDragAndDrop.startDrag(event,ZoteroPane.itemsView);"
|
||||||
ondragover="nsDragAndDrop.dragOver(event, ZoteroPane.itemsView)"
|
ondragover="nsDragAndDrop.dragOver(event, ZoteroPane.itemsView)"
|
||||||
|
|
|
@ -360,6 +360,29 @@ Zotero.CollectionTreeView.prototype.toggleOpenState = function(row)
|
||||||
this._refreshHashMap();
|
this._refreshHashMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Zotero.CollectionTreeView.prototype.expandAllRows = function() {
|
||||||
|
this._treebox.beginUpdateBatch();
|
||||||
|
for (var i=0; i<this.rowCount; i++) {
|
||||||
|
if (this.isContainer(i) && !this.isContainerOpen(i)) {
|
||||||
|
this.toggleOpenState(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this._treebox.endUpdateBatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Zotero.CollectionTreeView.prototype.collapseAllRows = function() {
|
||||||
|
this._treebox.beginUpdateBatch();
|
||||||
|
for (var i=0; i<this.rowCount; i++) {
|
||||||
|
if (this.isContainer(i) && this.isContainerOpen(i)) {
|
||||||
|
this.toggleOpenState(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this._treebox.endUpdateBatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
///
|
///
|
||||||
/// Additional functions for managing data in the tree
|
/// Additional functions for managing data in the tree
|
||||||
|
|
|
@ -475,6 +475,29 @@ Zotero.ItemTreeView.prototype.toggleOpenState = function(row)
|
||||||
this._refreshHashMap();
|
this._refreshHashMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Zotero.ItemTreeView.prototype.expandAllRows = function() {
|
||||||
|
this._treebox.beginUpdateBatch();
|
||||||
|
for (var i=0; i<this.rowCount; i++) {
|
||||||
|
if (this.isContainer(i) && !this.isContainerOpen(i)) {
|
||||||
|
this.toggleOpenState(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this._treebox.endUpdateBatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Zotero.ItemTreeView.prototype.collapseAllRows = function() {
|
||||||
|
this._treebox.beginUpdateBatch();
|
||||||
|
for (var i=0; i<this.rowCount; i++) {
|
||||||
|
if (this.isContainer(i) && this.isContainerOpen(i)) {
|
||||||
|
this.toggleOpenState(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this._treebox.endUpdateBatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Zotero.ItemTreeView.prototype.isSorted = function()
|
Zotero.ItemTreeView.prototype.isSorted = function()
|
||||||
{
|
{
|
||||||
// We sort by the first column if none selected, so return true
|
// We sort by the first column if none selected, so return true
|
||||||
|
|
Loading…
Reference in New Issue
Block a user