summaryrefslogtreecommitdiff
path: root/static/js/dataTables.percent.js
diff options
context:
space:
mode:
authorJohan Lundberg <lundberg@nordu.net>2014-04-02 17:26:12 +0200
committerJohan Lundberg <lundberg@nordu.net>2014-04-02 17:26:12 +0200
commit8214042cfdd6facad36aae287cbee60d6b96a4ee (patch)
tree0c1fa1260d0d588a57d953d8b6667df3739d2321 /static/js/dataTables.percent.js
parent807973debd5cb00a4250fe88f7037dcd3cd3133b (diff)
Added filters and type detection for dataTables.
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));
+ }
+} );