summaryrefslogtreecommitdiff
path: root/static/js/dataTables.percent.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/js/dataTables.percent.js')
-rw-r--r--static/js/dataTables.percent.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/static/js/dataTables.percent.js b/static/js/dataTables.percent.js
new file mode 100644
index 0000000..c0b4db4
--- /dev/null
+++ b/static/js/dataTables.percent.js
@@ -0,0 +1,20 @@
+/**
+ * Created by lundberg on 4/2/14.
+ */
+
+// http://datatables.net/plug-ins/sorting
+
+jQuery.extend( jQuery.fn.dataTableExt.oSort, {
+ "percent-pre": function ( a ) {
+ var x = (a == "-") ? 0 : a.replace( /%/, "" );
+ return parseFloat( x );
+ },
+
+ "percent-asc": function ( a, b ) {
+ return ((a < b) ? -1 : ((a > b) ? 1 : 0));
+ },
+
+ "percent-desc": function ( a, b ) {
+ return ((a < b) ? 1 : ((a > b) ? -1 : 0));
+ }
+} );