@ministryofjustice/frontend
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -1197,25 +1197,12 @@ ;(function(root, factory) { | ||
MOJFrontend.SortableTable.prototype.sort = function(rows, columnNumber, sortDirection) { | ||
var newRows = rows.sort($.proxy(function(rowA, rowB) { | ||
var newRows = rows.sort((function(rowA, rowB) { | ||
var tdA = $(rowA).find('td,th').eq(columnNumber); | ||
var tdB = $(rowB).find('td,th').eq(columnNumber); | ||
var valueA = this.getCellValue(tdA); | ||
var valueB = this.getCellValue(tdB); | ||
if(sortDirection === 'ascending') { | ||
if(valueA < valueB) { | ||
return -1; | ||
} | ||
if(valueA > valueB) { | ||
return 1; | ||
} | ||
return 0; | ||
} else { | ||
if(valueB < valueA) { | ||
return -1; | ||
} | ||
if(valueB > valueA) { | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
}, this)); | ||
var valueA = sortDirection === 'ascending' ? this.getCellValue(tdA) : this.getCellValue(tdB); | ||
var valueB = sortDirection === 'ascending' ? this.getCellValue(tdB) : this.getCellValue(tdA); | ||
if (typeof valueA === 'string' || typeof valueB === 'string') return valueA.toString().localeCompare(valueB.toString()); | ||
return valueA-valueB; | ||
}.bind(this))); | ||
return newRows; | ||
@@ -1225,8 +1212,6 @@ }; | ||
MOJFrontend.SortableTable.prototype.getCellValue = function(cell) { | ||
var val = cell.attr('data-sort-value'); | ||
val = val || cell.html(); | ||
if($.isNumeric(val)) { | ||
val = parseInt(val, 10); | ||
} | ||
return val; | ||
var val = cell.attr('data-sort-value') || cell.html(); | ||
var floatVal = parseFloat(val) | ||
return isNaN(floatVal) ? val : floatVal | ||
}; | ||
@@ -1233,0 +1218,0 @@ |
@@ -106,25 +106,12 @@ MOJFrontend.SortableTable = function(params) { | ||
MOJFrontend.SortableTable.prototype.sort = function(rows, columnNumber, sortDirection) { | ||
var newRows = rows.sort($.proxy(function(rowA, rowB) { | ||
var newRows = rows.sort((function(rowA, rowB) { | ||
var tdA = $(rowA).find('td,th').eq(columnNumber); | ||
var tdB = $(rowB).find('td,th').eq(columnNumber); | ||
var valueA = this.getCellValue(tdA); | ||
var valueB = this.getCellValue(tdB); | ||
if(sortDirection === 'ascending') { | ||
if(valueA < valueB) { | ||
return -1; | ||
} | ||
if(valueA > valueB) { | ||
return 1; | ||
} | ||
return 0; | ||
} else { | ||
if(valueB < valueA) { | ||
return -1; | ||
} | ||
if(valueB > valueA) { | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
}, this)); | ||
var valueA = sortDirection === 'ascending' ? this.getCellValue(tdA) : this.getCellValue(tdB); | ||
var valueB = sortDirection === 'ascending' ? this.getCellValue(tdB) : this.getCellValue(tdA); | ||
if (typeof valueA === 'string' || typeof valueB === 'string') return valueA.toString().localeCompare(valueB.toString()); | ||
return valueA-valueB; | ||
}.bind(this))); | ||
return newRows; | ||
@@ -134,8 +121,6 @@ }; | ||
MOJFrontend.SortableTable.prototype.getCellValue = function(cell) { | ||
var val = cell.attr('data-sort-value'); | ||
val = val || cell.html(); | ||
if($.isNumeric(val)) { | ||
val = parseInt(val, 10); | ||
} | ||
return val; | ||
var val = cell.attr('data-sort-value') || cell.html(); | ||
var floatVal = parseFloat(val) | ||
return isNaN(floatVal) ? val : floatVal | ||
}; |
{ | ||
"name": "@ministryofjustice/frontend", | ||
"description": "The MOJ Frontend contains the code you need to start building user interfaces for UK Ministry of Justice government services.", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"main": "moj/all.js", | ||
@@ -6,0 +6,0 @@ "sass": "moj/all.scss", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
761357
10165