jquery-tablesorter 1.19.3 → 1.19.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/jquery-tablesorter/version.rb +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/addons/pager/jquery.tablesorter.pager.js +26 -22
- data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.combined.js +25 -16
- data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.js +24 -15
- data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.widgets.js +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-month.js +18 -19
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-range.js +87 -3
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-two-digit-year.js +4 -5
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-weekday.js +28 -30
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-image.js +1 -0
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-input-select.js +80 -17
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-type-insideRange.js +6 -4
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-math.js +50 -18
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-pager.js +501 -449
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-print.js +20 -8
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-sortTbodies.js +2 -2
- metadata +2 -2
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! Parser: two digit year - updated
|
1
|
+
/*! Parser: two digit year - updated 11/22/2015 (v2.24.6) */
|
2
2
|
/* Demo: http://mottie.github.io/tablesorter/docs/example-parsers-dates.html */
|
3
3
|
/*jshint jquery:true */
|
4
4
|
;(function($){
|
@@ -13,10 +13,9 @@
|
|
13
13
|
ts = $.tablesorter,
|
14
14
|
now = new Date().getFullYear();
|
15
15
|
|
16
|
-
ts.dates
|
17
|
-
|
18
|
-
|
19
|
-
});
|
16
|
+
if ( !ts.dates ) { ts.dates = {}; }
|
17
|
+
ts.dates.regxxxxyy = /(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{2})/;
|
18
|
+
ts.dates.regyyxxxx = /(\d{2})[\/\s](\d{1,2})[\/\s](\d{1,2})/;
|
20
19
|
|
21
20
|
ts.formatDate = function(s, regex, format, table){
|
22
21
|
if (s) {
|
@@ -1,40 +1,38 @@
|
|
1
|
-
/*! Parser: weekday - updated 11/
|
1
|
+
/*! Parser: weekday - updated 11/22/2015 (v2.24.6) */
|
2
2
|
/* Demo: http://jsfiddle.net/Mottie/abkNM/4169/ */
|
3
3
|
/*jshint jquery:true */
|
4
4
|
;(function($){
|
5
5
|
'use strict';
|
6
6
|
|
7
7
|
var ts = $.tablesorter;
|
8
|
-
ts.dates = $.extend( true, {}, {
|
9
|
-
// See http://mottie.github.io/tablesorter/docs/example-widget-grouping.html
|
10
|
-
// for details on how to use CLDR data for a locale to add data for this parser
|
11
|
-
// CLDR returns { sun: "Sun", mon: "Mon", tue: "Tue", wed: "Wed", thu: "Thu", ... }
|
12
|
-
weekdays : {
|
13
|
-
'en' : {
|
14
|
-
'sun' : 'Sun',
|
15
|
-
'mon' : 'Mon',
|
16
|
-
'tue' : 'Tue',
|
17
|
-
'wed' : 'Wed',
|
18
|
-
'thu' : 'Thu',
|
19
|
-
'fri' : 'Fri',
|
20
|
-
'sat' : 'Sat'
|
21
|
-
}
|
22
|
-
},
|
23
|
-
|
24
|
-
// set table.config.weekStarts to change weekday start date for your locale
|
25
|
-
// cross-reference of a date on which the week starts on a...
|
26
|
-
// https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/weekData.json
|
27
|
-
weekStartList : {
|
28
|
-
'sun' : '1995', // Sun 1/1/1995
|
29
|
-
'mon' : '1996', // Mon 1/1/1996
|
30
|
-
'fri' : '1999', // Friday 1/1/1999
|
31
|
-
'sat' : '2000' // Sat 1/1/2000
|
32
|
-
},
|
33
|
-
|
34
|
-
// do not modify this array; it is used for cross referencing
|
35
|
-
weekdaysXref : [ 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat' ]
|
36
8
|
|
37
|
-
|
9
|
+
if ( !ts.dates ) { ts.dates = {}; }
|
10
|
+
if ( !ts.dates.weekdays ) { ts.dates.weekdays = {}; }
|
11
|
+
// See http://mottie.github.io/tablesorter/docs/example-widget-grouping.html
|
12
|
+
// for details on how to use CLDR data for a locale to add data for this parser
|
13
|
+
// CLDR returns { sun: "Sun", mon: "Mon", tue: "Tue", wed: "Wed", thu: "Thu", ... }
|
14
|
+
ts.dates.weekdays.en = {
|
15
|
+
'sun' : 'Sun',
|
16
|
+
'mon' : 'Mon',
|
17
|
+
'tue' : 'Tue',
|
18
|
+
'wed' : 'Wed',
|
19
|
+
'thu' : 'Thu',
|
20
|
+
'fri' : 'Fri',
|
21
|
+
'sat' : 'Sat'
|
22
|
+
};
|
23
|
+
// set table.config.weekStarts to change weekday start date for your locale
|
24
|
+
// cross-reference of a date on which the week starts on a...
|
25
|
+
// https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/weekData.json
|
26
|
+
// locale agnostic
|
27
|
+
ts.dates.weekStartList = {
|
28
|
+
'sun' : '1995', // Sun 1/1/1995
|
29
|
+
'mon' : '1996', // Mon 1/1/1996
|
30
|
+
'fri' : '1999', // Friday 1/1/1999
|
31
|
+
'sat' : '2000' // Sat 1/1/2000
|
32
|
+
};
|
33
|
+
// do not modify this array; it is used for cross referencing weekdays
|
34
|
+
// locale agnostic
|
35
|
+
ts.dates.weekdaysXref = [ 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat' ];
|
38
36
|
|
39
37
|
ts.addParser({
|
40
38
|
id: 'weekday',
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! Parser: input & select - updated
|
1
|
+
/*! Parser: input & select - updated 11/22/2015 (v2.24.6) *//*
|
2
2
|
* for jQuery 1.7+ & tablesorter 2.7.11+
|
3
3
|
* Demo: http://mottie.github.com/tablesorter/docs/example-widget-grouping.html
|
4
4
|
*/
|
@@ -10,7 +10,8 @@
|
|
10
10
|
// do something here to update your server, if needed
|
11
11
|
// event = change event object
|
12
12
|
// $table = jQuery object of the table that was just updated
|
13
|
-
// $input = jQuery object of the input or select that was modified
|
13
|
+
// $input = jQuery object(s) of the input or select that was modified; in v2.24.6,
|
14
|
+
// if the thead has a checkbox, $input may include multiple elements
|
14
15
|
};
|
15
16
|
|
16
17
|
// Custom parser for parsing input values
|
@@ -125,22 +126,20 @@
|
|
125
126
|
// you can change it to use delegate (v1.4.3+) or live (v1.3+) as desired
|
126
127
|
// if this code interferes somehow, target the specific table $('#mytable'), instead of $('table')
|
127
128
|
$( function() {
|
129
|
+
if ( !$.fn.on ) { return; }
|
128
130
|
$( 'table' ).on( 'tablesorter-initialized updateComplete', function() {
|
129
|
-
|
130
|
-
|
131
|
+
this.tablesorterBusy = false;
|
132
|
+
var namespace = '.parser-forms';
|
133
|
+
// bind to .tablesorter (default class name)
|
134
|
+
$( this ).children( 'tbody' )
|
135
|
+
.off( namespace )
|
136
|
+
.on( 'mouseleave' + namespace, function( event ) {
|
131
137
|
// make sure we restore original values (trigger blur)
|
132
138
|
// isTbody is needed to prevent the select from closing in IE
|
133
139
|
// see https://connect.microsoft.com/IE/feedbackdetail/view/962618/
|
134
|
-
if (
|
140
|
+
if ( event.target.nodeName === 'TBODY' ) {
|
135
141
|
$( ':focus' ).blur();
|
136
142
|
}
|
137
|
-
return;
|
138
|
-
};
|
139
|
-
// bind to .tablesorter (default class name)
|
140
|
-
$( this ).children( 'tbody' )
|
141
|
-
.off( namespace )
|
142
|
-
.on( 'mouseleave' + namespace, function( event ) {
|
143
|
-
restoreValue( event.target.nodeName === 'TBODY' );
|
144
143
|
})
|
145
144
|
.on( 'focus' + namespace, 'select, input, textarea', function() {
|
146
145
|
$( this ).data( 'ts-original-value', this.value );
|
@@ -162,28 +161,92 @@
|
|
162
161
|
( event.target.nodeName === 'INPUT' || event.target.nodeName === 'TEXTAREA' && event.altKey ) ) ) {
|
163
162
|
var undef,
|
164
163
|
$target = $( event.target ),
|
164
|
+
isCheckbox = event.target.type === 'checkbox',
|
165
165
|
$cell = $target.closest( 'td' ),
|
166
166
|
$table = $cell.closest( 'table' ),
|
167
167
|
indx = $cell[ 0 ].cellIndex,
|
168
168
|
c = $table[ 0 ].config || false,
|
169
|
+
busy = $table.length && $table[ 0 ].tablesorterBusy,
|
169
170
|
$hdr = c && c.$headerIndexed && c.$headerIndexed[ indx ] || [],
|
170
|
-
val = $target.val();
|
171
|
-
// abort if not a tablesorter table, or don't use updateCell if column is set
|
171
|
+
val = isCheckbox ? event.target.checked : $target.val();
|
172
|
+
// abort if not a tablesorter table, or busy, or don't use updateCell if column is set
|
172
173
|
// to 'sorter-false' and 'filter-false', or column is set to 'parser-false'
|
173
|
-
if ( $hdr.length && ( $hdr.hasClass( 'parser-false' ) ||
|
174
|
-
( $hdr.hasClass( 'sorter-false' ) && $hdr.hasClass( 'filter-false' ) ) )
|
174
|
+
if ( $.isEmptyObject( c ) || busy !== false || $hdr.length && ( $hdr.hasClass( 'parser-false' ) ||
|
175
|
+
( $hdr.hasClass( 'sorter-false' ) && $hdr.hasClass( 'filter-false' ) ) ) ||
|
176
|
+
// table already updating; get out of here, we might be in an endless loop (in IE)! See #971
|
177
|
+
( event.type === 'change' && c.table.isUpdating ) ) {
|
175
178
|
return;
|
176
179
|
}
|
177
180
|
// ignore change event if nothing changed
|
178
|
-
if ( c && val !== $target.data( 'ts-original-value' ) ||
|
181
|
+
if ( c && val !== $target.data( 'ts-original-value' ) || isCheckbox ) {
|
179
182
|
$target.data( 'ts-original-value', val );
|
183
|
+
$table[ 0 ].tablesorterBusy = true;
|
180
184
|
// pass undefined resort value so it falls back to config.resort setting
|
181
185
|
$.tablesorter.updateCell( c, $cell, undef, function() {
|
182
186
|
updateServer( event, $table, $target );
|
187
|
+
$table[ 0 ].tablesorterBusy = false;
|
183
188
|
});
|
184
189
|
}
|
185
190
|
}
|
186
191
|
});
|
192
|
+
|
193
|
+
// add code for a checkbox in the header to set/unset all checkboxes in a column
|
194
|
+
if ( $( this ).children( 'thead' ).find( 'input[type="checkbox"]' ) ) {
|
195
|
+
$( this )
|
196
|
+
.off( namespace )
|
197
|
+
.on( 'tablesorter-ready' + namespace, function() {
|
198
|
+
var checkboxClass, $rows, len,
|
199
|
+
$table = $( this ),
|
200
|
+
c = $table.length && $table[ 0 ].config;
|
201
|
+
if ( !$.isEmptyObject( c ) ) {
|
202
|
+
this.tablesorterBusy = true;
|
203
|
+
checkboxClass = c && c.checkboxClass || 'checked';
|
204
|
+
$rows = $table.children( 'tbody' ).children( ':visible' ); // (include child rows?)
|
205
|
+
len = $rows.length;
|
206
|
+
// set indeterminate state on header checkbox
|
207
|
+
$( this ).children( 'thead' ).find( 'input[type="checkbox"]' ).each( function() {
|
208
|
+
var column = $( this ).closest( 'td, th' ).attr( 'data-column' ),
|
209
|
+
vis = $rows.filter( '.' + checkboxClass + '-' + column ).length,
|
210
|
+
allChecked = vis === len;
|
211
|
+
if ( vis === 0 || allChecked ) {
|
212
|
+
this.checked = allChecked;
|
213
|
+
this.indeterminate = false;
|
214
|
+
} else {
|
215
|
+
this.indeterminate = true;
|
216
|
+
}
|
217
|
+
});
|
218
|
+
this.tablesorterBusy = false;
|
219
|
+
}
|
220
|
+
})
|
221
|
+
.children( 'thead' )
|
222
|
+
.off( namespace )
|
223
|
+
// modified from http://jsfiddle.net/abkNM/6163/
|
224
|
+
.on( 'change' + namespace, 'input[type="checkbox"]', function( event ) {
|
225
|
+
var undef, onlyVisible, column, $target,
|
226
|
+
$checkbox = $( this ),
|
227
|
+
$table = $checkbox.closest( 'table' ),
|
228
|
+
c = $table.length && $table[ 0 ].config,
|
229
|
+
isChecked = this.checked;
|
230
|
+
if ( $table.length && c && !$table[ 0 ].tablesorterBusy ) {
|
231
|
+
column = parseInt( $checkbox.closest( 'td, th' ).attr( 'data-column' ), 10 );
|
232
|
+
onlyVisible = $table.length && c.checkboxVisible;
|
233
|
+
$table[ 0 ].tablesorterBusy = true; // prevent "change" event from calling updateCell numerous times (see #971)
|
234
|
+
$target = $table
|
235
|
+
.children( 'tbody' )
|
236
|
+
.children( 'tr' + ( typeof onlyVisible === 'undefined' || onlyVisible === true ? ':visible' : '' ) )
|
237
|
+
.children( ':nth-child(' + ( column + 1 ) + ')' )
|
238
|
+
.find( 'input[type="checkbox"]' )
|
239
|
+
.prop( 'checked', isChecked );
|
240
|
+
$.tablesorter.update( c, undef, function() {
|
241
|
+
updateServer( event, $table, $target );
|
242
|
+
$table[ 0 ].tablesorterBusy = false;
|
243
|
+
});
|
244
|
+
}
|
245
|
+
// update already going on, don't do anything!
|
246
|
+
return false;
|
247
|
+
});
|
248
|
+
}
|
249
|
+
|
187
250
|
});
|
188
251
|
});
|
189
252
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! Widget: filter, insideRange filter type - updated
|
1
|
+
/*! Widget: filter, insideRange filter type - updated 11/22/2015 (v2.24.6) */
|
2
2
|
;(function($){
|
3
3
|
'use strict';
|
4
4
|
|
@@ -17,6 +17,8 @@
|
|
17
17
|
ts.filter.types.insideRange = function( c, data ) {
|
18
18
|
if ( isDigit.test( data.iFilter ) && range.test( data.iExact ) ) {
|
19
19
|
var t, val, low, high,
|
20
|
+
index = data.index,
|
21
|
+
cell = data.$cells[ index ],
|
20
22
|
parts = data.iExact.split( range ),
|
21
23
|
format = c.parsers[data.index].format;
|
22
24
|
// the cell does not contain a range
|
@@ -24,9 +26,9 @@
|
|
24
26
|
return null;
|
25
27
|
}
|
26
28
|
// format each side part of the range using the assigned parser
|
27
|
-
low = parseNumber( format( parts[0], c.table ) );
|
28
|
-
high = parseNumber( format( parts[1], c.table ) );
|
29
|
-
val = parseNumber( format( data.iFilter, c.table ) );
|
29
|
+
low = parseNumber( format( parts[0], c.table, cell, index ) );
|
30
|
+
high = parseNumber( format( parts[1], c.table, cell, index ) );
|
31
|
+
val = parseNumber( format( data.iFilter, c.table, cell, index ) );
|
30
32
|
if ( high < low ) {
|
31
33
|
// swap high & low
|
32
34
|
t = high; high = low; low = t;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! Widget: math - updated 11/
|
1
|
+
/*! Widget: math - updated 11/22/2015 (v2.24.6) *//*
|
2
2
|
* Requires tablesorter v2.16+ and jQuery 1.7+
|
3
3
|
* by Rob Garrison
|
4
4
|
*/
|
@@ -40,11 +40,17 @@
|
|
40
40
|
|
41
41
|
// get all of the row numerical values in an arry
|
42
42
|
getRow : function( c, $el ) {
|
43
|
-
var
|
43
|
+
var $cells,
|
44
|
+
wo = c.widgetOptions,
|
44
45
|
arry = [],
|
45
46
|
$row = $el.closest( 'tr' ),
|
47
|
+
isFiltered = $row.hasClass( wo.filter_filteredRow || 'filtered' ),
|
48
|
+
hasFilter = wo.math_rowFilter;
|
49
|
+
if ( hasFilter ) {
|
50
|
+
$row = $row.filter( hasFilter );
|
51
|
+
}
|
52
|
+
if ( !isFiltered || hasFilter ) {
|
46
53
|
$cells = $row.children().not( '[' + wo.math_dataAttrib + '=ignore]' );
|
47
|
-
if ( !$row.hasClass( wo.filter_filteredRow || 'filtered' ) ) {
|
48
54
|
if ( wo.math_ignore.length ) {
|
49
55
|
$cells = $cells.not( '[data-column=' + wo.math_ignore.join( '],[data-column=' ) + ']' );
|
50
56
|
}
|
@@ -57,9 +63,10 @@
|
|
57
63
|
|
58
64
|
// get all of the column numerical values in an arry
|
59
65
|
getColumn : function( c, $el, type ) {
|
60
|
-
var index, $t, len, $mathRows, mathAbove,
|
66
|
+
var index, $t, $tr, len, $mathRows, mathAbove,
|
61
67
|
arry = [],
|
62
68
|
wo = c.widgetOptions,
|
69
|
+
hasFilter = wo.math_rowFilter,
|
63
70
|
mathAttr = wo.math_dataAttrib,
|
64
71
|
filtered = wo.filter_filteredRow || 'filtered',
|
65
72
|
cIndex = parseInt( $el.attr( 'data-column' ), 10 ),
|
@@ -71,11 +78,15 @@
|
|
71
78
|
len = $rows.index( $row );
|
72
79
|
index = len;
|
73
80
|
while ( index >= 0 ) {
|
74
|
-
$
|
81
|
+
$tr = $rows.eq( index );
|
82
|
+
if ( hasFilter ) {
|
83
|
+
$tr = $tr.filter( wo.math_rowFilter );
|
84
|
+
}
|
85
|
+
$t = $tr.children().filter( '[data-column=' + cIndex + ']' );
|
75
86
|
mathAbove = $t.filter( '[' + mathAttr + '^=above]' ).length;
|
76
87
|
// ignore filtered rows & rows with data-math="ignore" (and starting row)
|
77
|
-
if ( (
|
78
|
-
$
|
88
|
+
if ( ( ( !$tr.hasClass( filtered ) || hasFilter ) &&
|
89
|
+
$tr.not( '[' + mathAttr + '=ignore]' ).length &&
|
79
90
|
index !== len ) ||
|
80
91
|
mathAbove && index !== len ) {
|
81
92
|
// stop calculating 'above', when encountering another 'above'
|
@@ -91,12 +102,16 @@
|
|
91
102
|
len = $rows.length;
|
92
103
|
// index + 1 to ignore starting node
|
93
104
|
for ( index = $rows.index( $row ) + 1; index < len; index++ ) {
|
94
|
-
$
|
105
|
+
$tr = $rows.eq( index );
|
106
|
+
if ( hasFilter ) {
|
107
|
+
$tr = $tr.filter( hasFilter );
|
108
|
+
}
|
109
|
+
$t = $tr.children().filter( '[data-column=' + cIndex + ']' );
|
95
110
|
if ( $t.filter( '[' + mathAttr + '^=below]' ).length ) {
|
96
111
|
break;
|
97
112
|
}
|
98
|
-
if (
|
99
|
-
$
|
113
|
+
if ( ( !$tr.hasClass( filtered ) || hasFilter ) &&
|
114
|
+
$tr.not( '[' + mathAttr + '=ignore]' ).length &&
|
100
115
|
$t.length ) {
|
101
116
|
arry.push( math.processText( c, $t ) );
|
102
117
|
}
|
@@ -106,8 +121,12 @@
|
|
106
121
|
$mathRows = $rows.not( '[' + mathAttr + '=ignore]' );
|
107
122
|
len = $mathRows.length;
|
108
123
|
for ( index = 0; index < len; index++ ) {
|
109
|
-
$
|
110
|
-
if (
|
124
|
+
$tr = $mathRows.eq( index );
|
125
|
+
if ( hasFilter ) {
|
126
|
+
$tr = $tr.filter( hasFilter );
|
127
|
+
}
|
128
|
+
$t = $tr.children().filter( '[data-column=' + cIndex + ']' );
|
129
|
+
if ( ( !$tr.hasClass( filtered ) || hasFilter ) &&
|
111
130
|
$t.not( '[' + mathAttr + '^=above],[' + mathAttr + '^=below],[' + mathAttr + '^=col]' ).length &&
|
112
131
|
!$t.is( $el ) ) {
|
113
132
|
arry.push( math.processText( c, $t ) );
|
@@ -124,11 +143,15 @@
|
|
124
143
|
wo = c.widgetOptions,
|
125
144
|
mathAttr = wo.math_dataAttrib,
|
126
145
|
filtered = wo.filter_filteredRow || 'filtered',
|
146
|
+
hasFilter = wo.filter_rowFilter,
|
127
147
|
$rows = c.$table.children( 'tbody' ).children().not( '[' + mathAttr + '=ignore]' );
|
128
148
|
rowLen = $rows.length;
|
129
149
|
for ( rowIndex = 0; rowIndex < rowLen; rowIndex++ ) {
|
130
150
|
$row = $rows.eq( rowIndex );
|
131
|
-
if (
|
151
|
+
if ( hasFilter ) {
|
152
|
+
$row = $row.filter( hasFilter );
|
153
|
+
}
|
154
|
+
if ( !$row.hasClass( filtered ) || hasFilter ) {
|
132
155
|
$cells = $row.children().not( '[' + mathAttr + '=ignore]' );
|
133
156
|
cellLen = $cells.length;
|
134
157
|
// $row.children().each(function(){
|
@@ -157,7 +180,7 @@
|
|
157
180
|
recalculate : function(c, wo, init) {
|
158
181
|
if ( c && ( !wo.math_isUpdating || init ) ) {
|
159
182
|
|
160
|
-
var time, mathAttr, $mathCells;
|
183
|
+
var undef, time, mathAttr, $mathCells;
|
161
184
|
if ( c.debug ) {
|
162
185
|
time = new Date();
|
163
186
|
}
|
@@ -192,7 +215,9 @@
|
|
192
215
|
}
|
193
216
|
|
194
217
|
// update internal cache
|
195
|
-
ts.update( c )
|
218
|
+
ts.update( c, undef, function(){
|
219
|
+
math.updateComplete( c );
|
220
|
+
});
|
196
221
|
|
197
222
|
if ( c.debug ) {
|
198
223
|
console.log( 'Math widget update completed' + ts.benchmark( time ) );
|
@@ -200,6 +225,12 @@
|
|
200
225
|
}
|
201
226
|
},
|
202
227
|
|
228
|
+
updateComplete : function( c ) {
|
229
|
+
var wo = c.widgetOptions;
|
230
|
+
if ( wo.math_isUpdating && c.debug && console.groupEnd ) { console.groupEnd(); }
|
231
|
+
wo.math_isUpdating = false;
|
232
|
+
},
|
233
|
+
|
203
234
|
mathType : function( c, $cells, priority ) {
|
204
235
|
if ( $cells.length ) {
|
205
236
|
var formula, result, $el, arry, getAll, $targetCells, index, len,
|
@@ -488,7 +519,9 @@
|
|
488
519
|
math_suffix : '',
|
489
520
|
// no matching math elements found (text added to cell)
|
490
521
|
math_none : 'N/A',
|
491
|
-
math_event : 'recalculate'
|
522
|
+
math_event : 'recalculate',
|
523
|
+
// use this filter to target specific rows (e.g. ':visible', or ':not(.empty-row)')
|
524
|
+
math_rowFilter: ''
|
492
525
|
},
|
493
526
|
init : function( table, thisWidget, c, wo ) {
|
494
527
|
// filterEnd fires after updateComplete
|
@@ -507,8 +540,7 @@
|
|
507
540
|
})
|
508
541
|
.on( update + '.tsmath', function() {
|
509
542
|
setTimeout( function(){
|
510
|
-
|
511
|
-
wo.math_isUpdating = false;
|
543
|
+
math.updateComplete( c );
|
512
544
|
}, 40 );
|
513
545
|
});
|
514
546
|
wo.math_isUpdating = false;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! Widget: Pager - updated 11/
|
1
|
+
/*! Widget: Pager - updated 11/22/2015 (v2.24.6) */
|
2
2
|
/* Requires tablesorter v2.8+ and jQuery 1.7+
|
3
3
|
* by Rob Garrison
|
4
4
|
*/
|
@@ -11,9 +11,10 @@
|
|
11
11
|
ts.addWidget({
|
12
12
|
id: 'pager',
|
13
13
|
priority: 55, // load pager after filter widget
|
14
|
-
options
|
14
|
+
options: {
|
15
15
|
// output default: '{page}/{totalPages}'
|
16
|
-
// possible variables: {size}, {page}, {totalPages}, {filteredPages}, {startRow},
|
16
|
+
// possible variables: {size}, {page}, {totalPages}, {filteredPages}, {startRow},
|
17
|
+
// {endRow}, {filteredRows} and {totalRows}
|
17
18
|
pager_output: '{startRow} to {endRow} of {totalRows} rows', // '{page}/{totalPages}'
|
18
19
|
|
19
20
|
// apply disabled classname to the pager arrows when the rows at either extreme is visible
|
@@ -32,14 +33,15 @@
|
|
32
33
|
// Number of options to include in the pager number selector
|
33
34
|
pager_maxOptionSize: 20,
|
34
35
|
|
35
|
-
// Save pager page & size if the storage script is loaded (requires $.tablesorter.storage
|
36
|
+
// Save pager page & size if the storage script is loaded (requires $.tablesorter.storage
|
37
|
+
// in jquery.tablesorter.widgets.js)
|
36
38
|
pager_savePages: true,
|
37
39
|
|
38
40
|
// defines custom storage key
|
39
41
|
pager_storageKey: 'tablesorter-pager',
|
40
42
|
|
41
|
-
// if true, the table will remain the same height no matter how many records are displayed.
|
42
|
-
// table row set to a height to compensate; default is false
|
43
|
+
// if true, the table will remain the same height no matter how many records are displayed.
|
44
|
+
// The space is made up by an empty table row set to a height to compensate; default is false
|
43
45
|
pager_fixedHeight: false,
|
44
46
|
|
45
47
|
// count child rows towards the set page size? (set true if it is a visible table row within the pager)
|
@@ -48,7 +50,8 @@
|
|
48
50
|
pager_countChildRows: false,
|
49
51
|
|
50
52
|
// remove rows from the table to speed up the sort of large tables.
|
51
|
-
// setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with
|
53
|
+
// setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with
|
54
|
+
// the pager enabled.
|
52
55
|
pager_removeRows: false, // removing rows in larger tables speeds up the sort
|
53
56
|
|
54
57
|
// use this format: 'http://mydatabase.com?page={page}&size={size}&{sortList:col}&{filterList:fcol}'
|
@@ -60,7 +63,7 @@
|
|
60
63
|
pager_ajaxUrl: null,
|
61
64
|
|
62
65
|
// modify the url after all processing has been applied
|
63
|
-
pager_customAjaxUrl: function(table, url) { return url; },
|
66
|
+
pager_customAjaxUrl: function( table, url ) { return url; },
|
64
67
|
|
65
68
|
// ajax error callback from $.tablesorter.showError function
|
66
69
|
// pager_ajaxError: function( config, xhr, settings, exception ){ return exception; };
|
@@ -88,13 +91,15 @@
|
|
88
91
|
// ],
|
89
92
|
// [ "header1", "header2", ... "headerN" ] // optional
|
90
93
|
// ]
|
91
|
-
pager_ajaxProcessing: function(ajax){ return [ 0, [], null ]; },
|
94
|
+
pager_ajaxProcessing: function( ajax ){ return [ 0, [], null ]; },
|
92
95
|
|
93
96
|
// css class names of pager arrows
|
94
97
|
pager_css: {
|
95
98
|
container : 'tablesorter-pager',
|
96
|
-
|
97
|
-
|
99
|
+
// error information row (don't include period at beginning)
|
100
|
+
errorRow : 'tablesorter-errorRow',
|
101
|
+
// class added to arrows @ extremes (i.e. prev/first arrows 'disabled' on first page)
|
102
|
+
disabled : 'disabled'
|
98
103
|
},
|
99
104
|
|
100
105
|
// jQuery selectors
|
@@ -109,27 +114,27 @@
|
|
109
114
|
pageSize : '.pagesize' // page size selector - select dropdown that sets the 'size' option
|
110
115
|
}
|
111
116
|
},
|
112
|
-
init: function(table){
|
113
|
-
tsp.init(table);
|
117
|
+
init: function( table ) {
|
118
|
+
tsp.init( table );
|
114
119
|
},
|
115
120
|
// only update to complete sorter initialization
|
116
|
-
format: function(table, c){
|
117
|
-
if (!(c.pager && c.pager.initialized)){
|
118
|
-
return tsp.initComplete(
|
121
|
+
format: function( table, c ) {
|
122
|
+
if ( !( c.pager && c.pager.initialized ) ) {
|
123
|
+
return tsp.initComplete( c );
|
119
124
|
}
|
120
|
-
tsp.moveToPage(
|
125
|
+
tsp.moveToPage( c, c.pager, false );
|
121
126
|
},
|
122
|
-
remove: function(table, c, wo, refreshing){
|
123
|
-
tsp.destroyPager(
|
127
|
+
remove: function( table, c, wo, refreshing ) {
|
128
|
+
tsp.destroyPager( c, refreshing );
|
124
129
|
}
|
125
130
|
});
|
126
131
|
|
127
132
|
/* pager widget functions */
|
128
133
|
tsp = ts.pager = {
|
129
134
|
|
130
|
-
init: function(table) {
|
135
|
+
init: function( table ) {
|
131
136
|
// check if tablesorter has initialized
|
132
|
-
if (table.hasInitialized && table.config.pager && table.config.pager.initialized) { return; }
|
137
|
+
if ( table.hasInitialized && table.config.pager && table.config.pager.initialized ) { return; }
|
133
138
|
var t,
|
134
139
|
c = table.config,
|
135
140
|
wo = c.widgetOptions,
|
@@ -150,55 +155,60 @@
|
|
150
155
|
// save original pager size
|
151
156
|
setSize: wo.pager_size,
|
152
157
|
setPage: wo.pager_startPage
|
153
|
-
}, c.pager);
|
158
|
+
}, c.pager );
|
154
159
|
|
155
160
|
// pager initializes multiple times before table has completed initialization
|
156
|
-
if (p.isInitializing) { return; }
|
161
|
+
if ( p.isInitializing ) { return; }
|
157
162
|
|
158
163
|
p.isInitializing = true;
|
159
|
-
if (c.debug) {
|
160
|
-
console.log('Pager: Initializing');
|
164
|
+
if ( c.debug ) {
|
165
|
+
console.log( 'Pager: Initializing' );
|
161
166
|
}
|
162
167
|
|
163
|
-
p.size = $.data(table, 'pagerLastSize') || wo.pager_size;
|
168
|
+
p.size = $.data( table, 'pagerLastSize' ) || wo.pager_size;
|
164
169
|
// added in case the pager is reinitialized after being destroyed.
|
165
|
-
p.$container = $(s.container).addClass(wo.pager_css.container).show();
|
170
|
+
p.$container = $( s.container ).addClass( wo.pager_css.container ).show();
|
166
171
|
// goto selector
|
167
|
-
p.$goto = p.$container.find(s.gotoPage); // goto is a reserved word #657
|
172
|
+
p.$goto = p.$container.find( s.gotoPage ); // goto is a reserved word #657
|
168
173
|
// page size selector
|
169
|
-
p.$size = p.$container.find(s.pageSize);
|
170
|
-
p.totalRows = c.$tbodies.eq(0
|
174
|
+
p.$size = p.$container.find( s.pageSize );
|
175
|
+
p.totalRows = c.$tbodies.eq( 0 )
|
176
|
+
.children( 'tr' )
|
177
|
+
.not( wo.pager_countChildRows ? '' : '.' + c.cssChildRow )
|
178
|
+
.length;
|
171
179
|
p.oldAjaxSuccess = p.oldAjaxSuccess || wo.pager_ajaxObject.success;
|
172
180
|
c.appender = tsp.appender;
|
173
181
|
p.initializing = true;
|
174
|
-
if (wo.pager_savePages && ts.storage) {
|
175
|
-
t = ts.storage(table, wo.pager_storageKey) || {}; // fixes #387
|
176
|
-
p.page = ( isNaN(t.page) ? p.page : t.page ) || p.setPage || 0;
|
177
|
-
p.size = ( isNaN(t.size) ? p.size : t.size ) || p.setSize || 10;
|
178
|
-
$.data(table, 'pagerLastSize', p.size);
|
182
|
+
if ( wo.pager_savePages && ts.storage ) {
|
183
|
+
t = ts.storage( table, wo.pager_storageKey ) || {}; // fixes #387
|
184
|
+
p.page = ( isNaN( t.page ) ? p.page : t.page ) || p.setPage || 0;
|
185
|
+
p.size = ( isNaN( t.size ) ? p.size : t.size ) || p.setSize || 10;
|
186
|
+
$.data( table, 'pagerLastSize', p.size );
|
179
187
|
}
|
180
188
|
|
181
189
|
// skipped rows
|
182
|
-
p.regexRows = new RegExp('(' + (wo.filter_filteredRow || 'filtered'
|
190
|
+
p.regexRows = new RegExp( '(' + ( wo.filter_filteredRow || 'filtered' ) + '|' +
|
191
|
+
c.selectorRemove.slice( 1 ) + '|' + c.cssChildRow + ')' );
|
183
192
|
|
184
193
|
// clear initialized flag
|
185
194
|
p.initialized = false;
|
186
195
|
// before initialization event
|
187
|
-
c.$table.trigger('pagerBeforeInitialized', c);
|
196
|
+
c.$table.trigger( 'pagerBeforeInitialized', c );
|
188
197
|
|
189
|
-
tsp.enablePager(
|
198
|
+
tsp.enablePager( c, false );
|
190
199
|
|
191
200
|
// p must have ajaxObject
|
192
|
-
p.ajaxObject = wo.pager_ajaxObject;
|
201
|
+
p.ajaxObject = wo.pager_ajaxObject;
|
193
202
|
p.ajaxObject.url = wo.pager_ajaxUrl;
|
194
203
|
|
195
204
|
if ( typeof wo.pager_ajaxUrl === 'string' ) {
|
196
205
|
// ajax pager; interact with database
|
197
206
|
p.ajax = true;
|
198
|
-
// When filtering with ajax, allow only custom filtering function, disable default filtering
|
207
|
+
// When filtering with ajax, allow only custom filtering function, disable default filtering
|
208
|
+
// since it will be done server side.
|
199
209
|
wo.filter_serversideFiltering = true;
|
200
210
|
c.serverSideSorting = true;
|
201
|
-
tsp.moveToPage(
|
211
|
+
tsp.moveToPage( c, p );
|
202
212
|
} else {
|
203
213
|
p.ajax = false;
|
204
214
|
// Regular pager; all rows stored in memory
|
@@ -207,30 +217,30 @@
|
|
207
217
|
|
208
218
|
},
|
209
219
|
|
210
|
-
initComplete: function(
|
220
|
+
initComplete: function( c ) {
|
211
221
|
var p = c.pager;
|
212
|
-
tsp.bindEvents(
|
213
|
-
tsp.setPageSize(c, 0); // page size 0 is ignored
|
214
|
-
if (!p.ajax) {
|
215
|
-
tsp.hideRowsSetup(
|
222
|
+
tsp.bindEvents( c );
|
223
|
+
tsp.setPageSize( c, 0 ); // page size 0 is ignored
|
224
|
+
if ( !p.ajax ) {
|
225
|
+
tsp.hideRowsSetup( c );
|
216
226
|
}
|
217
227
|
|
218
228
|
// pager initialized
|
219
229
|
p.initialized = true;
|
220
230
|
p.initializing = false;
|
221
231
|
p.isInitializing = false;
|
222
|
-
if (c.debug) {
|
223
|
-
console.log('Pager: Triggering pagerInitialized');
|
232
|
+
if ( c.debug ) {
|
233
|
+
console.log( 'Pager: Triggering pagerInitialized' );
|
224
234
|
}
|
225
235
|
c.$table.trigger( 'pagerInitialized', c );
|
226
236
|
// filter widget not initialized; it will update the output display & fire off the pagerComplete event
|
227
|
-
if ( !( c.widgetOptions.filter_initialized && ts.hasWidget(table, 'filter') ) ) {
|
237
|
+
if ( !( c.widgetOptions.filter_initialized && ts.hasWidget( c.table, 'filter' ) ) ) {
|
228
238
|
// if ajax, then don't fire off pagerComplete
|
229
|
-
tsp.updatePageDisplay(
|
239
|
+
tsp.updatePageDisplay( c, !p.ajax );
|
230
240
|
}
|
231
241
|
},
|
232
242
|
|
233
|
-
bindEvents: function(
|
243
|
+
bindEvents: function( c ) {
|
234
244
|
var ctrls, fxn,
|
235
245
|
p = c.pager,
|
236
246
|
wo = c.widgetOptions,
|
@@ -239,106 +249,108 @@
|
|
239
249
|
|
240
250
|
c.$table
|
241
251
|
.off( namespace )
|
242
|
-
.on('filterInit filterStart '.split(' ').join(namespace + ' '), function(e, filters) {
|
243
|
-
p.currentFilters = $.isArray(filters) ? filters : c.$table.data('lastSearch');
|
252
|
+
.on( 'filterInit filterStart '.split( ' ' ).join( namespace + ' ' ), function( e, filters ) {
|
253
|
+
p.currentFilters = $.isArray( filters ) ? filters : c.$table.data( 'lastSearch' );
|
244
254
|
// don't change page if filters are the same (pager updating, etc)
|
245
|
-
if (e.type === 'filterStart' && wo.pager_pageReset !== false &&
|
255
|
+
if ( e.type === 'filterStart' && wo.pager_pageReset !== false &&
|
256
|
+
( c.lastCombinedFilter || '' ) !== ( p.currentFilters || [] ).join( '' ) ) {
|
246
257
|
p.page = wo.pager_pageReset; // fixes #456 & #565
|
247
258
|
}
|
248
259
|
})
|
249
260
|
// update pager after filter widget completes
|
250
|
-
.on('filterEnd sortEnd '.split(' ').join(namespace + ' '), function() {
|
251
|
-
p.currentFilters = c.$table.data('lastSearch');
|
252
|
-
if (p.initialized || p.initializing) {
|
253
|
-
if (c.delayInit && c.rowsCopy && c.rowsCopy.length === 0) {
|
261
|
+
.on( 'filterEnd sortEnd '.split( ' ' ).join( namespace + ' ' ), function() {
|
262
|
+
p.currentFilters = c.$table.data( 'lastSearch' );
|
263
|
+
if ( p.initialized || p.initializing ) {
|
264
|
+
if ( c.delayInit && c.rowsCopy && c.rowsCopy.length === 0 ) {
|
254
265
|
// make sure we have a copy of all table rows once the cache has been built
|
255
|
-
tsp.updateCache(
|
266
|
+
tsp.updateCache( c );
|
256
267
|
}
|
257
|
-
tsp.updatePageDisplay(
|
258
|
-
// tsp.moveToPage(
|
259
|
-
ts.applyWidget( table );
|
268
|
+
tsp.updatePageDisplay( c, false );
|
269
|
+
// tsp.moveToPage( c, p, false ); <-- called when applyWidgets is triggered
|
270
|
+
ts.applyWidget( c.table );
|
260
271
|
}
|
261
272
|
})
|
262
|
-
.on('disablePager' + namespace, function(e){
|
273
|
+
.on( 'disablePager' + namespace, function( e ) {
|
263
274
|
e.stopPropagation();
|
264
|
-
tsp.showAllRows(
|
275
|
+
tsp.showAllRows( c );
|
265
276
|
})
|
266
|
-
.on('enablePager' + namespace, function(e){
|
277
|
+
.on( 'enablePager' + namespace, function( e ) {
|
267
278
|
e.stopPropagation();
|
268
|
-
tsp.enablePager(
|
279
|
+
tsp.enablePager( c, true );
|
269
280
|
})
|
270
|
-
.on('destroyPager' + namespace, function(e, refreshing){
|
281
|
+
.on( 'destroyPager' + namespace, function( e, refreshing ) {
|
271
282
|
e.stopPropagation();
|
272
283
|
// call removeWidget to make sure internal flags are modified.
|
273
|
-
ts.removeWidget( table, 'pager', false );
|
284
|
+
ts.removeWidget( c.table, 'pager', false );
|
274
285
|
})
|
275
|
-
.on('updateComplete' + namespace, function(e, table, triggered){
|
286
|
+
.on( 'updateComplete' + namespace, function( e, table, triggered ) {
|
276
287
|
e.stopPropagation();
|
277
288
|
// table can be unintentionally undefined in tablesorter v2.17.7 and earlier
|
278
289
|
// don't recalculate total rows/pages if using ajax
|
279
|
-
if (!table || triggered || p.ajax) { return; }
|
280
|
-
var $rows = c.$tbodies.eq(0).children('tr').not(c.selectorRemove);
|
281
|
-
p.totalRows = $rows.length -
|
290
|
+
if ( !table || triggered || p.ajax ) { return; }
|
291
|
+
var $rows = c.$tbodies.eq( 0 ).children( 'tr' ).not( c.selectorRemove );
|
292
|
+
p.totalRows = $rows.length -
|
293
|
+
( wo.pager_countChildRows ? 0 : $rows.filter( '.' + c.cssChildRow ).length );
|
282
294
|
p.totalPages = Math.ceil( p.totalRows / p.size );
|
283
|
-
if ($rows.length && c.rowsCopy && c.rowsCopy.length === 0) {
|
295
|
+
if ( $rows.length && c.rowsCopy && c.rowsCopy.length === 0 ) {
|
284
296
|
// make a copy of all table rows once the cache has been built
|
285
|
-
tsp.updateCache(
|
297
|
+
tsp.updateCache( c );
|
286
298
|
}
|
287
299
|
if ( p.page >= p.totalPages ) {
|
288
|
-
tsp.moveToLastPage(
|
300
|
+
tsp.moveToLastPage( c, p );
|
289
301
|
}
|
290
|
-
tsp.hideRows(
|
291
|
-
tsp.changeHeight(
|
302
|
+
tsp.hideRows( c );
|
303
|
+
tsp.changeHeight( c );
|
292
304
|
// update without triggering pagerComplete
|
293
|
-
tsp.updatePageDisplay(
|
305
|
+
tsp.updatePageDisplay( c, false );
|
294
306
|
// make sure widgets are applied - fixes #450
|
295
307
|
ts.applyWidget( table );
|
296
|
-
tsp.updatePageDisplay(
|
308
|
+
tsp.updatePageDisplay( c );
|
297
309
|
})
|
298
|
-
.on('pageSize refreshComplete '.split(' ').join(namespace + ' '), function(e, size){
|
310
|
+
.on( 'pageSize refreshComplete '.split( ' ' ).join( namespace + ' ' ), function( e, size ) {
|
299
311
|
e.stopPropagation();
|
300
|
-
tsp.setPageSize(c, tsp.parsePageSize( c, size, 'get' ));
|
301
|
-
tsp.hideRows(
|
302
|
-
tsp.updatePageDisplay(
|
312
|
+
tsp.setPageSize( c, tsp.parsePageSize( c, size, 'get' ) );
|
313
|
+
tsp.hideRows( c );
|
314
|
+
tsp.updatePageDisplay( c, false );
|
303
315
|
})
|
304
|
-
.on('pageSet pagerUpdate '.split(' ').join(namespace + ' '), function(e, num){
|
316
|
+
.on( 'pageSet pagerUpdate '.split( ' ' ).join( namespace + ' ' ), function( e, num ) {
|
305
317
|
e.stopPropagation();
|
306
318
|
// force pager refresh
|
307
|
-
if (e.type === 'pagerUpdate') {
|
319
|
+
if ( e.type === 'pagerUpdate' ) {
|
308
320
|
num = typeof num === 'undefined' ? p.page + 1 : num;
|
309
321
|
p.last.page = true;
|
310
322
|
}
|
311
|
-
p.page = (parseInt(num, 10) || 1) - 1;
|
312
|
-
tsp.moveToPage(
|
313
|
-
tsp.updatePageDisplay(
|
323
|
+
p.page = ( parseInt( num, 10 ) || 1 ) - 1;
|
324
|
+
tsp.moveToPage( c, p, true );
|
325
|
+
tsp.updatePageDisplay( c, false );
|
314
326
|
})
|
315
|
-
.on('pageAndSize' + namespace, function(e, page, size){
|
327
|
+
.on( 'pageAndSize' + namespace, function( e, page, size ) {
|
316
328
|
e.stopPropagation();
|
317
|
-
p.page = (parseInt(page, 10) || 1) - 1;
|
318
|
-
tsp.setPageSize(c, tsp.parsePageSize( c, size, 'get' ));
|
319
|
-
tsp.moveToPage(
|
320
|
-
tsp.hideRows(
|
321
|
-
tsp.updatePageDisplay(
|
329
|
+
p.page = ( parseInt(page, 10) || 1 ) - 1;
|
330
|
+
tsp.setPageSize( c, tsp.parsePageSize( c, size, 'get' ) );
|
331
|
+
tsp.moveToPage( c, p, true );
|
332
|
+
tsp.hideRows( c );
|
333
|
+
tsp.updatePageDisplay( c, false );
|
322
334
|
});
|
323
335
|
|
324
336
|
// clicked controls
|
325
337
|
ctrls = [ s.first, s.prev, s.next, s.last ];
|
326
338
|
fxn = [ 'moveToFirstPage', 'moveToPrevPage', 'moveToNextPage', 'moveToLastPage' ];
|
327
|
-
if (c.debug && !p.$container.length) {
|
328
|
-
console.warn('Pager: >> Container not found');
|
339
|
+
if ( c.debug && !p.$container.length ) {
|
340
|
+
console.warn( 'Pager: >> Container not found' );
|
329
341
|
}
|
330
|
-
p.$container.find(ctrls.join(','))
|
331
|
-
.attr('tabindex', 0)
|
332
|
-
.off('click' + namespace)
|
333
|
-
.on('click' + namespace, function(e){
|
342
|
+
p.$container.find( ctrls.join( ',' ) )
|
343
|
+
.attr( 'tabindex', 0 )
|
344
|
+
.off( 'click' + namespace )
|
345
|
+
.on( 'click' + namespace, function( e ) {
|
334
346
|
e.stopPropagation();
|
335
347
|
var i,
|
336
|
-
$c = $(this),
|
348
|
+
$c = $( this ),
|
337
349
|
l = ctrls.length;
|
338
|
-
if ( !$c.hasClass(wo.pager_css.disabled) ) {
|
339
|
-
for (i = 0; i < l; i++) {
|
340
|
-
if ($c.is(ctrls[i])) {
|
341
|
-
tsp[fxn[i]](
|
350
|
+
if ( !$c.hasClass( wo.pager_css.disabled ) ) {
|
351
|
+
for ( i = 0; i < l; i++ ) {
|
352
|
+
if ( $c.is( ctrls[ i ] ) ) {
|
353
|
+
tsp[ fxn[ i ] ]( c, p );
|
342
354
|
break;
|
343
355
|
}
|
344
356
|
}
|
@@ -347,145 +359,165 @@
|
|
347
359
|
|
348
360
|
if ( p.$goto.length ) {
|
349
361
|
p.$goto
|
350
|
-
.off('change' + namespace)
|
351
|
-
.on('change' + namespace, function(){
|
352
|
-
p.page = $(this).val() - 1;
|
353
|
-
tsp.moveToPage(
|
354
|
-
tsp.updatePageDisplay(
|
362
|
+
.off( 'change' + namespace )
|
363
|
+
.on( 'change' + namespace, function() {
|
364
|
+
p.page = $( this ).val() - 1;
|
365
|
+
tsp.moveToPage( c, p, true );
|
366
|
+
tsp.updatePageDisplay( c, false );
|
355
367
|
});
|
356
|
-
} else if (c.debug) {
|
357
|
-
console.warn('Pager: >> Goto selector not found');
|
368
|
+
} else if ( c.debug ) {
|
369
|
+
console.warn( 'Pager: >> Goto selector not found' );
|
358
370
|
}
|
359
371
|
|
360
372
|
if ( p.$size.length ) {
|
361
373
|
// setting an option as selected appears to cause issues with initial page size
|
362
|
-
p.$size.find('option').removeAttr('selected');
|
374
|
+
p.$size.find( 'option' ).removeAttr( 'selected' );
|
363
375
|
p.$size
|
364
|
-
.off('change' + namespace)
|
365
|
-
.on('change' + namespace, function() {
|
366
|
-
if ( !$(this).hasClass(wo.pager_css.disabled) ) {
|
367
|
-
var size = $(this).val();
|
376
|
+
.off( 'change' + namespace )
|
377
|
+
.on( 'change' + namespace, function() {
|
378
|
+
if ( !$( this ).hasClass( wo.pager_css.disabled ) ) {
|
379
|
+
var size = $( this ).val();
|
368
380
|
p.$size.val( size ); // in case there are more than one pagers
|
369
|
-
tsp.setPageSize(c, size);
|
370
|
-
tsp.changeHeight(
|
381
|
+
tsp.setPageSize( c, size );
|
382
|
+
tsp.changeHeight( c );
|
371
383
|
}
|
372
384
|
return false;
|
373
385
|
});
|
374
|
-
} else if (c.debug) {
|
386
|
+
} else if ( c.debug ) {
|
375
387
|
console.warn('Pager: >> Size selector not found');
|
376
388
|
}
|
377
389
|
|
378
390
|
},
|
379
391
|
|
380
392
|
// hide arrows at extremes
|
381
|
-
pagerArrows: function(c, disable) {
|
393
|
+
pagerArrows: function( c, disable ) {
|
382
394
|
var p = c.pager,
|
383
395
|
dis = !!disable,
|
384
396
|
first = dis || p.page === 0,
|
385
|
-
tp =
|
397
|
+
tp = tsp.getTotalPages( c, p ),
|
386
398
|
last = dis || p.page === tp - 1 || tp === 0,
|
387
399
|
wo = c.widgetOptions,
|
388
400
|
s = wo.pager_selectors;
|
389
401
|
if ( wo.pager_updateArrows ) {
|
390
|
-
p.$container
|
391
|
-
|
402
|
+
p.$container
|
403
|
+
.find( s.first + ',' + s.prev )
|
404
|
+
.toggleClass( wo.pager_css.disabled, first )
|
405
|
+
.attr( 'aria-disabled', first );
|
406
|
+
p.$container
|
407
|
+
.find( s.next + ',' + s.last )
|
408
|
+
.toggleClass( wo.pager_css.disabled, last )
|
409
|
+
.attr( 'aria-disabled', last );
|
392
410
|
}
|
393
411
|
},
|
394
412
|
|
395
|
-
calcFilters: function(
|
413
|
+
calcFilters: function( c ) {
|
396
414
|
var normalized, indx, len,
|
397
415
|
wo = c.widgetOptions,
|
398
416
|
p = c.pager,
|
399
|
-
hasFilters = c.$table.hasClass('hasFilters');
|
400
|
-
if (hasFilters && !wo.pager_ajaxUrl) {
|
401
|
-
if ($.isEmptyObject(c.cache)) {
|
417
|
+
hasFilters = c.$table.hasClass( 'hasFilters' );
|
418
|
+
if ( hasFilters && !wo.pager_ajaxUrl ) {
|
419
|
+
if ( $.isEmptyObject( c.cache ) ) {
|
402
420
|
// delayInit: true so nothing is in the cache
|
403
|
-
p.filteredRows = p.totalRows = c.$tbodies.eq(0
|
421
|
+
p.filteredRows = p.totalRows = c.$tbodies.eq( 0 )
|
422
|
+
.children( 'tr' )
|
423
|
+
.not( wo.pager_countChildRows ? '' : '.' + c.cssChildRow )
|
424
|
+
.length;
|
404
425
|
} else {
|
405
426
|
p.filteredRows = 0;
|
406
|
-
normalized = c.cache[0].normalized;
|
427
|
+
normalized = c.cache[ 0 ].normalized;
|
407
428
|
len = normalized.length;
|
408
|
-
for (indx = 0; indx < len; indx++) {
|
409
|
-
p.filteredRows += p.regexRows.test(normalized[indx][c.columns].$row[0].className) ? 0 : 1;
|
429
|
+
for ( indx = 0; indx < len; indx++ ) {
|
430
|
+
p.filteredRows += p.regexRows.test( normalized[ indx ][ c.columns ].$row[ 0 ].className ) ? 0 : 1;
|
410
431
|
}
|
411
432
|
}
|
412
|
-
} else if (!hasFilters) {
|
433
|
+
} else if ( !hasFilters ) {
|
413
434
|
p.filteredRows = p.totalRows;
|
414
435
|
}
|
415
436
|
},
|
416
437
|
|
417
|
-
updatePageDisplay: function(
|
438
|
+
updatePageDisplay: function( c, completed ) {
|
418
439
|
if ( c.pager.initializing ) { return; }
|
419
440
|
var s, t, $out, options, indx, len,
|
441
|
+
table = c.table,
|
420
442
|
wo = c.widgetOptions,
|
421
443
|
p = c.pager,
|
422
444
|
namespace = c.namespace + 'pager',
|
423
445
|
sz = tsp.parsePageSize( c, p.size, 'get' ); // don't allow dividing by zero
|
424
|
-
if (wo.pager_countChildRows) { t.push(c.cssChildRow); }
|
425
|
-
p.$size
|
446
|
+
if ( wo.pager_countChildRows ) { t.push( c.cssChildRow ); }
|
447
|
+
p.$size
|
448
|
+
.add( p.$goto )
|
449
|
+
.removeClass( wo.pager_css.disabled )
|
450
|
+
.removeAttr( 'disabled' )
|
451
|
+
.attr( 'aria-disabled', 'false' );
|
426
452
|
p.totalPages = Math.ceil( p.totalRows / sz ); // needed for 'pageSize' method
|
427
453
|
c.totalRows = p.totalRows;
|
428
|
-
tsp.parsePageNumber( p );
|
429
|
-
tsp.calcFilters(
|
454
|
+
tsp.parsePageNumber( c, p );
|
455
|
+
tsp.calcFilters( c );
|
430
456
|
c.filteredRows = p.filteredRows;
|
431
457
|
p.filteredPages = Math.ceil( p.filteredRows / sz ) || 0;
|
432
|
-
if (
|
433
|
-
t = (p.size * p.page > p.filteredRows) && completed;
|
434
|
-
p.page =
|
435
|
-
p.startRow =
|
458
|
+
if ( tsp.getTotalPages( c, p ) >= 0 ) {
|
459
|
+
t = ( p.size * p.page > p.filteredRows ) && completed;
|
460
|
+
p.page = t ? wo.pager_pageReset || 0 : p.page;
|
461
|
+
p.startRow = t ? p.size * p.page + 1 : ( p.filteredRows === 0 ? 0 : p.size * p.page + 1 );
|
436
462
|
p.endRow = Math.min( p.filteredRows, p.totalRows, p.size * ( p.page + 1 ) );
|
437
|
-
$out = p.$container.find(wo.pager_selectors.pageDisplay);
|
463
|
+
$out = p.$container.find( wo.pager_selectors.pageDisplay );
|
438
464
|
// form the output string (can now get a new output string from the server)
|
439
465
|
s = ( p.ajaxData && p.ajaxData.output ? p.ajaxData.output || wo.pager_output : wo.pager_output )
|
440
466
|
// {page} = one-based index; {page+#} = zero based index +/- value
|
441
|
-
.replace(/\{page([\-+]\d+)?\}/gi, function(m, n){
|
442
|
-
return p.totalPages ? p.page + (n ? parseInt(n, 10) : 1) : 0;
|
467
|
+
.replace( /\{page([\-+]\d+)?\}/gi, function( m, n ) {
|
468
|
+
return p.totalPages ? p.page + ( n ? parseInt( n, 10 ) : 1 ) : 0;
|
443
469
|
})
|
444
470
|
// {totalPages}, {extra}, {extra:0} (array) or {extra : key} (object)
|
445
|
-
.replace(/\{\w+(\s*:\s*\w+)?\}/gi, function(m){
|
471
|
+
.replace( /\{\w+(\s*:\s*\w+)?\}/gi, function( m ) {
|
446
472
|
var len, indx,
|
447
|
-
str = m.replace(/[{}\s]/g, ''),
|
448
|
-
extra = str.split(':'),
|
473
|
+
str = m.replace( /[{}\s]/g, '' ),
|
474
|
+
extra = str.split( ':' ),
|
449
475
|
data = p.ajaxData,
|
450
476
|
// return zero for default page/row numbers
|
451
|
-
deflt = /(rows?|pages?)$/i.test(str) ? 0 : '';
|
452
|
-
if (/(startRow|page)/.test(extra[0]) && extra[1] === 'input') {
|
453
|
-
len = ('' + (extra[0] === 'page' ? p.totalPages : p.totalRows)).length;
|
454
|
-
indx = extra[0] === 'page' ? p.page + 1 : p.startRow;
|
455
|
-
return '<input type="text" class="ts-' + extra[0] +
|
477
|
+
deflt = /(rows?|pages?)$/i.test( str ) ? 0 : '';
|
478
|
+
if ( /(startRow|page)/.test( extra[ 0 ] ) && extra[ 1 ] === 'input' ) {
|
479
|
+
len = ( '' + ( extra[ 0 ] === 'page' ? p.totalPages : p.totalRows ) ).length;
|
480
|
+
indx = extra[ 0 ] === 'page' ? p.page + 1 : p.startRow;
|
481
|
+
return '<input type="text" class="ts-' + extra[ 0 ] +
|
482
|
+
'" style="max-width:' + len + 'em" value="' + indx + '"/>';
|
456
483
|
}
|
457
|
-
return extra.length > 1 && data && data[extra[0
|
484
|
+
return extra.length > 1 && data && data[ extra[ 0 ] ] ?
|
485
|
+
data[ extra[ 0 ] ][ extra[ 1 ] ] :
|
486
|
+
p[ str ] || ( data ? data[ str ] : deflt ) || deflt;
|
458
487
|
});
|
459
488
|
if ( p.$goto.length ) {
|
460
489
|
t = '';
|
461
|
-
options = tsp.buildPageSelect(
|
490
|
+
options = tsp.buildPageSelect( c, p );
|
462
491
|
len = options.length;
|
463
|
-
for (indx = 0; indx < len; indx++) {
|
464
|
-
t += '<option value="' + options[indx] + '">' + options[indx] + '</option>';
|
492
|
+
for ( indx = 0; indx < len; indx++ ) {
|
493
|
+
t += '<option value="' + options[ indx ] + '">' + options[ indx ] + '</option>';
|
465
494
|
}
|
466
495
|
// innerHTML doesn't work in IE9 - http://support2.microsoft.com/kb/276228
|
467
|
-
p.$goto.html(t).val( p.page + 1 );
|
496
|
+
p.$goto.html( t ).val( p.page + 1 );
|
468
497
|
}
|
469
|
-
if ($out.length) {
|
470
|
-
$out[ ($out[0].nodeName === 'INPUT') ? 'val' : 'html' ](s);
|
498
|
+
if ( $out.length ) {
|
499
|
+
$out[ ($out[ 0 ].nodeName === 'INPUT' ) ? 'val' : 'html' ]( s );
|
471
500
|
// rebind startRow/page inputs
|
472
|
-
$out
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
501
|
+
$out
|
502
|
+
.find( '.ts-startRow, .ts-page' )
|
503
|
+
.off( 'change' + namespace )
|
504
|
+
.on( 'change' + namespace, function() {
|
505
|
+
var v = $( this ).val(),
|
506
|
+
pg = $( this ).hasClass( 'ts-startRow' ) ? Math.floor( v / p.size ) + 1 : v;
|
507
|
+
c.$table.trigger( 'pageSet' + namespace, [ pg ] );
|
508
|
+
});
|
477
509
|
}
|
478
510
|
}
|
479
|
-
tsp.pagerArrows(c);
|
480
|
-
tsp.fixHeight(
|
481
|
-
if (p.initialized && completed !== false) {
|
482
|
-
if (c.debug) {
|
483
|
-
console.log('Pager: Triggering pagerComplete');
|
511
|
+
tsp.pagerArrows( c );
|
512
|
+
tsp.fixHeight( c );
|
513
|
+
if ( p.initialized && completed !== false ) {
|
514
|
+
if ( c.debug ) {
|
515
|
+
console.log( 'Pager: Triggering pagerComplete' );
|
484
516
|
}
|
485
|
-
c.$table.trigger('pagerComplete', c);
|
517
|
+
c.$table.trigger( 'pagerComplete', c );
|
486
518
|
// save pager info to storage
|
487
|
-
if (wo.pager_savePages && ts.storage) {
|
488
|
-
ts.storage(table, wo.pager_storageKey, {
|
519
|
+
if ( wo.pager_savePages && ts.storage ) {
|
520
|
+
ts.storage( table, wo.pager_storageKey, {
|
489
521
|
page : p.page,
|
490
522
|
size : p.size
|
491
523
|
});
|
@@ -493,100 +525,107 @@
|
|
493
525
|
}
|
494
526
|
},
|
495
527
|
|
496
|
-
buildPageSelect: function(
|
528
|
+
buildPageSelect: function( c, p ) {
|
497
529
|
// Filter the options page number link array if it's larger than 'pager_maxOptionSize'
|
498
530
|
// as large page set links will slow the browser on large dom inserts
|
499
|
-
var i,
|
531
|
+
var i, centralFocusSize, focusOptionPages, insertIndex, optionLength, focusLength,
|
500
532
|
wo = c.widgetOptions,
|
501
|
-
pg =
|
533
|
+
pg = tsp.getTotalPages( c, p ) || 1,
|
502
534
|
// make skip set size multiples of 5
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
535
|
+
skipSetSize = Math.ceil( ( pg / wo.pager_maxOptionSize ) / 5 ) * 5,
|
536
|
+
largeCollection = pg > wo.pager_maxOptionSize,
|
537
|
+
currentPage = p.page + 1,
|
538
|
+
startPage = skipSetSize,
|
539
|
+
endPage = pg - skipSetSize,
|
540
|
+
optionPages = [ 1 ],
|
509
541
|
// construct default options pages array
|
510
|
-
|
542
|
+
optionPagesStartPage = largeCollection ? skipSetSize : 1;
|
511
543
|
|
512
|
-
for ( i =
|
513
|
-
|
514
|
-
i = i + (
|
544
|
+
for ( i = optionPagesStartPage; i <= pg; ) {
|
545
|
+
optionPages.push( i );
|
546
|
+
i = i + ( largeCollection ? skipSetSize : 1 );
|
515
547
|
}
|
516
|
-
|
548
|
+
optionPages.push( pg );
|
517
549
|
|
518
|
-
if (
|
519
|
-
|
550
|
+
if ( largeCollection ) {
|
551
|
+
focusOptionPages = [];
|
520
552
|
// don't allow central focus size to be > 5 on either side of current page
|
521
|
-
|
553
|
+
centralFocusSize = Math.max( Math.floor( wo.pager_maxOptionSize / skipSetSize ) - 1, 5 );
|
522
554
|
|
523
|
-
|
524
|
-
if (
|
525
|
-
|
526
|
-
if (
|
555
|
+
startPage = currentPage - centralFocusSize;
|
556
|
+
if ( startPage < 1 ) { startPage = 1; }
|
557
|
+
endPage = currentPage + centralFocusSize;
|
558
|
+
if ( endPage > pg ) { endPage = pg; }
|
527
559
|
// construct an array to get a focus set around the current page
|
528
|
-
for (i =
|
529
|
-
|
560
|
+
for ( i = startPage; i <= endPage ; i++ ) {
|
561
|
+
focusOptionPages.push( i );
|
530
562
|
}
|
531
563
|
|
532
564
|
// keep unique values
|
533
|
-
|
534
|
-
return $.inArray(value,
|
565
|
+
optionPages = $.grep( optionPages, function( value, indx ) {
|
566
|
+
return $.inArray( value, optionPages ) === indx;
|
535
567
|
});
|
536
568
|
|
537
|
-
|
538
|
-
|
569
|
+
optionLength = optionPages.length;
|
570
|
+
focusLength = focusOptionPages.length;
|
539
571
|
|
540
|
-
// make sure at all
|
541
|
-
if (
|
542
|
-
|
543
|
-
Array.prototype.splice.apply(
|
572
|
+
// make sure at all optionPages aren't replaced
|
573
|
+
if ( optionLength - focusLength > skipSetSize / 2 && optionLength + focusLength > wo.pager_maxOptionSize ) {
|
574
|
+
insertIndex = Math.floor( optionLength / 2 ) - Math.floor( focusLength / 2 );
|
575
|
+
Array.prototype.splice.apply( optionPages, [ insertIndex, focusLength ] );
|
544
576
|
}
|
545
|
-
|
577
|
+
optionPages = optionPages.concat( focusOptionPages );
|
546
578
|
|
547
579
|
}
|
548
580
|
|
549
581
|
// keep unique values again
|
550
|
-
|
551
|
-
return $.inArray(value,
|
582
|
+
optionPages = $.grep( optionPages, function( value, indx ) {
|
583
|
+
return $.inArray( value, optionPages ) === indx;
|
552
584
|
})
|
553
|
-
.sort(function(a, b) {
|
585
|
+
.sort( function( a, b ) {
|
586
|
+
return a - b;
|
587
|
+
});
|
554
588
|
|
555
|
-
return
|
589
|
+
return optionPages;
|
556
590
|
},
|
557
591
|
|
558
|
-
fixHeight: function(
|
592
|
+
fixHeight: function( c ) {
|
559
593
|
var d, h,
|
594
|
+
table = c.table,
|
560
595
|
p = c.pager,
|
561
596
|
wo = c.widgetOptions,
|
562
|
-
$b = c.$tbodies.eq(0);
|
563
|
-
$b.find('tr.pagerSavedHeightSpacer').remove();
|
564
|
-
if (wo.pager_fixedHeight && !p.isDisabled) {
|
565
|
-
h = $.data(table, 'pagerSavedHeight');
|
566
|
-
if (h) {
|
597
|
+
$b = c.$tbodies.eq( 0 );
|
598
|
+
$b.find( 'tr.pagerSavedHeightSpacer' ).remove();
|
599
|
+
if ( wo.pager_fixedHeight && !p.isDisabled ) {
|
600
|
+
h = $.data( table, 'pagerSavedHeight' );
|
601
|
+
if ( h ) {
|
567
602
|
d = h - $b.height();
|
568
|
-
if ( d > 5 && $.data(table, 'pagerLastSize') === p.size && $b.children('tr:visible').length < p.size ) {
|
569
|
-
$b.append('<tr class="pagerSavedHeightSpacer ' + c.selectorRemove.slice(1) +
|
603
|
+
if ( d > 5 && $.data( table, 'pagerLastSize' ) === p.size && $b.children( 'tr:visible' ).length < p.size ) {
|
604
|
+
$b.append( '<tr class="pagerSavedHeightSpacer ' + c.selectorRemove.slice( 1 ) +
|
605
|
+
'" style="height:' + d + 'px;"></tr>' );
|
570
606
|
}
|
571
607
|
}
|
572
608
|
}
|
573
609
|
},
|
574
610
|
|
575
|
-
changeHeight: function(
|
576
|
-
var h,
|
577
|
-
|
578
|
-
|
579
|
-
|
611
|
+
changeHeight: function( c ) {
|
612
|
+
var h,
|
613
|
+
table = c.table,
|
614
|
+
$b = c.$tbodies.eq( 0 );
|
615
|
+
$b.find( 'tr.pagerSavedHeightSpacer' ).remove();
|
616
|
+
if ( !$b.children( 'tr:visible' ).length ) {
|
617
|
+
$b.append( '<tr class="pagerSavedHeightSpacer ' + c.selectorRemove.slice( 1 ) + '"><td> </td></tr>' );
|
580
618
|
}
|
581
|
-
h = $b.children('tr').eq(0).height() * c.pager.size;
|
582
|
-
$.data(table, 'pagerSavedHeight', h);
|
583
|
-
tsp.fixHeight(
|
584
|
-
$.data(table, 'pagerLastSize', c.pager.size);
|
619
|
+
h = $b.children( 'tr' ).eq( 0 ).height() * c.pager.size;
|
620
|
+
$.data( table, 'pagerSavedHeight', h );
|
621
|
+
tsp.fixHeight( c );
|
622
|
+
$.data( table, 'pagerLastSize', c.pager.size );
|
585
623
|
},
|
586
624
|
|
587
|
-
hideRows: function(
|
625
|
+
hideRows: function( c ) {
|
588
626
|
if ( !c.widgetOptions.pager_ajaxUrl ) {
|
589
627
|
var tbodyIndex, rowIndex, $rows, len, lastIndex,
|
628
|
+
table = c.table,
|
590
629
|
p = c.pager,
|
591
630
|
wo = c.widgetOptions,
|
592
631
|
tbodyLen = c.$tbodies.length,
|
@@ -633,236 +672,239 @@
|
|
633
672
|
}
|
634
673
|
},
|
635
674
|
|
636
|
-
hideRowsSetup: function(
|
675
|
+
hideRowsSetup: function( c ) {
|
637
676
|
var p = c.pager,
|
638
677
|
namespace = c.namespace + 'pager',
|
639
678
|
size = p.$size.val();
|
640
679
|
p.size = tsp.parsePageSize( c, size, 'get' );
|
641
680
|
p.$size.val( tsp.parsePageSize( c, p.size, 'set' ) );
|
642
|
-
$.data(table, 'pagerLastSize', p.size);
|
643
|
-
tsp.pagerArrows(c);
|
681
|
+
$.data( c.table, 'pagerLastSize', p.size );
|
682
|
+
tsp.pagerArrows( c );
|
644
683
|
if ( !c.widgetOptions.pager_removeRows ) {
|
645
|
-
tsp.hideRows(
|
646
|
-
c.$table.on('sortEnd filterEnd '.split(' ').join(namespace + ' '), function(){
|
647
|
-
tsp.hideRows(
|
684
|
+
tsp.hideRows( c );
|
685
|
+
c.$table.on( 'sortEnd filterEnd '.split( ' ' ).join( namespace + ' ' ), function() {
|
686
|
+
tsp.hideRows( c );
|
648
687
|
});
|
649
688
|
}
|
650
689
|
},
|
651
690
|
|
652
|
-
renderAjax: function(data,
|
653
|
-
var
|
691
|
+
renderAjax: function( data, c, xhr, settings, exception ) {
|
692
|
+
var table = c.table,
|
693
|
+
p = c.pager,
|
654
694
|
wo = c.widgetOptions;
|
655
695
|
// process data
|
656
|
-
if ( $.isFunction(wo.pager_ajaxProcessing) ) {
|
696
|
+
if ( $.isFunction( wo.pager_ajaxProcessing ) ) {
|
657
697
|
|
658
698
|
// in case nothing is returned by ajax, empty out the table; see #1032
|
659
699
|
// but do it before calling pager_ajaxProcessing because that function may add content
|
660
700
|
// directly to the table
|
661
|
-
c.$tbodies.eq(0).empty();
|
701
|
+
c.$tbodies.eq( 0 ).empty();
|
662
702
|
|
663
703
|
// ajaxProcessing result: [ total, rows, headers ]
|
664
704
|
var i, j, t, hsh, $f, $sh, $headers, $h, icon, th, d, l, rr_count, len,
|
665
705
|
$table = c.$table,
|
666
706
|
tds = '',
|
667
|
-
result = wo.pager_ajaxProcessing(data, table, xhr) || [ 0, [] ],
|
668
|
-
hl = $table.find('thead th').length;
|
707
|
+
result = wo.pager_ajaxProcessing( data, table, xhr ) || [ 0, [] ],
|
708
|
+
hl = $table.find( 'thead th' ).length;
|
669
709
|
|
670
710
|
// Clean up any previous error.
|
671
711
|
ts.showError( table );
|
672
712
|
|
673
713
|
if ( exception ) {
|
674
|
-
if (c.debug) {
|
675
|
-
console.error('Pager: >> Ajax Error', xhr, settings, exception);
|
714
|
+
if ( c.debug ) {
|
715
|
+
console.error( 'Pager: >> Ajax Error', xhr, settings, exception );
|
676
716
|
}
|
677
717
|
ts.showError( table, xhr, settings, exception );
|
678
|
-
c.$tbodies.eq(0).children('tr').detach();
|
718
|
+
c.$tbodies.eq( 0 ).children( 'tr' ).detach();
|
679
719
|
p.totalRows = 0;
|
680
720
|
} else {
|
681
721
|
// process ajax object
|
682
|
-
if (!$.isArray(result)) {
|
722
|
+
if ( !$.isArray( result ) ) {
|
683
723
|
p.ajaxData = result;
|
684
724
|
c.totalRows = p.totalRows = result.total;
|
685
|
-
c.filteredRows = p.filteredRows = typeof result.filteredRows !== 'undefined' ?
|
725
|
+
c.filteredRows = p.filteredRows = typeof result.filteredRows !== 'undefined' ?
|
726
|
+
result.filteredRows :
|
727
|
+
result.total;
|
686
728
|
th = result.headers;
|
687
729
|
d = result.rows || [];
|
688
730
|
} else {
|
689
731
|
// allow [ total, rows, headers ] or [ rows, total, headers ]
|
690
|
-
t = isNaN(result[0]) && !isNaN(result[1]);
|
732
|
+
t = isNaN( result[ 0 ] ) && !isNaN( result[ 1 ] );
|
691
733
|
// ensure a zero returned row count doesn't fail the logical ||
|
692
|
-
rr_count = result[t ? 1 : 0];
|
693
|
-
p.totalRows = isNaN(rr_count) ? p.totalRows || 0 : rr_count;
|
734
|
+
rr_count = result[ t ? 1 : 0 ];
|
735
|
+
p.totalRows = isNaN( rr_count ) ? p.totalRows || 0 : rr_count;
|
694
736
|
// can't set filtered rows when returning an array
|
695
737
|
c.totalRows = c.filteredRows = p.filteredRows = p.totalRows;
|
696
738
|
// set row data to empty array if nothing found - see http://stackoverflow.com/q/30875583/145346
|
697
|
-
d = p.totalRows === 0 ? [] : result[t ? 0 : 1] || []; // row data
|
698
|
-
th = result[2]; // headers
|
739
|
+
d = p.totalRows === 0 ? [] : result[ t ? 0 : 1 ] || []; // row data
|
740
|
+
th = result[ 2 ]; // headers
|
699
741
|
}
|
700
742
|
l = d && d.length;
|
701
|
-
if (d instanceof jQuery) {
|
702
|
-
if (wo.pager_processAjaxOnInit) {
|
743
|
+
if ( d instanceof jQuery ) {
|
744
|
+
if ( wo.pager_processAjaxOnInit ) {
|
703
745
|
// append jQuery object
|
704
|
-
c.$tbodies.eq(0).empty();
|
705
|
-
c.$tbodies.eq(0).append(d);
|
746
|
+
c.$tbodies.eq( 0 ).empty();
|
747
|
+
c.$tbodies.eq( 0 ).append( d );
|
706
748
|
}
|
707
|
-
} else if (l) {
|
749
|
+
} else if ( l ) {
|
708
750
|
// build table from array
|
709
751
|
for ( i = 0; i < l; i++ ) {
|
710
752
|
tds += '<tr>';
|
711
753
|
for ( j = 0; j < d[i].length; j++ ) {
|
712
754
|
// build tbody cells; watch for data containing HTML markup - see #434
|
713
|
-
tds += /^\s*<td/.test(d[i][j]) ? $.trim(d[i][j]) : '<td>' + d[i][j] + '</td>';
|
755
|
+
tds += /^\s*<td/.test( d[ i ][ j ] ) ? $.trim( d[ i ][ j ] ) : '<td>' + d[ i ][ j ] + '</td>';
|
714
756
|
}
|
715
757
|
tds += '</tr>';
|
716
758
|
}
|
717
759
|
// add rows to first tbody
|
718
|
-
if (wo.pager_processAjaxOnInit) {
|
719
|
-
c.$tbodies.eq(0).html( tds );
|
760
|
+
if ( wo.pager_processAjaxOnInit ) {
|
761
|
+
c.$tbodies.eq( 0 ).html( tds );
|
720
762
|
}
|
721
763
|
}
|
722
764
|
wo.pager_processAjaxOnInit = true;
|
723
765
|
// only add new header text if the length matches
|
724
766
|
if ( th && th.length === hl ) {
|
725
|
-
hsh = $table.hasClass('hasStickyHeaders');
|
726
|
-
$sh = hsh ? wo.$sticky.children('thead:first').children('tr').children() : '';
|
727
|
-
$f = $table.find('tfoot tr:first').children();
|
767
|
+
hsh = $table.hasClass( 'hasStickyHeaders' );
|
768
|
+
$sh = hsh ? wo.$sticky.children( 'thead:first' ).children( 'tr' ).children() : '';
|
769
|
+
$f = $table.find( 'tfoot tr:first' ).children();
|
728
770
|
// don't change td headers (may contain pager)
|
729
|
-
$headers = c.$headers.filter( 'th
|
771
|
+
$headers = c.$headers.filter( 'th' );
|
730
772
|
len = $headers.length;
|
731
773
|
for ( j = 0; j < len; j++ ) {
|
732
774
|
$h = $headers.eq( j );
|
733
775
|
// add new test within the first span it finds, or just in the header
|
734
|
-
if ( $h.find('.' + ts.css.icon).length ) {
|
735
|
-
icon = $h.find('.' + ts.css.icon).clone(true);
|
736
|
-
$h.find('.tablesorter-header-inner').html( th[j] ).append(icon);
|
776
|
+
if ( $h.find( '.' + ts.css.icon ).length ) {
|
777
|
+
icon = $h.find( '.' + ts.css.icon ).clone( true );
|
778
|
+
$h.find( '.tablesorter-header-inner' ).html( th[ j ] ).append( icon );
|
737
779
|
if ( hsh && $sh.length ) {
|
738
|
-
icon = $sh.eq(j).find('.' + ts.css.icon).clone(true);
|
739
|
-
$sh.eq(j).find('.tablesorter-header-inner').html( th[j] ).append(icon);
|
780
|
+
icon = $sh.eq( j ).find( '.' + ts.css.icon ).clone( true );
|
781
|
+
$sh.eq( j ).find( '.tablesorter-header-inner' ).html( th[ j ] ).append( icon );
|
740
782
|
}
|
741
783
|
} else {
|
742
|
-
$h.find('.tablesorter-header-inner').html( th[j] );
|
743
|
-
if (hsh && $sh.length) {
|
744
|
-
$sh.eq(j).find('.tablesorter-header-inner').html( th[j] );
|
784
|
+
$h.find( '.tablesorter-header-inner' ).html( th[ j ] );
|
785
|
+
if ( hsh && $sh.length ) {
|
786
|
+
$sh.eq( j ).find( '.tablesorter-header-inner' ).html( th[ j ] );
|
745
787
|
}
|
746
788
|
}
|
747
|
-
$f.eq(j).html( th[j] );
|
789
|
+
$f.eq( j ).html( th[ j ] );
|
748
790
|
}
|
749
791
|
}
|
750
792
|
}
|
751
|
-
if (c.showProcessing) {
|
752
|
-
ts.isProcessing(table); // remove loading icon
|
793
|
+
if ( c.showProcessing ) {
|
794
|
+
ts.isProcessing( table ); // remove loading icon
|
753
795
|
}
|
754
796
|
// make sure last pager settings are saved, prevents multiple server side calls with
|
755
797
|
// the same parameters
|
756
798
|
p.totalPages = Math.ceil( p.totalRows / tsp.parsePageSize( c, p.size, 'get' ) );
|
757
799
|
p.last.totalRows = p.totalRows;
|
758
800
|
p.last.currentFilters = p.currentFilters;
|
759
|
-
p.last.sortList = (c.sortList || []).join(',');
|
801
|
+
p.last.sortList = ( c.sortList || [] ).join( ',' );
|
760
802
|
p.initializing = false;
|
761
803
|
// update display without triggering pager complete... before updating cache
|
762
|
-
tsp.updatePageDisplay(
|
804
|
+
tsp.updatePageDisplay( c, false );
|
763
805
|
// tablesorter core updateCache (not pager)
|
764
|
-
ts.updateCache( c, function(){
|
765
|
-
if (p.initialized) {
|
806
|
+
ts.updateCache( c, function() {
|
807
|
+
if ( p.initialized ) {
|
766
808
|
// apply widgets after table has rendered & after a delay to prevent
|
767
809
|
// multiple applyWidget blocking code from blocking this trigger
|
768
|
-
setTimeout(function(){
|
769
|
-
if (c.debug) {
|
770
|
-
console.log('Pager: Triggering pagerChange');
|
810
|
+
setTimeout( function() {
|
811
|
+
if ( c.debug ) {
|
812
|
+
console.log( 'Pager: Triggering pagerChange' );
|
771
813
|
}
|
772
814
|
$table.trigger( 'pagerChange', p );
|
773
815
|
ts.applyWidget( table );
|
774
|
-
tsp.updatePageDisplay(
|
775
|
-
}, 0);
|
816
|
+
tsp.updatePageDisplay( c );
|
817
|
+
}, 0 );
|
776
818
|
}
|
777
819
|
});
|
778
820
|
}
|
779
|
-
if (!p.initialized) {
|
821
|
+
if ( !p.initialized ) {
|
780
822
|
ts.applyWidget( table );
|
781
823
|
}
|
782
824
|
},
|
783
825
|
|
784
|
-
getAjax: function(
|
826
|
+
getAjax: function( c ) {
|
785
827
|
var counter,
|
786
|
-
url = tsp.getAjaxUrl(
|
787
|
-
$doc = $(document),
|
828
|
+
url = tsp.getAjaxUrl( c ),
|
829
|
+
$doc = $( document ),
|
788
830
|
namespace = c.namespace + 'pager',
|
789
831
|
p = c.pager;
|
790
832
|
if ( url !== '' ) {
|
791
|
-
if (c.showProcessing) {
|
792
|
-
ts.isProcessing(table, true); // show loading icon
|
833
|
+
if ( c.showProcessing ) {
|
834
|
+
ts.isProcessing( c.table, true ); // show loading icon
|
793
835
|
}
|
794
|
-
$doc.on('ajaxError' + namespace, function(e, xhr, settings, exception) {
|
795
|
-
tsp.renderAjax(null,
|
796
|
-
$doc.off('ajaxError' + namespace);
|
836
|
+
$doc.on( 'ajaxError' + namespace, function( e, xhr, settings, exception ) {
|
837
|
+
tsp.renderAjax( null, c, xhr, settings, exception );
|
838
|
+
$doc.off( 'ajaxError' + namespace );
|
797
839
|
});
|
798
840
|
counter = ++p.ajaxCounter;
|
799
841
|
p.last.ajaxUrl = url; // remember processed url
|
800
842
|
p.ajaxObject.url = url; // from the ajaxUrl option and modified by customAjaxUrl
|
801
|
-
p.ajaxObject.success = function(data, status, jqxhr) {
|
843
|
+
p.ajaxObject.success = function( data, status, jqxhr ) {
|
802
844
|
// Refuse to process old ajax commands that were overwritten by new ones - see #443
|
803
|
-
if (counter < p.ajaxCounter){
|
845
|
+
if ( counter < p.ajaxCounter ) {
|
804
846
|
return;
|
805
847
|
}
|
806
|
-
tsp.renderAjax(data,
|
807
|
-
$doc.off('ajaxError' + namespace);
|
808
|
-
if (typeof p.oldAjaxSuccess === 'function') {
|
809
|
-
p.oldAjaxSuccess(data);
|
848
|
+
tsp.renderAjax( data, c, jqxhr );
|
849
|
+
$doc.off( 'ajaxError' + namespace );
|
850
|
+
if ( typeof p.oldAjaxSuccess === 'function' ) {
|
851
|
+
p.oldAjaxSuccess( data );
|
810
852
|
}
|
811
853
|
};
|
812
|
-
if (c.debug) {
|
813
|
-
console.log('Pager: Ajax initialized', p.ajaxObject);
|
854
|
+
if ( c.debug ) {
|
855
|
+
console.log( 'Pager: Ajax initialized', p.ajaxObject );
|
814
856
|
}
|
815
|
-
$.ajax(p.ajaxObject);
|
857
|
+
$.ajax( p.ajaxObject );
|
816
858
|
}
|
817
859
|
},
|
818
860
|
|
819
|
-
getAjaxUrl: function(
|
861
|
+
getAjaxUrl: function( c ) {
|
820
862
|
var indx, len,
|
821
863
|
p = c.pager,
|
822
864
|
wo = c.widgetOptions,
|
823
|
-
url =
|
865
|
+
url = wo.pager_ajaxUrl ? wo.pager_ajaxUrl
|
824
866
|
// allow using '{page+1}' in the url string to switch to a non-zero based index
|
825
|
-
.replace(/\{page([\-+]\d+)?\}/, function(s, n){ return p.page + (n ? parseInt(n, 10) : 0); })
|
826
|
-
.replace(/\{size\}/g, p.size) : '',
|
867
|
+
.replace( /\{page([\-+]\d+)?\}/, function( s, n ) { return p.page + ( n ? parseInt( n, 10 ) : 0 ); })
|
868
|
+
.replace( /\{size\}/g, p.size ) : '',
|
827
869
|
sortList = c.sortList,
|
828
|
-
filterList = p.currentFilters ||
|
829
|
-
sortCol = url.match(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/),
|
830
|
-
filterCol = url.match(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/),
|
870
|
+
filterList = p.currentFilters || c.$table.data( 'lastSearch' ) || [],
|
871
|
+
sortCol = url.match( /\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/ ),
|
872
|
+
filterCol = url.match( /\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/ ),
|
831
873
|
arry = [];
|
832
|
-
if (sortCol) {
|
833
|
-
sortCol = sortCol[1];
|
874
|
+
if ( sortCol ) {
|
875
|
+
sortCol = sortCol[ 1 ];
|
834
876
|
len = sortList.length;
|
835
|
-
for (indx = 0; indx < len; indx++) {
|
836
|
-
arry.push(sortCol + '[' + sortList[indx][0] + ']=' + sortList[indx][1]);
|
877
|
+
for ( indx = 0; indx < len; indx++ ) {
|
878
|
+
arry.push( sortCol + '[' + sortList[ indx ][ 0 ] + ']=' + sortList[ indx ][ 1 ] );
|
837
879
|
}
|
838
880
|
// if the arry is empty, just add the col parameter... '&{sortList:col}' becomes '&col'
|
839
|
-
url = url.replace(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/g, arry.length ? arry.join('&') : sortCol );
|
881
|
+
url = url.replace( /\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/g, arry.length ? arry.join( '&' ) : sortCol );
|
840
882
|
arry = [];
|
841
883
|
}
|
842
|
-
if (filterCol) {
|
843
|
-
filterCol = filterCol[1];
|
884
|
+
if ( filterCol ) {
|
885
|
+
filterCol = filterCol[ 1 ];
|
844
886
|
len = filterList.length;
|
845
|
-
for (indx = 0; indx < len; indx++) {
|
846
|
-
if (filterList[indx]) {
|
847
|
-
arry.push(filterCol + '[' + indx + ']=' + encodeURIComponent(filterList[indx]));
|
887
|
+
for ( indx = 0; indx < len; indx++ ) {
|
888
|
+
if ( filterList[ indx ] ) {
|
889
|
+
arry.push( filterCol + '[' + indx + ']=' + encodeURIComponent( filterList[ indx ] ) );
|
848
890
|
}
|
849
891
|
}
|
850
892
|
// if the arry is empty, just add the fcol parameter... '&{filterList:fcol}' becomes '&fcol'
|
851
|
-
url = url.replace(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/g, arry.length ? arry.join('&') : filterCol );
|
893
|
+
url = url.replace( /\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/g, arry.length ? arry.join( '&' ) : filterCol );
|
852
894
|
p.currentFilters = filterList;
|
853
895
|
}
|
854
|
-
if ( $.isFunction(wo.pager_customAjaxUrl) ) {
|
855
|
-
url = wo.pager_customAjaxUrl(table, url);
|
896
|
+
if ( $.isFunction( wo.pager_customAjaxUrl ) ) {
|
897
|
+
url = wo.pager_customAjaxUrl( c.table, url );
|
856
898
|
}
|
857
|
-
if (c.debug) {
|
858
|
-
console.log('Pager: Ajax url = ' + url);
|
899
|
+
if ( c.debug ) {
|
900
|
+
console.log( 'Pager: Ajax url = ' + url );
|
859
901
|
}
|
860
902
|
return url;
|
861
903
|
},
|
862
904
|
|
863
|
-
renderTable: function(
|
905
|
+
renderTable: function( c, rows ) {
|
864
906
|
var $tb, index, count, added,
|
865
|
-
|
907
|
+
table = c.table,
|
866
908
|
p = c.pager,
|
867
909
|
wo = c.widgetOptions,
|
868
910
|
f = c.$table.hasClass('hasFilters'),
|
@@ -870,81 +912,83 @@
|
|
870
912
|
s = ( p.page * p.size ),
|
871
913
|
e = p.size;
|
872
914
|
if ( l < 1 ) {
|
873
|
-
if (c.debug) {
|
874
|
-
console.warn('Pager: >> No rows for pager to render');
|
915
|
+
if ( c.debug ) {
|
916
|
+
console.warn( 'Pager: >> No rows for pager to render' );
|
875
917
|
}
|
876
918
|
// empty table, abort!
|
877
919
|
return;
|
878
920
|
}
|
879
921
|
if ( p.page >= p.totalPages ) {
|
880
922
|
// lets not render the table more than once
|
881
|
-
return tsp.moveToLastPage(
|
923
|
+
return tsp.moveToLastPage( c, p );
|
882
924
|
}
|
883
925
|
p.cacheIndex = [];
|
884
926
|
p.isDisabled = false; // needed because sorting will change the page and re-enable the pager
|
885
|
-
if (p.initialized) {
|
886
|
-
if (c.debug) {
|
887
|
-
console.log('Pager: Triggering pagerChange');
|
927
|
+
if ( p.initialized ) {
|
928
|
+
if ( c.debug ) {
|
929
|
+
console.log( 'Pager: Triggering pagerChange' );
|
888
930
|
}
|
889
931
|
c.$table.trigger( 'pagerChange', c );
|
890
932
|
}
|
891
933
|
if ( !wo.pager_removeRows ) {
|
892
|
-
tsp.hideRows(
|
934
|
+
tsp.hideRows( c );
|
893
935
|
} else {
|
894
|
-
ts.clearTableBody(table);
|
895
|
-
$tb = ts.processTbody(table, c.$tbodies.eq(0), true);
|
936
|
+
ts.clearTableBody( table );
|
937
|
+
$tb = ts.processTbody( table, c.$tbodies.eq(0), true );
|
896
938
|
// not filtered, start from the calculated starting point (s)
|
897
939
|
// if filtered, start from zero
|
898
940
|
index = f ? 0 : s;
|
899
941
|
count = f ? 0 : s;
|
900
942
|
added = 0;
|
901
|
-
while (added < e && index < rows.length) {
|
902
|
-
if (!f || !/filtered/.test(rows[index][0].className)){
|
943
|
+
while ( added < e && index < rows.length ) {
|
944
|
+
if ( !f || !/filtered/.test( rows[ index ][ 0 ].className ) ) {
|
903
945
|
count++;
|
904
|
-
if (count > s && added <= e) {
|
946
|
+
if ( count > s && added <= e ) {
|
905
947
|
added++;
|
906
|
-
p.cacheIndex.push(index);
|
907
|
-
$tb.append(rows[index]);
|
948
|
+
p.cacheIndex.push( index );
|
949
|
+
$tb.append( rows[ index ] );
|
908
950
|
}
|
909
951
|
}
|
910
952
|
index++;
|
911
953
|
}
|
912
|
-
ts.processTbody(table, $tb, false);
|
954
|
+
ts.processTbody( table, $tb, false );
|
913
955
|
}
|
914
|
-
tsp.updatePageDisplay(
|
956
|
+
tsp.updatePageDisplay( c );
|
915
957
|
|
916
958
|
wo.pager_startPage = p.page;
|
917
959
|
wo.pager_size = p.size;
|
918
|
-
if (table.isUpdating) {
|
919
|
-
if (c.debug) {
|
920
|
-
console.log('Pager: Triggering updateComplete');
|
960
|
+
if ( table.isUpdating ) {
|
961
|
+
if ( c.debug ) {
|
962
|
+
console.log( 'Pager: Triggering updateComplete' );
|
921
963
|
}
|
922
|
-
c.$table.trigger('updateComplete', [ table, true ]);
|
964
|
+
c.$table.trigger( 'updateComplete', [ table, true ] );
|
923
965
|
}
|
924
966
|
|
925
967
|
},
|
926
968
|
|
927
|
-
showAllRows: function(
|
969
|
+
showAllRows: function( c ) {
|
928
970
|
var index, $controls, len,
|
971
|
+
table = c.table,
|
929
972
|
p = c.pager,
|
930
973
|
wo = c.widgetOptions;
|
931
974
|
if ( p.ajax ) {
|
932
|
-
tsp.pagerArrows(c, true);
|
975
|
+
tsp.pagerArrows( c, true );
|
933
976
|
} else {
|
934
|
-
$.data(table, 'pagerLastPage', p.page);
|
935
|
-
$.data(table, 'pagerLastSize', p.size);
|
977
|
+
$.data( table, 'pagerLastPage', p.page );
|
978
|
+
$.data( table, 'pagerLastSize', p.size );
|
936
979
|
p.page = 0;
|
937
980
|
p.size = p.totalRows;
|
938
981
|
p.totalPages = 1;
|
939
982
|
c.$table
|
940
|
-
.addClass('pagerDisabled')
|
941
|
-
.removeAttr('aria-describedby')
|
942
|
-
.find('tr.pagerSavedHeightSpacer')
|
943
|
-
|
983
|
+
.addClass( 'pagerDisabled' )
|
984
|
+
.removeAttr( 'aria-describedby' )
|
985
|
+
.find( 'tr.pagerSavedHeightSpacer' )
|
986
|
+
.remove();
|
987
|
+
tsp.renderTable( c, c.rowsCopy );
|
944
988
|
p.isDisabled = true;
|
945
989
|
ts.applyWidget( table );
|
946
|
-
if (c.debug) {
|
947
|
-
console.log('Pager: Disabled');
|
990
|
+
if ( c.debug ) {
|
991
|
+
console.log( 'Pager: Disabled' );
|
948
992
|
}
|
949
993
|
}
|
950
994
|
// disable size selector
|
@@ -955,96 +999,99 @@
|
|
955
999
|
for ( index = 0; index < len; index++ ) {
|
956
1000
|
$controls.eq( index )
|
957
1001
|
.attr( 'aria-disabled', 'true' )
|
958
|
-
.addClass( wo.pager_css.disabled )[0].disabled = true;
|
1002
|
+
.addClass( wo.pager_css.disabled )[ 0 ].disabled = true;
|
959
1003
|
}
|
960
1004
|
},
|
961
1005
|
|
962
1006
|
// updateCache if delayInit: true
|
963
1007
|
// this is normally done by 'appendToTable' function in the tablesorter core AFTER a sort
|
964
|
-
updateCache: function(
|
965
|
-
var
|
966
|
-
p = c.pager;
|
1008
|
+
updateCache: function( c ) {
|
1009
|
+
var p = c.pager;
|
967
1010
|
// tablesorter core updateCache (not pager)
|
968
|
-
ts.updateCache( c, function(){
|
969
|
-
if ( !$.isEmptyObject(
|
970
|
-
var
|
1011
|
+
ts.updateCache( c, function() {
|
1012
|
+
if ( !$.isEmptyObject( c.cache ) ) {
|
1013
|
+
var index,
|
971
1014
|
rows = [],
|
972
|
-
|
973
|
-
p.totalRows =
|
974
|
-
for (
|
975
|
-
rows.push(
|
1015
|
+
normalized = c.cache[ 0 ].normalized;
|
1016
|
+
p.totalRows = normalized.length;
|
1017
|
+
for ( index = 0; index < p.totalRows; index++ ) {
|
1018
|
+
rows.push( normalized[ index ][ c.columns ].$row );
|
976
1019
|
}
|
977
1020
|
c.rowsCopy = rows;
|
978
|
-
tsp.moveToPage(
|
1021
|
+
tsp.moveToPage( c, p, true );
|
979
1022
|
// clear out last search to force an update
|
980
1023
|
p.last.currentFilters = [ ' ' ];
|
981
1024
|
}
|
982
1025
|
});
|
983
1026
|
},
|
984
1027
|
|
985
|
-
moveToPage: function(
|
1028
|
+
moveToPage: function( c, p, pageMoved ) {
|
986
1029
|
if ( p.isDisabled ) { return; }
|
987
|
-
if ( pageMoved !== false && p.initialized && $.isEmptyObject(
|
988
|
-
return tsp.updateCache(
|
1030
|
+
if ( pageMoved !== false && p.initialized && $.isEmptyObject( c.cache ) ) {
|
1031
|
+
return tsp.updateCache( c );
|
989
1032
|
}
|
990
|
-
var
|
1033
|
+
var table = c.table,
|
991
1034
|
wo = c.widgetOptions,
|
992
1035
|
l = p.last;
|
993
1036
|
|
994
1037
|
// abort page move if the table has filters and has not been initialized
|
995
|
-
if (p.ajax && !wo.filter_initialized && ts.hasWidget(table, 'filter')) { return; }
|
1038
|
+
if ( p.ajax && !wo.filter_initialized && ts.hasWidget( table, 'filter' ) ) { return; }
|
996
1039
|
|
997
|
-
tsp.parsePageNumber( p );
|
998
|
-
tsp.calcFilters(
|
1040
|
+
tsp.parsePageNumber( c, p );
|
1041
|
+
tsp.calcFilters( c );
|
999
1042
|
|
1000
1043
|
// fixes issue where one current filter is [] and the other is [ '', '', '' ],
|
1001
1044
|
// making the next if comparison think the filters as different. Fixes #202.
|
1002
|
-
l.currentFilters = (l.currentFilters || []).join('') === '' ? [] : l.currentFilters;
|
1003
|
-
p.currentFilters = (p.currentFilters || []).join('') === '' ? [] : p.currentFilters;
|
1045
|
+
l.currentFilters = ( l.currentFilters || [] ).join( '' ) === '' ? [] : l.currentFilters;
|
1046
|
+
p.currentFilters = ( p.currentFilters || [] ).join( '' ) === '' ? [] : p.currentFilters;
|
1004
1047
|
// don't allow rendering multiple times on the same page/size/totalRows/filters/sorts
|
1005
1048
|
if ( l.page === p.page && l.size === p.size && l.totalRows === p.totalRows &&
|
1006
|
-
(l.currentFilters || []).join(',') === (p.currentFilters || []).join(',') &&
|
1049
|
+
( l.currentFilters || [] ).join( ',' ) === ( p.currentFilters || [] ).join( ',' ) &&
|
1007
1050
|
// check for ajax url changes see #730
|
1008
|
-
(l.ajaxUrl || '') === (p.ajaxObject.url || '') &&
|
1051
|
+
( l.ajaxUrl || '' ) === ( p.ajaxObject.url || '' ) &&
|
1009
1052
|
// & ajax url option changes (dynamically add/remove/rename sort & filter parameters)
|
1010
|
-
(l.optAjaxUrl || '') === (wo.pager_ajaxUrl || '') &&
|
1011
|
-
l.sortList === (c.sortList || []).join(',') ) {
|
1053
|
+
( l.optAjaxUrl || '' ) === ( wo.pager_ajaxUrl || '' ) &&
|
1054
|
+
l.sortList === ( c.sortList || [] ).join( ',' ) ) {
|
1012
1055
|
return;
|
1013
1056
|
}
|
1014
|
-
if (c.debug) {
|
1015
|
-
console.log('Pager: Changing to page ' + p.page);
|
1057
|
+
if ( c.debug ) {
|
1058
|
+
console.log( 'Pager: Changing to page ' + p.page );
|
1016
1059
|
}
|
1017
1060
|
p.last = {
|
1018
|
-
page
|
1019
|
-
size
|
1061
|
+
page: p.page,
|
1062
|
+
size: p.size,
|
1020
1063
|
// fixes #408; modify sortList otherwise it auto-updates
|
1021
|
-
sortList
|
1022
|
-
totalRows
|
1023
|
-
currentFilters
|
1024
|
-
ajaxUrl
|
1025
|
-
optAjaxUrl
|
1064
|
+
sortList: ( c.sortList || [] ).join( ',' ),
|
1065
|
+
totalRows: p.totalRows,
|
1066
|
+
currentFilters: p.currentFilters || [],
|
1067
|
+
ajaxUrl: p.ajaxObject.url || '',
|
1068
|
+
optAjaxUrl: wo.pager_ajaxUrl
|
1026
1069
|
};
|
1027
|
-
if (p.ajax) {
|
1028
|
-
tsp.getAjax(
|
1029
|
-
} else if (!p.ajax) {
|
1030
|
-
tsp.renderTable(
|
1070
|
+
if ( p.ajax ) {
|
1071
|
+
tsp.getAjax( c );
|
1072
|
+
} else if ( !p.ajax ) {
|
1073
|
+
tsp.renderTable( c, c.rowsCopy );
|
1031
1074
|
}
|
1032
|
-
$.data(table, 'pagerLastPage', p.page);
|
1033
|
-
if (p.initialized && pageMoved !== false) {
|
1034
|
-
if (c.debug) {
|
1035
|
-
console.log('Pager: Triggering pageMoved');
|
1075
|
+
$.data( table, 'pagerLastPage', p.page );
|
1076
|
+
if ( p.initialized && pageMoved !== false ) {
|
1077
|
+
if ( c.debug ) {
|
1078
|
+
console.log( 'Pager: Triggering pageMoved' );
|
1036
1079
|
}
|
1037
|
-
c.$table.trigger('pageMoved', c);
|
1080
|
+
c.$table.trigger( 'pageMoved', c );
|
1038
1081
|
ts.applyWidget( table );
|
1039
|
-
if (!p.ajax && table.isUpdating) {
|
1040
|
-
if (c.debug) {
|
1041
|
-
console.log('Pager: Triggering updateComplete');
|
1082
|
+
if ( !p.ajax && table.isUpdating ) {
|
1083
|
+
if ( c.debug ) {
|
1084
|
+
console.log( 'Pager: Triggering updateComplete' );
|
1042
1085
|
}
|
1043
|
-
c.$table.trigger('updateComplete', [ table, true ]);
|
1086
|
+
c.$table.trigger( 'updateComplete', [ table, true ] );
|
1044
1087
|
}
|
1045
1088
|
}
|
1046
1089
|
},
|
1047
1090
|
|
1091
|
+
getTotalPages: function( c, p ) {
|
1092
|
+
return ts.hasWidget( c.table, 'filter' ) ? Math.min( p.totalPages, p.filteredPages ) : p.totalPages;
|
1093
|
+
},
|
1094
|
+
|
1048
1095
|
// set to either set or get value
|
1049
1096
|
parsePageSize: function( c, size, mode ) {
|
1050
1097
|
var p = c.pager,
|
@@ -1057,54 +1104,56 @@
|
|
1057
1104
|
( mode === 'get' ? s : p.size );
|
1058
1105
|
},
|
1059
1106
|
|
1060
|
-
parsePageNumber: function( p ) {
|
1061
|
-
var min =
|
1107
|
+
parsePageNumber: function( c, p ) {
|
1108
|
+
var min = tsp.getTotalPages( c, p ) - 1;
|
1062
1109
|
p.page = parseInt( p.page, 10 );
|
1063
1110
|
if ( p.page < 0 || isNaN( p.page ) ) { p.page = 0; }
|
1064
|
-
if ( p.page > min &&
|
1111
|
+
if ( p.page > min && min >= 0 ) { p.page = min; }
|
1065
1112
|
return p.page;
|
1066
1113
|
},
|
1067
1114
|
|
1068
|
-
setPageSize: function(c, size) {
|
1115
|
+
setPageSize: function( c, size ) {
|
1069
1116
|
var p = c.pager,
|
1070
1117
|
table = c.table;
|
1071
1118
|
p.size = tsp.parsePageSize( c, size, 'get' );
|
1072
1119
|
p.$size.val( tsp.parsePageSize( c, p.size, 'set' ) );
|
1073
|
-
$.data(table, 'pagerLastPage', tsp.parsePageNumber( p ) );
|
1074
|
-
$.data(table, 'pagerLastSize', p.size);
|
1120
|
+
$.data( table, 'pagerLastPage', tsp.parsePageNumber( c, p ) );
|
1121
|
+
$.data( table, 'pagerLastSize', p.size );
|
1075
1122
|
p.totalPages = Math.ceil( p.totalRows / p.size );
|
1076
1123
|
p.filteredPages = Math.ceil( p.filteredRows / p.size );
|
1077
|
-
tsp.moveToPage(
|
1124
|
+
tsp.moveToPage( c, p, true );
|
1078
1125
|
},
|
1079
1126
|
|
1080
|
-
moveToFirstPage: function(
|
1127
|
+
moveToFirstPage: function( c, p ) {
|
1081
1128
|
p.page = 0;
|
1082
|
-
tsp.moveToPage(
|
1129
|
+
tsp.moveToPage( c, p, true );
|
1083
1130
|
},
|
1084
1131
|
|
1085
|
-
moveToLastPage: function(
|
1086
|
-
p.page =
|
1087
|
-
tsp.moveToPage(
|
1132
|
+
moveToLastPage: function( c, p ) {
|
1133
|
+
p.page = tsp.getTotalPages( c, p ) - 1;
|
1134
|
+
tsp.moveToPage( c, p, true );
|
1088
1135
|
},
|
1089
1136
|
|
1090
|
-
moveToNextPage: function(
|
1137
|
+
moveToNextPage: function( c, p ) {
|
1091
1138
|
p.page++;
|
1092
|
-
|
1093
|
-
|
1139
|
+
var last = tsp.getTotalPages( c, p ) - 1;
|
1140
|
+
if ( p.page >= last ) {
|
1141
|
+
p.page = last;
|
1094
1142
|
}
|
1095
|
-
tsp.moveToPage(
|
1143
|
+
tsp.moveToPage( c, p, true );
|
1096
1144
|
},
|
1097
1145
|
|
1098
|
-
moveToPrevPage: function(
|
1146
|
+
moveToPrevPage: function( c, p ) {
|
1099
1147
|
p.page--;
|
1100
1148
|
if ( p.page <= 0 ) {
|
1101
1149
|
p.page = 0;
|
1102
1150
|
}
|
1103
|
-
tsp.moveToPage(
|
1151
|
+
tsp.moveToPage( c, p, true );
|
1104
1152
|
},
|
1105
1153
|
|
1106
|
-
destroyPager: function(
|
1107
|
-
var
|
1154
|
+
destroyPager: function( c, refreshing ) {
|
1155
|
+
var table = c.table,
|
1156
|
+
p = c.pager,
|
1108
1157
|
s = c.widgetOptions.pager_selectors,
|
1109
1158
|
ctrls = [ s.first, s.prev, s.next, s.last, s.gotoPage, s.pageSize ].join( ',' ),
|
1110
1159
|
namespace = c.namespace + 'pager';
|
@@ -1117,57 +1166,58 @@
|
|
1117
1166
|
.find( ctrls )
|
1118
1167
|
.off( namespace );
|
1119
1168
|
if ( refreshing ) { return; }
|
1120
|
-
tsp.showAllRows(
|
1169
|
+
tsp.showAllRows( c );
|
1121
1170
|
c.appender = null; // remove pager appender function
|
1122
|
-
if (ts.storage) {
|
1123
|
-
ts.storage(table, c.widgetOptions.pager_storageKey, '');
|
1171
|
+
if ( ts.storage ) {
|
1172
|
+
ts.storage( table, c.widgetOptions.pager_storageKey, '' );
|
1124
1173
|
}
|
1125
1174
|
delete table.config.pager;
|
1126
1175
|
delete table.config.rowsCopy;
|
1127
1176
|
},
|
1128
1177
|
|
1129
|
-
enablePager: function(
|
1178
|
+
enablePager: function( c, triggered ) {
|
1130
1179
|
var info, size,
|
1180
|
+
table = c.table,
|
1131
1181
|
p = c.pager;
|
1132
1182
|
p.isDisabled = false;
|
1133
|
-
p.page = $.data(table, 'pagerLastPage') || p.page || 0;
|
1134
|
-
size = p.$size.find('option[selected]').val();
|
1135
|
-
p.size = $.data(table, 'pagerLastSize') || tsp.parsePageSize( c, size, 'get' );
|
1183
|
+
p.page = $.data( table, 'pagerLastPage' ) || p.page || 0;
|
1184
|
+
size = p.$size.find( 'option[selected]' ).val();
|
1185
|
+
p.size = $.data( table, 'pagerLastSize' ) || tsp.parsePageSize( c, size, 'get' );
|
1136
1186
|
p.$size.val( tsp.parsePageSize( c, p.size, 'set' ) ); // set page size
|
1137
|
-
p.totalPages = Math.ceil(
|
1138
|
-
c.$table.removeClass('pagerDisabled');
|
1187
|
+
p.totalPages = Math.ceil( tsp.getTotalPages( c, p ) / p.size );
|
1188
|
+
c.$table.removeClass( 'pagerDisabled' );
|
1139
1189
|
// if table id exists, include page display with aria info
|
1140
1190
|
if ( table.id ) {
|
1141
1191
|
info = table.id + '_pager_info';
|
1142
|
-
p.$container.find(c.widgetOptions.pager_selectors.pageDisplay).attr('id', info);
|
1143
|
-
c.$table.attr('aria-describedby', info);
|
1192
|
+
p.$container.find( c.widgetOptions.pager_selectors.pageDisplay ).attr( 'id', info );
|
1193
|
+
c.$table.attr( 'aria-describedby', info );
|
1144
1194
|
}
|
1145
|
-
tsp.changeHeight(
|
1195
|
+
tsp.changeHeight( c );
|
1146
1196
|
if ( triggered ) {
|
1147
1197
|
// tablesorter core update table
|
1148
1198
|
ts.update( c );
|
1149
|
-
tsp.setPageSize(c, p.size);
|
1150
|
-
tsp.hideRowsSetup(
|
1151
|
-
if (c.debug) {
|
1152
|
-
console.log('Pager: Enabled');
|
1199
|
+
tsp.setPageSize( c, p.size );
|
1200
|
+
tsp.hideRowsSetup( c );
|
1201
|
+
if ( c.debug ) {
|
1202
|
+
console.log( 'Pager: Enabled' );
|
1153
1203
|
}
|
1154
1204
|
}
|
1155
1205
|
},
|
1156
1206
|
|
1157
|
-
appender: function(table, rows) {
|
1207
|
+
appender: function( table, rows ) {
|
1158
1208
|
var c = table.config,
|
1159
1209
|
wo = c.widgetOptions,
|
1160
1210
|
p = c.pager;
|
1161
1211
|
if ( !p.ajax ) {
|
1162
1212
|
c.rowsCopy = rows;
|
1163
|
-
p.totalRows = wo.pager_countChildRows ? c.$tbodies.eq(0).children('tr').length : rows.length;
|
1164
|
-
p.size = $.data(table, 'pagerLastSize') || p.size || wo.pager_size || p.setSize || 10;
|
1213
|
+
p.totalRows = wo.pager_countChildRows ? c.$tbodies.eq( 0 ).children( 'tr' ).length : rows.length;
|
1214
|
+
p.size = $.data( table, 'pagerLastSize' ) || p.size || wo.pager_size || p.setSize || 10;
|
1165
1215
|
p.totalPages = Math.ceil( p.totalRows / p.size );
|
1166
|
-
tsp.moveToPage(
|
1216
|
+
tsp.moveToPage( c, p );
|
1167
1217
|
// update display here in case all rows are removed
|
1168
|
-
tsp.updatePageDisplay(
|
1218
|
+
tsp.updatePageDisplay( c, false );
|
1169
1219
|
} else {
|
1170
|
-
tsp.moveToPage(
|
1220
|
+
tsp.moveToPage( c, p, true );
|
1171
1221
|
}
|
1172
1222
|
}
|
1173
1223
|
|
@@ -1177,7 +1227,7 @@
|
|
1177
1227
|
ts.showError = function( table, xhr, settings, exception ) {
|
1178
1228
|
var $row,
|
1179
1229
|
$table = $( table ),
|
1180
|
-
c = $table[0].config,
|
1230
|
+
c = $table[ 0 ].config,
|
1181
1231
|
wo = c && c.widgetOptions,
|
1182
1232
|
errorRow = c.pager && c.pager.cssErrorRow ||
|
1183
1233
|
wo && wo.pager_css && wo.pager_css.errorRow ||
|
@@ -1185,12 +1235,12 @@
|
|
1185
1235
|
typ = typeof xhr,
|
1186
1236
|
valid = true,
|
1187
1237
|
message = '',
|
1188
|
-
removeRow = function(){
|
1238
|
+
removeRow = function() {
|
1189
1239
|
c.$table.find( 'thead' ).find( '.' + errorRow ).remove();
|
1190
1240
|
};
|
1191
1241
|
|
1192
1242
|
if ( !$table.length ) {
|
1193
|
-
console.error('tablesorter showError: no table parameter passed');
|
1243
|
+
console.error( 'tablesorter showError: no table parameter passed' );
|
1194
1244
|
return;
|
1195
1245
|
}
|
1196
1246
|
|
@@ -1231,16 +1281,18 @@
|
|
1231
1281
|
}
|
1232
1282
|
|
1233
1283
|
// allow message to include entire row HTML!
|
1234
|
-
$row = ( /tr\>/.test(
|
1284
|
+
$row = ( /tr\>/.test( message ) ?
|
1285
|
+
$( message ) :
|
1286
|
+
$( '<tr><td colspan="' + c.columns + '">' + message + '</td></tr>' ) )
|
1235
1287
|
.click( function() {
|
1236
1288
|
$( this ).remove();
|
1237
1289
|
})
|
1238
1290
|
// add error row to thead instead of tbody, or clicking on the header will result in a parser error
|
1239
1291
|
.appendTo( c.$table.find( 'thead:first' ) )
|
1240
|
-
.addClass( errorRow + ' ' + c.selectorRemove.slice(1) )
|
1292
|
+
.addClass( errorRow + ' ' + c.selectorRemove.slice( 1 ) )
|
1241
1293
|
.attr({
|
1242
|
-
role
|
1243
|
-
'aria-live'
|
1294
|
+
role: 'alert',
|
1295
|
+
'aria-live': 'assertive'
|
1244
1296
|
});
|
1245
1297
|
|
1246
1298
|
};
|