Permalink
Browse files

Fixed sorting on the user names with gravatars next to them.

  • Loading branch information...
1 parent b390349 commit 1d113ee2d60156d496da6c36942d179f950519a7 @darrenaustin committed Oct 2, 2011
Showing with 25 additions and 14 deletions.
  1. +25 −14 resources/public/script/foreclojure.js
@@ -59,20 +59,31 @@ $(document).ready(function() {
});
});
-var difficulty = new Array();
-difficulty["Elementary"] = 0;
-difficulty["Easy"] = 1;
-difficulty["Medium"] = 2;
-difficulty["Hard"] = 3;
-difficulty[""] = 4;
-
-jQuery.fn.dataTableExt.oSort['difficulty-asc'] = function(a, b) {
- return difficulty[a] - difficulty[b];
+var difficulty = {
+ "Elementary": 0,
+ "Easy": 1,
+ "Medium": 2,
+ "Hard": 3,
+ "": 4
};
-jQuery.fn.dataTableExt.oSort['difficulty-desc'] = function(a, b) {
- return difficulty[b] - difficulty[a];
-};
+jQuery.fn.dataTableExt.afnSortData['difficulty'] = function(oSettings, iColumn)
+{
+ var aData = [];
+ $('td:eq('+iColumn+')', oSettings.oApi._fnGetTrNodes(oSettings)).each(function () {
+ aData.push(difficulty[$(this).text()]);
+ });
+ return aData;
+}
+
+jQuery.fn.dataTableExt.afnSortData['user-name'] = function(oSettings, iColumn)
+{
+ var aData = [];
+ $('td:eq('+iColumn+') a.user-profile-link', oSettings.oApi._fnGetTrNodes(oSettings)).each(function () {
+ aData.push($(this).text());
+ });
+ return aData;
+}
function configureDataTables(){
@@ -81,7 +92,7 @@ function configureDataTables(){
"aaSorting": [[5, "desc"], [1, "asc"], [4, "desc"]],
"aoColumns": [
{"sType": "string"},
- {"sType": "difficulty"},
+ {"sSortDataType": "difficulty", "sType": "numeric"},
{"sType": "string"},
{"sType": "string"},
{"sType": "numeric"},
@@ -105,7 +116,7 @@ function configureDataTables(){
"aaSorting": [[0, "asc"]],
"aoColumns": [
{"sType": "numeric"},
- {"sType": "string"},
+ {"sSortDataType": "user-name"},
{"sType": "numeric"},
{"sType": "string"}
]

0 comments on commit 1d113ee

Please sign in to comment.