The properties file is now better realigned.
The selection no longer lost or moved on folder opening/closing. The erase functionality works, on Mac (Windows) use the delete (backspace) or forward delete (delete) keys. unfortunately there are sometimes exceptions so I am not calling erase() on each item until we figure out what the problem is. view._deleteItem() and view._insertItem() are now view._hideItem() and view._showItem() to better reflect functionality.
This commit is contained in:
parent
89a6bc8746
commit
782d049dcd
3 changed files with 68 additions and 30 deletions
|
@ -18,7 +18,7 @@ Scholar.TreeView.prototype.setTree = function(treebox)
|
|||
|
||||
var newRows = Scholar.Items.getTreeRows();
|
||||
for(var i = 0; i < newRows.length; i++)
|
||||
this._insertItem(newRows[i], 0, i+1); //item ref, isContainerOpen, level
|
||||
this._showItem(newRows[i], 0, i+1); //item ref, isContainerOpen, level
|
||||
|
||||
this.rowCount = this._dataItems.length;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ Scholar.TreeView.prototype.toggleOpenState = function(row)
|
|||
{
|
||||
while((row + 1 < this._dataItems.length) && (this.getLevel(row + 1) > thisLevel))
|
||||
{
|
||||
this._deleteItem(row+1);
|
||||
this._hideItem(row+1);
|
||||
count--; //count is negative when closing a container because we are removing rows
|
||||
}
|
||||
}
|
||||
|
@ -91,14 +91,15 @@ Scholar.TreeView.prototype.toggleOpenState = function(row)
|
|||
for(var i = 0; i < newRows.length; i++)
|
||||
{
|
||||
count++;
|
||||
this._insertItem(newRows[i], thisLevel+1, row+i+1); //insert new row
|
||||
this._showItem(newRows[i], thisLevel+1, row+i+1); //insert new row
|
||||
}
|
||||
}
|
||||
|
||||
this._dataItems[row][1] = !this._dataItems[row][1]; //toggle container open value
|
||||
|
||||
this.rowCount = this._dataItems.length;
|
||||
|
||||
this._treebox.rowCountChanged(row, count); //tell treebox to repaint these
|
||||
this._treebox.rowCountChanged(row+1, count); //tell treebox to repaint these
|
||||
this._treebox.invalidateRow(row);
|
||||
}
|
||||
|
||||
Scholar.TreeView.prototype.selectionChanged = function()
|
||||
|
@ -116,10 +117,9 @@ Scholar.TreeView.prototype.selectionChanged = function()
|
|||
}
|
||||
|
||||
|
||||
Scholar.TreeView.prototype._insertItem = function(item, level, beforeRow) { this._dataItems.splice(beforeRow, 0, [item, false, level]); }
|
||||
|
||||
Scholar.TreeView.prototype._deleteItem = function(row) { this._dataItems.splice(row,1);; }
|
||||
Scholar.TreeView.prototype._showItem = function(item, level, beforeRow) { this._dataItems.splice(beforeRow, 0, [item, false, level]); }
|
||||
|
||||
Scholar.TreeView.prototype._hideItem = function(row) { this._dataItems.splice(row,1); }
|
||||
|
||||
Scholar.TreeView.prototype._getItemAtRow = function(row) { return this._dataItems[row][0]; }
|
||||
Scholar.TreeView.prototype.isSorted = function() { return false; }
|
||||
|
@ -133,10 +133,45 @@ 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()
|
||||
{
|
||||
if(this.selection.count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if(confirm("Are you sure you want to delete the selected item"+(this.selection.count > 1 ? "s" : "")))
|
||||
{
|
||||
//PS - ask first!!
|
||||
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._getItemAtRow(j).erase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i=0; i<items.length; i++)
|
||||
{
|
||||
this._hideItem(items[i]-i);
|
||||
this.rowCount--;
|
||||
|
||||
this._treebox.rowCountChanged(items[i]-i, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
DRAG AND DROP (IMPLEMENT LATER)
|
||||
Scholar.TreeView.prototype.canDrop = function(row, orient) { return !orient; }
|
||||
Scholar.TreeView.prototype.drop = function(row, orient) { }
|
||||
Scholar.DragObserver.canDrop = function(row, orient) { return !orient; }
|
||||
Scholar.DragObserver.drop = function(row, orient) { }
|
||||
*/
|
||||
|
||||
function viewSelectedItem()
|
||||
|
|
|
@ -10,7 +10,10 @@
|
|||
|
||||
<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()"/>
|
||||
</keyset>
|
||||
<stringbundle id="scholar-strings" src="chrome://scholar/locale/scholar.properties"/>
|
||||
<vbox id="list-pane" flex="1">
|
||||
<tree
|
||||
|
@ -18,7 +21,7 @@
|
|||
onselect="this.view.selectionChanged()"
|
||||
enableColumnDrag="true"
|
||||
seltype="multiple" flex="1">
|
||||
|
||||
|
||||
<treecols>
|
||||
<treecol
|
||||
id="title_column"
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
itemFields.title = Title
|
||||
itemFields.dateAdded = Date Added
|
||||
itemFields.dateModified = Modified
|
||||
itemFields.source = Source
|
||||
itemFields.rights = Rights
|
||||
itemFields.title = Title
|
||||
itemFields.dateAdded = Date Added
|
||||
itemFields.dateModified = Modified
|
||||
itemFields.source = Source
|
||||
itemFields.rights = Rights
|
||||
|
||||
itemFields.series = Series
|
||||
itemFields.volume = Volume
|
||||
itemFields.number = Number
|
||||
itemFields.edition = Edition
|
||||
itemFields.place = Place
|
||||
itemFields.publisher = Publisher
|
||||
itemFields.year = Year
|
||||
itemFields.pages = Pages
|
||||
itemFields.ISBN = ISBN
|
||||
itemFields.publication = Publication
|
||||
itemFields.ISSN = ISSN
|
||||
itemFields.series = Series
|
||||
itemFields.volume = Volume
|
||||
itemFields.number = Number
|
||||
itemFields.edition = Edition
|
||||
itemFields.place = Place
|
||||
itemFields.publisher = Publisher
|
||||
itemFields.year = Year
|
||||
itemFields.pages = Pages
|
||||
itemFields.ISBN = ISBN
|
||||
itemFields.publication = Publication
|
||||
itemFields.ISSN = ISSN
|
||||
|
||||
|
||||
itemTypes.book = Book
|
||||
itemTypes.journalArticle = Journal Article
|
||||
itemTypes.book = Book
|
||||
itemTypes.journalArticle = Journal Article
|
Loading…
Reference in a new issue