commit b1389bfc61bfd5dfec584aeb0be199d62f2e6811
parent cebd6bde5b3e5184eb53e6efa9967fac5f5db284
Author: David Norton <david@nortoncrew.com>
Date: Mon, 12 Jun 2006 12:43:20 +0000
[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.
Diffstat:
5 files changed, 51 insertions(+), 18 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/itemPane.js b/chrome/chromeFiles/content/scholar/itemPane.js
@@ -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++;
diff --git a/chrome/chromeFiles/content/scholar/itemTreeView.js b/chrome/chromeFiles/content/scholar/itemTreeView.js
@@ -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();
}
diff --git a/chrome/chromeFiles/content/scholar/overlay.xul b/chrome/chromeFiles/content/scholar/overlay.xul
@@ -63,13 +63,18 @@
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;"
flex="4" persist="width ordinal hidden sortActive sortDirection"/>
<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
diff --git a/chrome/chromeFiles/locale/en-US/scholar/scholar.dtd b/chrome/chromeFiles/locale/en-US/scholar/scholar.dtd
@@ -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">
diff --git a/chrome/chromeFiles/skin/default/scholar/overlay.css b/chrome/chromeFiles/skin/default/scholar/overlay.css
@@ -21,6 +21,11 @@ tree #items-tree
}
+treechildren::-moz-tree-image
+{
+
+}
+
#scholar-pane toolbar
{
border-bottom: none;
@@ -58,10 +63,8 @@ tree #items-tree
}
#scholar-metadata .addremove
-{
- -moz-border-radius: 8px;
- width: 16px;
- height: 16px;
+{
+ -moz-border-radius: 6px;
}
#scholar-metadata .addremove:hover