www

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

commit 72a2dd92168028ae37cadca6bae55dbc99c8c392
parent 0fa7c008aa113d9384c4f63bc152535144c3fc0a
Author: David Norton <david@nortoncrew.com>
Date:   Fri, 19 May 2006 15:26:54 +0000

Folders deletion logic added (needs Folder.erase() which should recursively delete children as well)

Diffstat:
Mchrome/chromeFiles/content/scholar/sidebar.js | 57++++++++++++++++++++++++++++++++++-----------------------
Mchrome/chromeFiles/content/scholar/sidebar.xul | 4++--
2 files changed, 36 insertions(+), 25 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/sidebar.js b/chrome/chromeFiles/content/scholar/sidebar.js @@ -134,37 +134,48 @@ Scholar.TreeView.prototype.performAction = function(action) { } Scholar.TreeView.prototype.performActionOnCell = function(action, row, col) { } Scholar.TreeView.prototype.getProgressMode = function(row, col) { } -Scholar.TreeView.prototype.deleteSelectedItem = function() +Scholar.TreeView.prototype.deleteSelection = function() { if(this.selection.count == 0) { return; } - else if(confirm("Are you sure you want to delete the selected item"+(this.selection.count > 1 ? "s" : "")+"?")) + if(!confirm("Are you sure you want to delete the selected item"+(this.selection.count > 1 ? "s" : "")+"?")) { - var items = new Array(); - var start = new Object(); - var end = new Object(); - - for (var i=0, len=this.selection.getRangeCount(); i<len; i++) - { - this.selection.getRangeAt(i,start,end); - for (var j=start.value; j<=end.value; j++) - if(!this.isContainer(j)) - items.push(j); - } - - this._treebox.beginUpdateBatch(); - for (var i=0; i<items.length; i++) - { - this._getItemAtRow(items[i]-i).erase(); - this._hideItem(items[i]-i); + return; + } - this.rowCount--; - this._treebox.rowCountChanged(items[i]-i, -1); - } - this._treebox.endUpdateBatch(); + //collapse open folders + for(var i=0; i<this.rowCount; i++) + { + if(this.selection.isSelected(i) && this.isContainer(i) && this.isContainerOpen(i)) + this.toggleOpenState(i); } + + //create an array of selected items/folders + var rows = new Array(); + var start = new Object(); + var end = new Object(); + for (var i=0, len=this.selection.getRangeCount(); i<len; i++) + { + this.selection.getRangeAt(i,start,end); + for (var j=start.value; j<=end.value; j++) + rows.push(j); + } + + //iterate and erase... + this._treebox.beginUpdateBatch(); + for (var i=0; i<rows.length; i++) + { + this._getItemAtRow(rows[i]-i).erase(); //erases item/folder from DB + + //remove row from tree + this._hideItem(rows[i]-i); + this.rowCount--; + this._treebox.rowCountChanged(rows[i]-i, -1); + } + this._treebox.endUpdateBatch(); + } /* DRAG AND DROP (IMPLEMENT LATER) diff --git a/chrome/chromeFiles/content/scholar/sidebar.xul b/chrome/chromeFiles/content/scholar/sidebar.xul @@ -11,8 +11,8 @@ <script src="include.js"/> <script src="sidebar.js"/> <keyset> - <key id="delete-cmd" keycode="VK_DELETE" oncommand="myTreeView.deleteSelectedItem()"/> - <key id="backspace-cmd" keycode="VK_BACK" oncommand="myTreeView.deleteSelectedItem()"/> + <key id="delete-cmd" keycode="VK_DELETE" oncommand="myTreeView.deleteSelection()"/> + <key id="backspace-cmd" keycode="VK_BACK" oncommand="myTreeView.deleteSelection()"/> </keyset> <stringbundle id="scholar-strings" src="chrome://scholar/locale/scholar.properties"/> <vbox id="list-pane" flex="1">