[interface] Item Type column (will show up on the right if you already have Scholar installed, but on the left for all new installations.), sortable.

[style] Better add/remove Creator buttons.
[fix] The sorting should not randomly switch the order of two items with the same sort value (eg, Barnes vs. Barnes).
[fix] The browser should not open with two sorted columns.
This commit is contained in:
David Norton 2006-06-12 12:43:20 +00:00
parent cebd6bde5b
commit b1389bfc61
5 changed files with 51 additions and 18 deletions

View file

@ -123,16 +123,16 @@ ScholarItemPane = new function()
firstlast.appendChild(createValueElement(firstName, 'creator-'+_creatorCount+'-firstName'));
row.appendChild(firstlast);
var removeButton = document.createElement('toolbarbutton');
removeButton.setAttribute("label","-");
var removeButton = document.createElement('label');
removeButton.setAttribute("value","-");
removeButton.setAttribute("class","addremove");
removeButton.setAttribute("oncommand","ScholarItemPane.removeCreator("+_creatorCount+")");
removeButton.setAttribute("onclick","ScholarItemPane.removeCreator("+_creatorCount+")");
row.appendChild(removeButton);
var addButton = document.createElement('toolbarbutton');
addButton.setAttribute("label","+");
var addButton = document.createElement('label');
addButton.setAttribute("value","+");
addButton.setAttribute("class","addremove");
addButton.setAttribute("oncommand","ScholarItemPane.addCreatorRow('','',1);");
addButton.setAttribute("onclick","ScholarItemPane.addCreatorRow('','',1);");
row.appendChild(addButton);
_creatorCount++;

View file

@ -14,7 +14,15 @@ Scholar.ItemTreeView.prototype.setTree = function(treebox)
if(this._treebox)
return;
this._treebox = treebox;
this.sort();
if(!this.isSorted())
{
this.cycleHeader(this._treebox.columns.getNamedColumn('firstCreator'));
}
else
{
this.sort();
}
}
Scholar.ItemTreeView.prototype.refresh = function()
@ -112,7 +120,10 @@ Scholar.ItemTreeView.prototype.unregister = function()
Scholar.ItemTreeView.prototype.getCellText = function(row, column)
{
var obj = this._getItemAtRow(row);
var val = obj.getField(column.id);
var val;
if(column.id != "typeIcon")
val = obj.getField(column.id);
if(column.id == 'dateAdded' || column.id == 'dateModified') //this is not so much that we will use this format for date, but a simple template for later revisions.
{
@ -124,7 +135,7 @@ Scholar.ItemTreeView.prototype.getCellText = function(row, column)
Scholar.ItemTreeView.prototype.getImageSrc = function(row, col)
{
if(col.id == 'title')
if(col.id == 'typeIcon')
{
var itemType = Scholar.ItemTypes.getTypeName(this._getItemAtRow(row).getType());
return "chrome://scholar/skin/treeitem-"+itemType+".png";
@ -169,22 +180,35 @@ Scholar.ItemTreeView.prototype.sort = function()
var column = this._treebox.columns.getSortedColumn()
var order = column.element.getAttribute('sortDirection') == 'descending';
if(order)
if(column.id == 'typeIcon')
{
function columnSort(a,b)
{
return(a.getField(column.id) < b.getField(column.id)) ? -1 : (a.getField[column.id] > b.getField(column.id)) ? 1 : 0;
var typeA = Scholar.getString('itemTypes.'+Scholar.ItemTypes.getTypeName(a.getType()));
var typeB = Scholar.getString('itemTypes.'+Scholar.ItemTypes.getTypeName(b.getType()));
return (typeA > typeB) ? -1 : (typeA < typeB) ? 1 : 0;
}
}
else
{
function columnSort(a,b)
{
return(a.getField(column.id) > b.getField(column.id)) ? -1 : (a.getField[column.id] < b.getField(column.id)) ? 1 : 0;
return (a.getField(column.id) > b.getField(column.id)) ? -1 : (a.getField(column.id) < b.getField(column.id)) ? 1 : 0;
}
}
this._dataItems.sort(columnSort);
function oppSort(a,b)
{
return(columnSort(a,b) * -1);
}
if(order)
this._dataItems.sort(oppSort);
else
this._dataItems.sort(columnSort);
this._refreshHashMap();
}

View file

@ -62,6 +62,11 @@
ondragdrop="nsDragAndDrop.drop(event,ScholarPane.getItemsView())"
flex="1">
<treecols>
<treecol
id="typeIcon"
label="&items.type_column;"
width="40" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="title"
label="&items.title_column;"
@ -69,7 +74,7 @@
<splitter class="tree-splitter"/>
<treecol
id="firstCreator"
label="&items.creator_column;" sortActive="true" sortDirection="descending"
label="&items.creator_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol

View file

@ -8,6 +8,7 @@
<!ENTITY metadata.cancel.label "Cancel">
<!ENTITY metadata.save.label "Save">
<!ENTITY items.type_column "Type">
<!ENTITY items.title_column "Title">
<!ENTITY items.creator_column "Creator">
<!ENTITY items.source_column "Source">

View file

@ -21,6 +21,11 @@ tree #items-tree
}
treechildren::-moz-tree-image
{
}
#scholar-pane toolbar
{
border-bottom: none;
@ -59,9 +64,7 @@ tree #items-tree
#scholar-metadata .addremove
{
-moz-border-radius: 8px;
width: 16px;
height: 16px;
-moz-border-radius: 6px;
}
#scholar-metadata .addremove:hover