Bug 736572 - Show arrow after sorting column in pageInfo. Provide empty string for comparison function if no according attribute was set. r=jaws
authorMichael Weisz <mail@michael-weisz.de>
Thu, 05 Mar 2015 20:16:18 +0100
changeset 232408 e0abc8b99d180f46d78b7b50da50a4d5af4b0bbb
parent 232407 1e1ec290a384565434b718d8b8f072b2ac140af7
child 232409 9f3479b12e5e27aae6a6286cc4ea9026498ee2cf
push id28379
push userphilringnalda@gmail.com
push dateSun, 08 Mar 2015 03:39:06 +0000
treeherdermozilla-central@fecf1afb0830 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs736572
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 736572 - Show arrow after sorting column in pageInfo. Provide empty string for comparison function if no according attribute was set. r=jaws
browser/base/content/pageinfo/pageInfo.js
--- a/browser/base/content/pageinfo/pageInfo.js
+++ b/browser/base/content/pageinfo/pageInfo.js
@@ -93,31 +93,39 @@ pageInfoTreeView.prototype = {
     var treecol = tree.columns.getNamedColumn(columnname);
 
     this.sortdir =
       gTreeUtils.sort(
         tree,
         this,
         this.data,
         treecol.index,
-        function textComparator(a, b) { return a.toLowerCase().localeCompare(b.toLowerCase()); },
+        function textComparator(a, b) { return (a || "").toLowerCase().localeCompare((b || "").toLowerCase()); },
         this.sortcol,
         this.sortdir
       );
 
+    Array.forEach(tree.columns, function(col) {
+      col.element.removeAttribute("sortActive");
+      col.element.removeAttribute("sortDirection");
+    });
+    treecol.element.setAttribute("sortActive", "true");
+    treecol.element.setAttribute("sortDirection", this.sortdir ?
+                                                  "ascending" : "descending");
+
     this.sortcol = treecol.index;
   },
 
   getRowProperties: function(row) { return ""; },
   getCellProperties: function(row, column) { return ""; },
   getColumnProperties: function(column) { return ""; },
   isContainer: function(index) { return false; },
   isContainerOpen: function(index) { return false; },
   isSeparator: function(index) { return false; },
-  isSorted: function() { },
+  isSorted: function() { return this.sortcol > -1 },
   canDrop: function(index, orientation) { return false; },
   drop: function(row, orientation) { return false; },
   getParentIndex: function(index) { return 0; },
   hasNextSibling: function(index, after) { return false; },
   getLevel: function(index) { return 0; },
   getImageSrc: function(row, column) { },
   getProgressMode: function(row, column) { },
   getCellValue: function(row, column) { },
@@ -182,34 +190,43 @@ gImageView.getCellText = function(row, c
   return value || "";
 };
 
 gImageView.onPageMediaSort = function(columnname) {
   var tree = document.getElementById(this.treeid);
   var treecol = tree.columns.getNamedColumn(columnname);
 
   var comparator;
-  if (treecol.index == COL_IMAGE_SIZE || treecol.index == COL_IMAGE_COUNT) {
+  var index = treecol.index;
+  if (index == COL_IMAGE_SIZE || index == COL_IMAGE_COUNT) {
     comparator = function numComparator(a, b) { return a - b; };
   } else {
-    comparator = function textComparator(a, b) { return a.toLowerCase().localeCompare(b.toLowerCase()); };
+    comparator = function textComparator(a, b) { return (a || "").toLowerCase().localeCompare((b || "").toLowerCase()); };
   }
 
   this.sortdir =
     gTreeUtils.sort(
       tree,
       this,
       this.data,
-      treecol.index,
+      index,
       comparator,
       this.sortcol,
       this.sortdir
     );
 
-  this.sortcol = treecol.index;
+  Array.forEach(tree.columns, function(col) {
+    col.element.removeAttribute("sortActive");
+    col.element.removeAttribute("sortDirection");
+  });
+  treecol.element.setAttribute("sortActive", "true");
+  treecol.element.setAttribute("sortDirection", this.sortdir ?
+                                                "ascending" : "descending");
+
+  this.sortcol = index;
 };
 
 var gImageHash = { };
 
 // localized strings (will be filled in when the document is loaded)
 // this isn't all of them, these are just the ones that would otherwise have been loaded inside a loop
 var gStrings = { };
 var gBundle;