This commit is contained in:
David Norton 2006-05-15 21:45:07 +00:00
parent ec010c8b07
commit 8f84eaad7a

View File

@ -1,13 +1,23 @@
var ScholarLocalizedStrings; var ScholarLocalizedStrings;
var myTreeView;
var treeView = { Scholar.TreeView = function()
treebox: null,
dataObjects: null,
get rowCount() { return this.dataObjects.length; },
getCellText: function(row,column)
{ {
obj = this.dataObjects[row]; this._treebox = null;
this._dataObjects = new Array();
this.rowCount = 0;
}
Scholar.TreeView.prototype.setTree = function(treebox)
{
this._treebox = treebox;
this._dataObjects = Scholar.Objects.getTreeRows();
this.rowCount = this._dataObjects.length;
}
Scholar.TreeView.prototype.getCellText = function(row, column)
{
var obj = this._dataObjects[row];
if(column.id == "title_column") if(column.id == "title_column")
{ {
@ -21,21 +31,50 @@ var treeView = {
{ {
return obj.getField("source"); return obj.getField("source");
} }
}, }
setTree: function(treebox)
Scholar.TreeView.prototype.isContainer = function(row)
{ {
this.treebox = treebox; return this._dataObjects(row).isFolder();
this.dataObjects = Scholar.Objects.getTreeRows(); }
},
isContainer: function(row){ return false; }, Scholar.TreeView.prototype.isContainerOpen = function(row)
isSeparator: function(row){ return false; }, {
isSorted: function(){ return false; }, return false;
getLevel: function(row){ return 0; }, }
getImageSrc: function(row,col){ return null; },
getRowProperties: function(row,props){}, Scholar.TreeView.prototype.isContainerEmpty = function(row)
getCellProperties: function(row,col,props){}, {
getColumnProperties: function(colid,col,props){}, }
selectionChanged: function()
Scholar.TreeView.prototype.getLevel = function(row)
{
return this._dataObjects(row).getLevel();
}
Scholar.TreeView.prototype.toggleOpenState = function(row)
{
if(this.isContainerOpen(row))
{
var thisLevel = this._dataObjects[row].getLevel();
while(this._dataObjects[row + 1].getLevel > thisLevel)
{
this._dataObjects.splice(row+1,1);
}
}
else
{
var newRows = Scholar.Objects.getTreeRows(this._dataObjects[row].getID()); //Get children of
for(i in newRows)
{
this._dataObjects.splice(row+i+1,0,newRows[i]);
}
}
this.rowCount = this._dataObjects.length;
}
Scholar.TreeView.prototype.selectionChanged = function()
{ {
if(this.selection.count == 0) if(this.selection.count == 0)
{ {
@ -44,7 +83,7 @@ var treeView = {
} }
else if(this.selection.count == 1) else if(this.selection.count == 1)
{ {
populateObjectPane(this.dataObjects[this.selection.currentIndex]); populateObjectPane(this._dataObjects[this.selection.currentIndex]);
setObjectPaneVisibility(true); setObjectPaneVisibility(true);
} }
else else
@ -52,8 +91,18 @@ var treeView = {
document.getElementById('status-text').value = "(Multiple selection)"; document.getElementById('status-text').value = "(Multiple selection)";
setObjectPaneVisibility(false); setObjectPaneVisibility(false);
} }
}
Scholar.TreeView.prototype.isSorted = function()
{
return false;
}
Scholar.TreeView.prototype.getColumnProperties = function(col, prop)
{
return null;
} }
};
function setObjectPaneVisibility(vis) function setObjectPaneVisibility(vis)
{ {
@ -116,13 +165,14 @@ function populateObjectPane(objectRow)
function selectionChanged() function selectionChanged()
{ {
treeView.selectionChanged(); myTreeView.selectionChanged();
} }
function setView() function setView()
{ {
myTreeView = new Scholar.TreeView();
ScholarLocalizedStrings = document.getElementById('scholar-strings'); ScholarLocalizedStrings = document.getElementById('scholar-strings');
document.getElementById('scholar-sidebar-items').view=treeView; document.getElementById('scholar-sidebar-items').view=myTreeView;
} }
Scholar.testString = 'Sidebar is registered.'; Scholar.testString = 'Sidebar is registered.';