[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:
parent
cebd6bde5b
commit
b1389bfc61
5 changed files with 51 additions and 18 deletions
|
@ -123,16 +123,16 @@ ScholarItemPane = new function()
|
||||||
firstlast.appendChild(createValueElement(firstName, 'creator-'+_creatorCount+'-firstName'));
|
firstlast.appendChild(createValueElement(firstName, 'creator-'+_creatorCount+'-firstName'));
|
||||||
row.appendChild(firstlast);
|
row.appendChild(firstlast);
|
||||||
|
|
||||||
var removeButton = document.createElement('toolbarbutton');
|
var removeButton = document.createElement('label');
|
||||||
removeButton.setAttribute("label","-");
|
removeButton.setAttribute("value","-");
|
||||||
removeButton.setAttribute("class","addremove");
|
removeButton.setAttribute("class","addremove");
|
||||||
removeButton.setAttribute("oncommand","ScholarItemPane.removeCreator("+_creatorCount+")");
|
removeButton.setAttribute("onclick","ScholarItemPane.removeCreator("+_creatorCount+")");
|
||||||
row.appendChild(removeButton);
|
row.appendChild(removeButton);
|
||||||
|
|
||||||
var addButton = document.createElement('toolbarbutton');
|
var addButton = document.createElement('label');
|
||||||
addButton.setAttribute("label","+");
|
addButton.setAttribute("value","+");
|
||||||
addButton.setAttribute("class","addremove");
|
addButton.setAttribute("class","addremove");
|
||||||
addButton.setAttribute("oncommand","ScholarItemPane.addCreatorRow('','',1);");
|
addButton.setAttribute("onclick","ScholarItemPane.addCreatorRow('','',1);");
|
||||||
row.appendChild(addButton);
|
row.appendChild(addButton);
|
||||||
|
|
||||||
_creatorCount++;
|
_creatorCount++;
|
||||||
|
|
|
@ -14,8 +14,16 @@ Scholar.ItemTreeView.prototype.setTree = function(treebox)
|
||||||
if(this._treebox)
|
if(this._treebox)
|
||||||
return;
|
return;
|
||||||
this._treebox = treebox;
|
this._treebox = treebox;
|
||||||
|
|
||||||
|
if(!this.isSorted())
|
||||||
|
{
|
||||||
|
this.cycleHeader(this._treebox.columns.getNamedColumn('firstCreator'));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
this.sort();
|
this.sort();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Scholar.ItemTreeView.prototype.refresh = function()
|
Scholar.ItemTreeView.prototype.refresh = function()
|
||||||
{
|
{
|
||||||
|
@ -112,7 +120,10 @@ Scholar.ItemTreeView.prototype.unregister = function()
|
||||||
Scholar.ItemTreeView.prototype.getCellText = function(row, column)
|
Scholar.ItemTreeView.prototype.getCellText = function(row, column)
|
||||||
{
|
{
|
||||||
var obj = this._getItemAtRow(row);
|
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.
|
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)
|
Scholar.ItemTreeView.prototype.getImageSrc = function(row, col)
|
||||||
{
|
{
|
||||||
if(col.id == 'title')
|
if(col.id == 'typeIcon')
|
||||||
{
|
{
|
||||||
var itemType = Scholar.ItemTypes.getTypeName(this._getItemAtRow(row).getType());
|
var itemType = Scholar.ItemTypes.getTypeName(this._getItemAtRow(row).getType());
|
||||||
return "chrome://scholar/skin/treeitem-"+itemType+".png";
|
return "chrome://scholar/skin/treeitem-"+itemType+".png";
|
||||||
|
@ -169,22 +180,35 @@ Scholar.ItemTreeView.prototype.sort = function()
|
||||||
|
|
||||||
var column = this._treebox.columns.getSortedColumn()
|
var column = this._treebox.columns.getSortedColumn()
|
||||||
var order = column.element.getAttribute('sortDirection') == 'descending';
|
var order = column.element.getAttribute('sortDirection') == 'descending';
|
||||||
if(order)
|
|
||||||
|
if(column.id == 'typeIcon')
|
||||||
{
|
{
|
||||||
function columnSort(a,b)
|
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
|
else
|
||||||
{
|
{
|
||||||
function columnSort(a,b)
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function oppSort(a,b)
|
||||||
|
{
|
||||||
|
return(columnSort(a,b) * -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(order)
|
||||||
|
this._dataItems.sort(oppSort);
|
||||||
|
else
|
||||||
this._dataItems.sort(columnSort);
|
this._dataItems.sort(columnSort);
|
||||||
|
|
||||||
this._refreshHashMap();
|
this._refreshHashMap();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,11 @@
|
||||||
ondragdrop="nsDragAndDrop.drop(event,ScholarPane.getItemsView())"
|
ondragdrop="nsDragAndDrop.drop(event,ScholarPane.getItemsView())"
|
||||||
flex="1">
|
flex="1">
|
||||||
<treecols>
|
<treecols>
|
||||||
|
<treecol
|
||||||
|
id="typeIcon"
|
||||||
|
label="&items.type_column;"
|
||||||
|
width="40" persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
|
<splitter class="tree-splitter"/>
|
||||||
<treecol
|
<treecol
|
||||||
id="title"
|
id="title"
|
||||||
label="&items.title_column;"
|
label="&items.title_column;"
|
||||||
|
@ -69,7 +74,7 @@
|
||||||
<splitter class="tree-splitter"/>
|
<splitter class="tree-splitter"/>
|
||||||
<treecol
|
<treecol
|
||||||
id="firstCreator"
|
id="firstCreator"
|
||||||
label="&items.creator_column;" sortActive="true" sortDirection="descending"
|
label="&items.creator_column;"
|
||||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<splitter class="tree-splitter"/>
|
<splitter class="tree-splitter"/>
|
||||||
<treecol
|
<treecol
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
<!ENTITY metadata.cancel.label "Cancel">
|
<!ENTITY metadata.cancel.label "Cancel">
|
||||||
<!ENTITY metadata.save.label "Save">
|
<!ENTITY metadata.save.label "Save">
|
||||||
|
|
||||||
|
<!ENTITY items.type_column "Type">
|
||||||
<!ENTITY items.title_column "Title">
|
<!ENTITY items.title_column "Title">
|
||||||
<!ENTITY items.creator_column "Creator">
|
<!ENTITY items.creator_column "Creator">
|
||||||
<!ENTITY items.source_column "Source">
|
<!ENTITY items.source_column "Source">
|
||||||
|
|
|
@ -21,6 +21,11 @@ tree #items-tree
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
treechildren::-moz-tree-image
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#scholar-pane toolbar
|
#scholar-pane toolbar
|
||||||
{
|
{
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
|
@ -59,9 +64,7 @@ tree #items-tree
|
||||||
|
|
||||||
#scholar-metadata .addremove
|
#scholar-metadata .addremove
|
||||||
{
|
{
|
||||||
-moz-border-radius: 8px;
|
-moz-border-radius: 6px;
|
||||||
width: 16px;
|
|
||||||
height: 16px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#scholar-metadata .addremove:hover
|
#scholar-metadata .addremove:hover
|
||||||
|
|
Loading…
Reference in a new issue