www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 9db4927f78e7aed501dc92876500e26e59b79b6e
parent 6dbcdb95f444618f2532b7e41effe28b47915d1e
Author: Dan Stillman <dstillman@zotero.org>
Date:   Tue, 12 Aug 2014 22:19:19 -0400

Scroll to new collections, and stay on same row when deleting collections

Diffstat:
Mchrome/content/zotero/xpcom/collectionTreeView.js | 14++++++++++----
Mchrome/content/zotero/xpcom/itemTreeView.js | 4++--
2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -245,7 +245,7 @@ Zotero.CollectionTreeView.prototype.notify = Zotero.Promise.coroutine(function* var savedSelection = this.saveSelection(); if (action == 'delete') { - var selectedIndex = this.selection.count ? this.selection.selectedIndex : 0; + var selectedIndex = this.selection.count ? this.selection.currentIndex : 0; //Since a delete involves shifting of rows, we have to do it in order @@ -287,14 +287,18 @@ Zotero.CollectionTreeView.prototype.notify = Zotero.Promise.coroutine(function* for(var i=0, len=rows.length; i<len; i++) { var row = rows[i]; - this._removeRow(row-i); - this._treebox.rowCountChanged(row-i,-1); + this._removeRow(row); + this._treebox.rowCountChanged(row, -1); } this._refreshCollectionRowMap(); } if (!this.selection.count) { + // If last row was selected, stay on the last row + if (selectedIndex >= this.rowCount) { + selectedIndex = this.rowCount - 1; + }; this.selection.select(selectedIndex) } } @@ -343,7 +347,9 @@ Zotero.CollectionTreeView.prototype.notify = Zotero.Promise.coroutine(function* this.rememberSelection(savedSelection); break; } - this.selection.select(this._collectionRowMap[collection.id]); + let row = this._collectionRowMap[collection.id]; + this._treebox.ensureRowIsVisible(row); + this.selection.select(row); break; case 'search': diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js @@ -646,12 +646,12 @@ Zotero.ItemTreeView.prototype.notify = Zotero.Promise.coroutine(function* (actio // The container refresh above takes care of adding the new row. else if (!this.isContainer(row) && parentIndex == -1 && parentItemID) { this._removeRow(row); - this._treebox.rowCountChanged(row + 1, -1) + this._treebox.rowCountChanged(row, -1) } // If moved from under another item to top level, remove old row and add new one else if (!this.isContainer(row) && parentIndex != -1 && !parentItemID) { this._removeRow(row); - this._treebox.rowCountChanged(row + 1, -1) + this._treebox.rowCountChanged(row, -1) this._addRow( this._rows,