From 87841bd05123d53594587db4f3ed589d38ccaa36 Mon Sep 17 00:00:00 2001 From: Sam Nicholls Date: Sun, 20 Jan 2013 23:07:33 +0000 Subject: [PATCH 1/3] DataTables [#140][#161] --- public/styles.css | 11 +++++++++++ views/layout.jade | 2 +- views/users/users.jade | 35 ++++++++++++++++++++++++++++++++++- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/public/styles.css b/public/styles.css index f1c40eb..d89d330 100644 --- a/public/styles.css +++ b/public/styles.css @@ -172,3 +172,14 @@ li.option-votes { box-shadow: inset 0px 0px 3px #444; } + +/** + * DataTables + * Based on http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css + */ +.sorting { background: url('http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/images/sort_both.png') no-repeat center right; } +.sorting_asc { background: url('http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/images/sort_asc.png') no-repeat center right; } +.sorting_desc { background: url('http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/images/sort_desc.png') no-repeat center right; } + +.sorting_asc_disabled { background: url('http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/images/sort_asc_disabled.png') no-repeat center right; } +.sorting_desc_disabled { background: url('http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/images/sort_desc_disabled.png') no-repeat center right; } diff --git a/views/layout.jade b/views/layout.jade index cbc8ab2..321bb07 100644 --- a/views/layout.jade +++ b/views/layout.jade @@ -2,6 +2,7 @@ html(lang='en') head meta(charset='utf-8') + script(type="text/javascript", src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js") link(rel="stylesheet", type="text/css", href="http://fonts.googleapis.com/css?family=Source+Sans+Pro") link(rel="stylesheet", type="text/css", href="/bootstrap/css/bootstrap.min.css") link(rel='stylesheet', type='text/css', href='/styles.css') @@ -16,4 +17,3 @@ html(lang='en') script(type="text/javascript", src="/bootstrap/js/bootstrap.min.js") script(type="text/javascript", src="/d3/d3.v3.min.js") script(type="text/javascript", src="/script.js") - diff --git a/views/users/users.jade b/views/users/users.jade index 07dbe15..508ed47 100644 --- a/views/users/users.jade +++ b/views/users/users.jade @@ -1,11 +1,44 @@ extends ../layout block content + script(type="text/javascript", src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js") + + script + $(document).ready(function(){ + // Allowing forcing data such as lincent and wpl to sort as numeric + jQuery.extend( jQuery.fn.dataTableExt.oSort, { + "forcenum-pre": function ( a ) { + return parseFloat( a ); + }, + + "forcenum-asc": function ( a, b ) { + return a - b; + }, + + "forcenum-desc": function ( a, b ) { + return b - a; + } + } ); + + $('.data').dataTable({ + "aoColumnDefs": [ + { "sType": "forcenum", "aTargets": [ 3, 4 ] } + ], + "bPaginate": false, + "bLengthChange": false, + "oLanguage": { + "sInfo": "_TOTAL_ users", + "sInfoEmpty": "No users :(", + "sInfoFiltered": "filtered (_MAX_ total)" + }, + }); + }); + h3 Users of #{channel} on #{connection} div#backlink a(href='/channels/'+connection) « Channel List div#row - table.table.table-striped + table.table.table-hover.data thead tr th Users From b6c2c46f6af3526f81578613354c58c0e46a4a58 Mon Sep 17 00:00:00 2001 From: Sam Nicholls Date: Sun, 20 Jan 2013 23:15:26 +0000 Subject: [PATCH 2/3] Fix for thousands seps [#140][#161] --- views/users/users.jade | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/views/users/users.jade b/views/users/users.jade index 508ed47..3aff2a3 100644 --- a/views/users/users.jade +++ b/views/users/users.jade @@ -5,9 +5,10 @@ block content script $(document).ready(function(){ - // Allowing forcing data such as lincent and wpl to sort as numeric + // Allowing forcing of string stats data to sort as numeric jQuery.extend( jQuery.fn.dataTableExt.oSort, { "forcenum-pre": function ( a ) { + a = a.replace("\,", ""); return parseFloat( a ); }, @@ -22,7 +23,7 @@ block content $('.data').dataTable({ "aoColumnDefs": [ - { "sType": "forcenum", "aTargets": [ 3, 4 ] } + { "sType": "forcenum", "aTargets": [ 1, 2, 3, 4, 5 ] } ], "bPaginate": false, "bLengthChange": false, From 0343da92d5c7c291420eeb5b1d2e6dfb618ba5a3 Mon Sep 17 00:00:00 2001 From: Sam Nicholls Date: Sun, 20 Jan 2013 23:25:00 +0000 Subject: [PATCH 3/3] Disable initial sort [#140][#161] --- views/users/users.jade | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/views/users/users.jade b/views/users/users.jade index 3aff2a3..35b2dca 100644 --- a/views/users/users.jade +++ b/views/users/users.jade @@ -29,9 +29,10 @@ block content "bLengthChange": false, "oLanguage": { "sInfo": "_TOTAL_ users", - "sInfoEmpty": "No users :(", + "sInfoEmpty": "No users", "sInfoFiltered": "filtered (_MAX_ total)" }, + "aaSorting": [], // Disable initial sort }); });