Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added new table sort routine

  • Loading branch information...
commit a6cd8538eb1a9e8b47130429fc4e2fa60468b903 1 parent b004023
Roger Stringer authored June 05, 2012
47  assets/css/core.css
@@ -256,6 +256,53 @@ hr.soften {
256 256
 }
257 257
 
258 258
 
  259
+div.dataTables_length label {
  260
+	float: left;
  261
+	text-align: left;
  262
+}
  263
+
  264
+div.dataTables_length select {
  265
+	width: 75px;
  266
+}
  267
+
  268
+div.dataTables_filter label {
  269
+	float: right;
  270
+}
  271
+
  272
+div.dataTables_info {
  273
+	padding-top: 8px;
  274
+}
  275
+
  276
+div.dataTables_paginate {
  277
+	float: right;
  278
+	margin: 0;
  279
+}
  280
+
  281
+table.table {
  282
+	clear: both;
  283
+	margin-bottom: 6px !important;
  284
+}
  285
+
  286
+table.table thead .sorting,
  287
+table.table thead .sorting_asc,
  288
+table.table thead .sorting_desc,
  289
+table.table thead .sorting_asc_disabled,
  290
+table.table thead .sorting_desc_disabled {
  291
+	cursor: pointer;
  292
+	*cursor: hand;
  293
+}
  294
+
  295
+table.table thead .sorting { background: url('/assets/images/sort_both.png') no-repeat center right; }
  296
+table.table thead .sorting_asc { background: url('/assets/images/sort_asc.png') no-repeat center right; }
  297
+table.table thead .sorting_desc { background: url('/assets/images/sort_desc.png') no-repeat center right; }
  298
+
  299
+table.table thead .sorting_asc_disabled { background: url('/assets/images/sort_asc_disabled.png') no-repeat center right; }
  300
+table.table thead .sorting_desc_disabled { background: url('/assets/images/sort_desc_disabled.png') no-repeat center right; }
  301
+
  302
+table.dataTable th:active {
  303
+	outline: none;
  304
+}
  305
+
259 306
 
260 307
 /* Special grid styles
261 308
 -------------------------------------------------- */
BIN  assets/images/back_disabled.jpg
BIN  assets/images/back_enabled.jpg
BIN  assets/images/down.png
BIN  assets/images/forward_disabled.jpg
BIN  assets/images/forward_enabled.jpg
BIN  assets/images/loader.gif
BIN  assets/images/sort_asc.png
BIN  assets/images/sort_both.png
BIN  assets/images/sort_desc.png
BIN  assets/images/up.png
91  assets/js/app.js
... ...
@@ -1,9 +1,98 @@
  1
+$.extend( $.fn.dataTableExt.oStdClasses, {
  2
+	"sWrapper": "dataTables_wrapper form-inline"
  3
+} );
  4
+$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings ){
  5
+	return {
  6
+		"iStart":         oSettings._iDisplayStart,
  7
+		"iEnd":           oSettings.fnDisplayEnd(),
  8
+		"iLength":        oSettings._iDisplayLength,
  9
+		"iTotal":         oSettings.fnRecordsTotal(),
  10
+		"iFilteredTotal": oSettings.fnRecordsDisplay(),
  11
+		"iPage":          Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
  12
+		"iTotalPages":    Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
  13
+	};
  14
+}
  15
+$.extend( $.fn.dataTableExt.oPagination, {
  16
+	"bootstrap": {
  17
+		"fnInit": function( oSettings, nPaging, fnDraw ) {
  18
+			var oLang = oSettings.oLanguage.oPaginate;
  19
+			var fnClickHandler = function ( e ) {
  20
+				e.preventDefault();
  21
+				if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) {
  22
+					fnDraw( oSettings );
  23
+				}
  24
+			};
  25
+			$(nPaging).addClass('pagination').append(
  26
+				'<ul>'+
  27
+					'<li class="prev disabled"><a href="#">&larr; '+oLang.sPrevious+'</a></li>'+
  28
+					'<li class="next disabled"><a href="#">'+oLang.sNext+' &rarr; </a></li>'+
  29
+				'</ul>'
  30
+			);
  31
+			var els = $('a', nPaging);
  32
+			$(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler );
  33
+			$(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler );
  34
+		},
  35
+		"fnUpdate": function ( oSettings, fnDraw ) {
  36
+			var iListLength = 5;
  37
+			var oPaging = oSettings.oInstance.fnPagingInfo();
  38
+			var an = oSettings.aanFeatures.p;
  39
+			var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2);
  40
+
  41
+			if ( oPaging.iTotalPages < iListLength) {
  42
+				iStart = 1;
  43
+				iEnd = oPaging.iTotalPages;
  44
+			}
  45
+			else if ( oPaging.iPage <= iHalf ) {
  46
+				iStart = 1;
  47
+				iEnd = iListLength;
  48
+			} else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) {
  49
+				iStart = oPaging.iTotalPages - iListLength + 1;
  50
+				iEnd = oPaging.iTotalPages;
  51
+			} else {
  52
+				iStart = oPaging.iPage - iHalf + 1;
  53
+				iEnd = iStart + iListLength - 1;
  54
+			}
  55
+			for ( i=0, iLen=an.length ; i<iLen ; i++ ) {
  56
+				$('li:gt(0)', an[i]).filter(':not(:last)').remove();
  57
+				for ( j=iStart ; j<=iEnd ; j++ ) {
  58
+					sClass = (j==oPaging.iPage+1) ? 'class="active"' : '';
  59
+					$('<li '+sClass+'><a href="#">'+j+'</a></li>')
  60
+						.insertBefore( $('li:last', an[i])[0] )
  61
+						.bind('click', function (e) {
  62
+							e.preventDefault();
  63
+							oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength;
  64
+							fnDraw( oSettings );
  65
+						} );
  66
+				}
  67
+				if ( oPaging.iPage === 0 ) {
  68
+					$('li:first', an[i]).addClass('disabled');
  69
+				} else {
  70
+					$('li:first', an[i]).removeClass('disabled');
  71
+				}
  72
+
  73
+				if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) {
  74
+					$('li:last', an[i]).addClass('disabled');
  75
+				} else {
  76
+					$('li:last', an[i]).removeClass('disabled');
  77
+				}
  78
+			}
  79
+		}
  80
+	}
  81
+} );
  82
+
1 83
 $(document).ready(function(){
2 84
 	$('form').submit(function(e){
3 85
 		return checkrequireds(e);
4 86
 	});
5 87
 	$('#topbar').dropdown();
6  
-	$("#sortTable").tablesorter( { sortList: [[ 1, 0 ]] } )
  88
+	$('#datatable table').dataTable( {
  89
+		"sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
  90
+		"sPaginationType": "bootstrap",
  91
+		"oLanguage": {
  92
+			"sLengthMenu": "_MENU_ records per page"
  93
+		}
  94
+	} );
  95
+
7 96
 	$('.add-on :checkbox').click(function () {
8 97
 		if ($(this).attr('checked')) {
9 98
 			$(this).parents('.add-on').addClass('active')
7,440  assets/js/datatables.js
7440 additions, 0 deletions not shown
2  sections/_partials/header.php
@@ -13,7 +13,7 @@
13 13
 	<link href="/assets/css/core.css" rel="stylesheet">
14 14
 	<link href="/assets/css/bootstrap-responsive.css" rel="stylesheet">
15 15
 	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
16  
-	<script src="http://autobahn.tablesorter.com/jquery.tablesorter.min.js"></script>
  16
+	<script src="/assets/js/datatables.js"></script>
17 17
 	<script src="/assets/js/bootstrap.js"></script>
18 18
 	<script src="/assets/js/app.js"></script>
19 19
 	<link rel="shortcut icon" href="/assets/images/favicon.ico">
2  sections/visitor/login.php
@@ -9,7 +9,7 @@
9 9
 			<h1>Sign In</h1>
10 10
 		</div>
11 11
 		<div class="row">
12  
-			<div class="span16">
  12
+			<div class="span12">
13 13
 				<form method="post">
14 14
 				<fieldset>
15 15
 					<div class="clearfix">
2  sections/visitor/signup.php
@@ -35,7 +35,7 @@
35 35
 			<h1>Signup <small>Supporting text or tagline</small></h1>
36 36
 		</div>
37 37
 		<div class="row">
38  
-			<div class="span16">
  38
+			<div class="span12">
39 39
 <?php
40 40
 				$form = new kfforms("","post","","form-horizontal");
41 41
 				$form->section("");
143  sections/visitor/table.php
... ...
@@ -0,0 +1,143 @@
  1
+<div class="container">
  2
+	<div class="content">
  3
+		<div class="page-header">
  4
+			<h1>Sign In</h1>
  5
+		</div>
  6
+		<div class="row">
  7
+			<div class="span12">
  8
+				<div id="datatable" class="advancedsort">
  9
+					<table width=100% class="table table-striped table-bordered">
  10
+					<thead>
  11
+					<tr>
  12
+						<th>adfasdf</th>
  13
+						<th>adsfafsd</th>
  14
+					</tr>
  15
+					</thead>
  16
+					<tbody>
  17
+					<tr>
  18
+						<td>3 afdsadsfas</td>
  19
+						<td>adfadfs</td>
  20
+					</tr>
  21
+					<tr>
  22
+						<td>5 afdsadsfas</td>
  23
+						<td>adfadfs</td>
  24
+					</tr>
  25
+					<tr>
  26
+						<td>6 afdsadsfas</td>
  27
+						<td>adfadfs</td>
  28
+					</tr>
  29
+					<tr>
  30
+						<td>1 afdsadsfas</td>
  31
+						<td>adfadfs</td>
  32
+					</tr>
  33
+					<tr>
  34
+						<td>2 afdsadsfas</td>
  35
+						<td>adfadfs</td>
  36
+					</tr>
  37
+					<tr>
  38
+						<td>3 afdsadsfas</td>
  39
+						<td>adfadfs</td>
  40
+					</tr>
  41
+					<tr>
  42
+						<td>5 afdsadsfas</td>
  43
+						<td>adfadfs</td>
  44
+					</tr>
  45
+					<tr>
  46
+						<td>6 afdsadsfas</td>
  47
+						<td>adfadfs</td>
  48
+					</tr>
  49
+					<tr>
  50
+						<td>1 afdsadsfas</td>
  51
+						<td>adfadfs</td>
  52
+					</tr>
  53
+					<tr>
  54
+						<td>2 afdsadsfas</td>
  55
+						<td>adfadfs</td>
  56
+					</tr>
  57
+					<tr>
  58
+						<td>3 afdsadsfas</td>
  59
+						<td>adfadfs</td>
  60
+					</tr>
  61
+					<tr>
  62
+						<td>5 afdsadsfas</td>
  63
+						<td>adfadfs</td>
  64
+					</tr>
  65
+					<tr>
  66
+						<td>6 afdsadsfas</td>
  67
+						<td>adfadfs</td>
  68
+					</tr>
  69
+					<tr>
  70
+						<td>1 afdsadsfas</td>
  71
+						<td>adfadfs</td>
  72
+					</tr>
  73
+					<tr>
  74
+						<td>2 afdsadsfas</td>
  75
+						<td>adfadfs</td>
  76
+					</tr>
  77
+					<tr>
  78
+						<td>3 afdsadsfas</td>
  79
+						<td>adfadfs</td>
  80
+					</tr>
  81
+					<tr>
  82
+						<td>5 afdsadsfas</td>
  83
+						<td>adfadfs</td>
  84
+					</tr>
  85
+					<tr>
  86
+						<td>6 afdsadsfas</td>
  87
+						<td>adfadfs</td>
  88
+					</tr>
  89
+					<tr>
  90
+						<td>1 afdsadsfas</td>
  91
+						<td>adfadfs</td>
  92
+					</tr>
  93
+					<tr>
  94
+						<td>2 afdsadsfas</td>
  95
+						<td>adfadfs</td>
  96
+					</tr>
  97
+					<tr>
  98
+						<td>3 afdsadsfas</td>
  99
+						<td>adfadfs</td>
  100
+					</tr>
  101
+					<tr>
  102
+						<td>5 afdsadsfas</td>
  103
+						<td>adfadfs</td>
  104
+					</tr>
  105
+					<tr>
  106
+						<td>6 afdsadsfas</td>
  107
+						<td>adfadfs</td>
  108
+					</tr>
  109
+					<tr>
  110
+						<td>1 afdsadsfas</td>
  111
+						<td>adfadfs</td>
  112
+					</tr>
  113
+					<tr>
  114
+						<td>2 afdsadsfas</td>
  115
+						<td>adfadfs</td>
  116
+					</tr>
  117
+					<tr>
  118
+						<td>3 afdsadsfas</td>
  119
+						<td>adfadfs</td>
  120
+					</tr>
  121
+					<tr>
  122
+						<td>5 afdsadsfas</td>
  123
+						<td>adfadfs</td>
  124
+					</tr>
  125
+					<tr>
  126
+						<td>6 afdsadsfas</td>
  127
+						<td>adfadfs</td>
  128
+					</tr>
  129
+					<tr>
  130
+						<td>1 afdsadsfas</td>
  131
+						<td>adfadfs</td>
  132
+					</tr>
  133
+					<tr>
  134
+						<td>2 afdsadsfas</td>
  135
+						<td>adfadfs</td>
  136
+					</tr>
  137
+					</tbody>
  138
+					</table>
  139
+				</div>
  140
+			</div>
  141
+		</div>
  142
+	</div>
  143
+</div>

0 notes on commit a6cd853

Please sign in to comment.
Something went wrong with that request. Please try again.