Updated trees to work with new setup. Some New Item functionality. etc.
This commit is contained in:
parent
03637a6c63
commit
2be758e488
|
@ -12,9 +12,9 @@ Scholar.FolderTreeView.prototype.setTree = function(treebox)
|
||||||
return;
|
return;
|
||||||
this._treebox = treebox;
|
this._treebox = treebox;
|
||||||
|
|
||||||
var newRows = Scholar.Items.getTreeRows(0,'folders');
|
var newRows = Scholar.getCollections();
|
||||||
for(var i = 0; i < newRows.length; i++)
|
for(var i = 0; i < newRows.length; i++)
|
||||||
this._showItem(new Scholar.ItemGroup('folder',newRows[i]), 0, this._dataItems.length); //item ref, level, beforeRow
|
this._showItem(new Scholar.ItemGroup('collection',newRows[i]), 0, this._dataItems.length); //item ref, level, beforeRow
|
||||||
|
|
||||||
this._refreshHashMap();
|
this._refreshHashMap();
|
||||||
}
|
}
|
||||||
|
@ -29,13 +29,13 @@ Scholar.FolderTreeView.prototype.getCellText = function(row, column)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
Scholar.FolderTreeView.prototype.isContainer = function(row) { return this._getItemAtRow(row).isFolder(); }
|
Scholar.FolderTreeView.prototype.isContainer = function(row) { return this._getItemAtRow(row).isCollection(); }
|
||||||
Scholar.FolderTreeView.prototype.isContainerOpen = function(row) { return this._dataItems[row][1]; }
|
Scholar.FolderTreeView.prototype.isContainerOpen = function(row) { return this._dataItems[row][1]; }
|
||||||
Scholar.FolderTreeView.prototype.isContainerEmpty = function(row)
|
Scholar.FolderTreeView.prototype.isContainerEmpty = function(row)
|
||||||
{
|
{
|
||||||
var itemGroup = this._getItemAtRow(row);
|
var itemGroup = this._getItemAtRow(row);
|
||||||
if(itemGroup.isFolder())
|
if(itemGroup.isCollection())
|
||||||
return !itemGroup.ref.hasChildFolders();
|
return !itemGroup.ref.hasChildCollections();
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -79,12 +79,12 @@ Scholar.FolderTreeView.prototype.toggleOpenState = function(row)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var newRows = Scholar.Items.getTreeRows(this._getItemAtRow(row).ref.getID(),'folders'); //Get children
|
var newRows = Scholar.getCollections(this._getItemAtRow(row).ref.getID()); //Get children
|
||||||
|
|
||||||
for(var i = 0; i < newRows.length; i++)
|
for(var i = 0; i < newRows.length; i++)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
this._showItem(new Scholar.ItemGroup('folder',newRows[i]), thisLevel+1, row+i+1); //insert new row
|
this._showItem(new Scholar.ItemGroup('collection',newRows[i]), thisLevel+1, row+i+1); //insert new row
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._dataItems[row][1] = !this._dataItems[row][1]; //toggle container open value
|
this._dataItems[row][1] = !this._dataItems[row][1]; //toggle container open value
|
||||||
|
@ -117,12 +117,12 @@ Scholar.FolderTreeView.prototype.deleteSelection = function()
|
||||||
if(this.selection.count == 0)
|
if(this.selection.count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//collapse open folders
|
//collapse open collections
|
||||||
for(var i=0; i<this.rowCount; i++)
|
for(var i=0; i<this.rowCount; i++)
|
||||||
if(this.selection.isSelected(i) && this.isContainer(i) && this.isContainerOpen(i))
|
if(this.selection.isSelected(i) && this.isContainer(i) && this.isContainerOpen(i))
|
||||||
this.toggleOpenState(i);
|
this.toggleOpenState(i);
|
||||||
|
|
||||||
//create an array of selected items/folders
|
//create an array of selected items/collections
|
||||||
var rows = new Array();
|
var rows = new Array();
|
||||||
var start = new Object();
|
var start = new Object();
|
||||||
var end = new Object();
|
var end = new Object();
|
||||||
|
@ -137,7 +137,7 @@ Scholar.FolderTreeView.prototype.deleteSelection = function()
|
||||||
this._treebox.beginUpdateBatch();
|
this._treebox.beginUpdateBatch();
|
||||||
for (var i=0; i<rows.length; i++)
|
for (var i=0; i<rows.length; i++)
|
||||||
{
|
{
|
||||||
//erase item/folder from DB:
|
//erase item/collection from DB:
|
||||||
this._getItemAtRow(rows[i]-i).erase();
|
this._getItemAtRow(rows[i]-i).erase();
|
||||||
|
|
||||||
//remove row from tree:
|
//remove row from tree:
|
||||||
|
@ -152,15 +152,15 @@ Scholar.FolderTreeView.prototype.deleteSelection = function()
|
||||||
|
|
||||||
Scholar.FolderTreeView.prototype._refreshHashMap = function()
|
Scholar.FolderTreeView.prototype._refreshHashMap = function()
|
||||||
{
|
{
|
||||||
// Create hash map of folder and object ids to row indexes
|
// Create hash map of collection and object ids to row indexes
|
||||||
|
|
||||||
this._folderRowMap = new Array();
|
this._collectionRowMap = new Array();
|
||||||
for(var i=0; i < this.rowCount; i++){
|
for(var i=0; i < this.rowCount; i++){
|
||||||
if (this.isContainer(i)){
|
if (this.isContainer(i)){
|
||||||
this._folderRowMap[this._getItemAtRow(i).ref.getID()] = i;
|
this._collectionRowMap[this._getItemAtRow(i).ref.getID()] = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Scholar.debug(Scholar.varDump(this.folderRowMap));
|
//Scholar.debug(Scholar.varDump(this.collectionRowMap));
|
||||||
//Scholar.debug(Scholar.varDump(this.objectRowMap));
|
//Scholar.debug(Scholar.varDump(this.objectRowMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,14 +175,14 @@ Scholar.ItemGroup.prototype.isLibrary = function()
|
||||||
return this.type == 'library';
|
return this.type == 'library';
|
||||||
}
|
}
|
||||||
|
|
||||||
Scholar.ItemGroup.prototype.isFolder = function()
|
Scholar.ItemGroup.prototype.isCollection = function()
|
||||||
{
|
{
|
||||||
return this.type == 'folder';
|
return this.type == 'collection';
|
||||||
}
|
}
|
||||||
|
|
||||||
Scholar.ItemGroup.prototype.getName = function()
|
Scholar.ItemGroup.prototype.getName = function()
|
||||||
{
|
{
|
||||||
if(this.isFolder())
|
if(this.isCollection())
|
||||||
return this.ref.getName();
|
return this.ref.getName();
|
||||||
else if(this.isLibrary())
|
else if(this.isLibrary())
|
||||||
return "Library";
|
return "Library";
|
||||||
|
@ -192,10 +192,10 @@ Scholar.ItemGroup.prototype.getName = function()
|
||||||
|
|
||||||
Scholar.ItemGroup.prototype.getChildItems = function()
|
Scholar.ItemGroup.prototype.getChildItems = function()
|
||||||
{
|
{
|
||||||
if(this.isFolder())
|
if(this.isCollection())
|
||||||
return Scholar.Items.getTreeRows(this.ref.getID(),'items');
|
return Scholar.getItems(this.ref.getID());
|
||||||
else if(this.isLibrary())
|
else if(this.isLibrary())
|
||||||
return Scholar.Items.getAll();
|
return Scholar.getItems();
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
|
@ -127,7 +127,7 @@ MetadataPane = new function()
|
||||||
function getFullFieldList(item)
|
function getFullFieldList(item)
|
||||||
{
|
{
|
||||||
var fields = Scholar.ItemFields.getItemTypeFields(item.getField("itemTypeID"));
|
var fields = Scholar.ItemFields.getItemTypeFields(item.getField("itemTypeID"));
|
||||||
var fieldNames = new Array("title","dateAdded","dateModified","source","rights");
|
var fieldNames = new Array("title","dateAdded","dateModified");
|
||||||
for(var i = 0; i<fields.length; i++)
|
for(var i = 0; i<fields.length; i++)
|
||||||
fieldNames.push(Scholar.ItemFields.getName(fields[i]));
|
fieldNames.push(Scholar.ItemFields.getName(fields[i]));
|
||||||
return fieldNames;
|
return fieldNames;
|
||||||
|
|
|
@ -8,7 +8,7 @@ var ScholarPane = new function()
|
||||||
this.init = init;
|
this.init = init;
|
||||||
this.toggleScholar = toggleScholar;
|
this.toggleScholar = toggleScholar;
|
||||||
this.newItem = newItem;
|
this.newItem = newItem;
|
||||||
this.newFolder = newFolder;
|
this.newCollection = newCollection;
|
||||||
this.folderSelected = folderSelected;
|
this.folderSelected = folderSelected;
|
||||||
this.itemSelected = itemSelected;
|
this.itemSelected = itemSelected;
|
||||||
this.deleteSelection = deleteSelection;
|
this.deleteSelection = deleteSelection;
|
||||||
|
@ -18,7 +18,7 @@ var ScholarPane = new function()
|
||||||
{
|
{
|
||||||
foldersView = new Scholar.FolderTreeView(); //pass params here?
|
foldersView = new Scholar.FolderTreeView(); //pass params here?
|
||||||
document.getElementById('folders-tree').view = foldersView;
|
document.getElementById('folders-tree').view = foldersView;
|
||||||
document.getElementById('items-tree').view = null;
|
foldersView.selection.select(0);
|
||||||
|
|
||||||
var addMenu = document.getElementById('tb-add').firstChild;
|
var addMenu = document.getElementById('tb-add').firstChild;
|
||||||
var itemTypes = Scholar.ItemTypes.getTypes();
|
var itemTypes = Scholar.ItemTypes.getTypes();
|
||||||
|
@ -41,12 +41,12 @@ var ScholarPane = new function()
|
||||||
|
|
||||||
function newItem(typeID)
|
function newItem(typeID)
|
||||||
{
|
{
|
||||||
alert("new item of type: "+typeID);
|
document.getElementById('content').loadURI('chrome://scholar/content/view.xul?new='+typeID);
|
||||||
}
|
}
|
||||||
|
|
||||||
function newFolder()
|
function newCollection()
|
||||||
{
|
{
|
||||||
alert("new folder");
|
alert("new collection");
|
||||||
}
|
}
|
||||||
|
|
||||||
function folderSelected()
|
function folderSelected()
|
||||||
|
|
|
@ -13,21 +13,22 @@
|
||||||
<script src="itemTreeView.js"/>
|
<script src="itemTreeView.js"/>
|
||||||
<script src="folderTreeView.js"/>
|
<script src="folderTreeView.js"/>
|
||||||
|
|
||||||
|
<commandset id="mainCommandSet">
|
||||||
<command id="cmd_scholar_newItem" oncommand="ScholarPane.newItem(1);"/>
|
<command id="cmd_scholar_newItem" oncommand="ScholarPane.newItem(1);"/>
|
||||||
<command id="cmd_scholar_newFolder" oncommand="ScholarPane.newFolder();"/>
|
<command id="cmd_scholar_newCollection" oncommand="ScholarPane.newCollection();"/>
|
||||||
<command id="cmd_scholar_search" oncommand="ScholarPane.search();"/>
|
<command id="cmd_scholar_search" oncommand="ScholarPane.search();"/>
|
||||||
|
</commandset>
|
||||||
|
|
||||||
<vbox id="appcontent">
|
<vbox id="appcontent">
|
||||||
<vbox id="scholar-pane" position="1" persist="height collapsed">
|
<vbox id="scholar-pane" position="1" persist="height collapsed">
|
||||||
<hbox flex="1">
|
<hbox flex="1">
|
||||||
<tree id="folders-tree"
|
<tree id="folders-tree" hidecolumnpicker="true"
|
||||||
style="-moz-user-focus: ignore;" hidecolumnpicker="true"
|
onselect="ScholarPane.folderSelected();" seltype="single"
|
||||||
onselect="ScholarPane.folderSelected();"
|
|
||||||
persist="width" flex="1">
|
persist="width" flex="1">
|
||||||
<treecols>
|
<treecols>
|
||||||
<treecol
|
<treecol
|
||||||
id="name_column"
|
id="name_column"
|
||||||
label="&folders.name_column;"
|
label="&collections.name_column;"
|
||||||
flex="1"
|
flex="1"
|
||||||
primary="true"/>
|
primary="true"/>
|
||||||
</treecols>
|
</treecols>
|
||||||
|
@ -75,7 +76,7 @@
|
||||||
</tree>
|
</tree>
|
||||||
</hbox>
|
</hbox>
|
||||||
<toolbar id="scholar-toolbar" align="center">
|
<toolbar id="scholar-toolbar" align="center">
|
||||||
<toolbarbutton label="&menuitem.newFolder.label;" command="cmd_scholar_newFolder"/>
|
<toolbarbutton label="&menuitem.newCollection.label;" command="cmd_scholar_newCollection"/>
|
||||||
<toolbarbutton id="tb-add" label="&menuitem.newItem.label;" type="menu">
|
<toolbarbutton id="tb-add" label="&menuitem.newItem.label;" type="menu">
|
||||||
<menupopup>
|
<menupopup>
|
||||||
</menupopup>
|
</menupopup>
|
||||||
|
|
|
@ -2,10 +2,22 @@ var thisItem;
|
||||||
|
|
||||||
function init()
|
function init()
|
||||||
{
|
{
|
||||||
thisItem = Scholar.Items.get(getArgument("id"));
|
if(thisItem)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var id = getArgument("id");
|
||||||
|
if(id)
|
||||||
|
{
|
||||||
|
thisItem = Scholar.Items.get(id);
|
||||||
document.getElementById('view').setAttribute('src','http://www.google.com/search?q='+encodeURIComponent('"'+thisItem.getField("title")+'"')+'&btnI');
|
document.getElementById('view').setAttribute('src','http://www.google.com/search?q='+encodeURIComponent('"'+thisItem.getField("title")+'"')+'&btnI');
|
||||||
MetadataPane.viewItem(thisItem);
|
MetadataPane.viewItem(thisItem);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
thisItem = new Scholar.Item(getArgument('new'));
|
||||||
|
MetadataPane.viewItem(thisItem);
|
||||||
|
MetadataPane.toggleEdit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggle(id)
|
function toggle(id)
|
||||||
|
|
|
@ -9,11 +9,6 @@
|
||||||
<script src="include.js"/>
|
<script src="include.js"/>
|
||||||
<?xul-overlay href="metadataPane.xul" ?>
|
<?xul-overlay href="metadataPane.xul" ?>
|
||||||
|
|
||||||
<toolbar id="view-toolbar">
|
|
||||||
<toolbarbutton class="toggler" id="tb-view" label="View" checked="true" oncommand="toggle('view')"/>
|
|
||||||
<toolbarbutton class="toggler" id="tb-metadata" label="Metadata" checked="true" oncommand="toggle('metadata')"/>
|
|
||||||
<toolbarbutton class="toggler" id="tb-notes" label="Notes" checked="true" oncommand="toggle('notes')"/>
|
|
||||||
</toolbar>
|
|
||||||
<stack flex="1">
|
<stack flex="1">
|
||||||
<browser id="view" flex="1"/>
|
<browser id="view" flex="1"/>
|
||||||
<vbox align="end">
|
<vbox align="end">
|
||||||
|
@ -23,4 +18,9 @@
|
||||||
</vbox>
|
</vbox>
|
||||||
</vbox>
|
</vbox>
|
||||||
</stack>
|
</stack>
|
||||||
|
<toolbar id="view-toolbar">
|
||||||
|
<toolbarbutton class="toggler" id="tb-view" label="View" checked="true" oncommand="toggle('view')"/>
|
||||||
|
<toolbarbutton class="toggler" id="tb-metadata" label="Metadata" checked="true" oncommand="toggle('metadata')"/>
|
||||||
|
<toolbarbutton class="toggler" id="tb-notes" label="Notes" checked="true" oncommand="toggle('notes')"/>
|
||||||
|
</toolbar>
|
||||||
</page>
|
</page>
|
|
@ -5,7 +5,7 @@
|
||||||
<!ENTITY items.dateAdded_column "Date Added">
|
<!ENTITY items.dateAdded_column "Date Added">
|
||||||
<!ENTITY items.dateModified_column "Date Modified">
|
<!ENTITY items.dateModified_column "Date Modified">
|
||||||
|
|
||||||
<!ENTITY folders.name_column "Name">
|
<!ENTITY collections.name_column "Name">
|
||||||
|
|
||||||
<!ENTITY creators.firstname "First name">
|
<!ENTITY creators.firstname "First name">
|
||||||
<!ENTITY creators.lastname "Last name">
|
<!ENTITY creators.lastname "Last name">
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
<!ENTITY menuitem.newItem.label "New Item...">
|
<!ENTITY menuitem.newItem.label "New Item...">
|
||||||
<!ENTITY menuitem.newItem.accesskey "n">
|
<!ENTITY menuitem.newItem.accesskey "n">
|
||||||
<!ENTITY menuitem.newFolder.label "New Folder...">
|
<!ENTITY menuitem.newCollection.label "New Collection...">
|
||||||
<!ENTITY menuitem.newFolder.accesskey "o">
|
<!ENTITY menuitem.newFolder.accesskey "o">
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ tree #folders-tree
|
||||||
|
|
||||||
#scholar-tree-splitter
|
#scholar-tree-splitter
|
||||||
{
|
{
|
||||||
|
background: #f5f5f5;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ tree #items-tree
|
||||||
#scholar-toolbar
|
#scholar-toolbar
|
||||||
{
|
{
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
|
background: #f5f5f5;
|
||||||
}
|
}
|
||||||
|
|
||||||
#scholar-toolbar toolbarbutton
|
#scholar-toolbar toolbarbutton
|
||||||
|
|
Loading…
Reference in New Issue
Block a user