From b1389bfc61bfd5dfec584aeb0be199d62f2e6811 Mon Sep 17 00:00:00 2001 From: David Norton Date: Mon, 12 Jun 2006 12:43:20 +0000 Subject: [PATCH] [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. --- .../chromeFiles/content/scholar/itemPane.js | 12 +++--- .../content/scholar/itemTreeView.js | 38 +++++++++++++++---- .../chromeFiles/content/scholar/overlay.xul | 7 +++- .../locale/en-US/scholar/scholar.dtd | 1 + .../skin/default/scholar/overlay.css | 11 ++++-- 5 files changed, 51 insertions(+), 18 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/itemPane.js b/chrome/chromeFiles/content/scholar/itemPane.js index 0d32ee2d87..220f57a19a 100644 --- 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 index faee64f94c..e4a19eb158 100644 --- 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 index 3ef66c545a..92e25ddc1c 100644 --- a/chrome/chromeFiles/content/scholar/overlay.xul +++ b/chrome/chromeFiles/content/scholar/overlay.xul @@ -62,6 +62,11 @@ ondragdrop="nsDragAndDrop.drop(event,ScholarPane.getItemsView())" flex="1"> + + + diff --git a/chrome/chromeFiles/skin/default/scholar/overlay.css b/chrome/chromeFiles/skin/default/scholar/overlay.css index 7e8a93fd8c..22fa2a9dd1 100644 --- 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