jquery-tablesorter 1.21.1 → 1.21.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb2ba06f45b4d250693949a5d773166da7c07ea9
4
- data.tar.gz: 6a0fb6f57c8cc04560b509c54440ea34ea1017b0
3
+ metadata.gz: 7b9922d7996173a6f66fddcb2f5a97e454460048
4
+ data.tar.gz: c882c95cec3c5834b622c5520bfb61cfa82d7396
5
5
  SHA512:
6
- metadata.gz: 796f72bd34bd69508cf330100a603745e37d5878c374e08e1028ec99670cafd5124052ef899e1d7327e0f95d25246d47b0cfa5b7453b8ed6306359f7181b7b4e
7
- data.tar.gz: 6d9bf1b74b466881db498b59697b15bff8e0463a90d05ab8c2c7d8b911cc4688febbf407fecf09f4bf758b66a7e3b9a1d45ffbf15df7315afd5b7b4100aa8347
6
+ metadata.gz: 06f345cb454aab77123a867df03dd608f7630b7af0873430cc78ffc179368ce3cf812a12eeb4d56f7fd63b0ec873e6d958722a4467daacc19cad8334cf5192b2
7
+ data.tar.gz: 6f5cf3d7b721658937eb9fad720f77e5e38c41dc63a8f8b5268ef5afe1c928b282d40f2f93c9dedc7be630c2e676656147f5c3ac22ef08d5f497a632380e7836
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Simple integration of jquery-tablesorter into the asset pipeline.
6
6
 
7
- Current tablesorter version: 2.26.1 (5/16/2016), [documentation]
7
+ Current tablesorter version: 2.26.4 (6/15/2016), [documentation]
8
8
 
9
9
  Any issue associated with the js/css files, please report to [Mottie's fork].
10
10
 
@@ -1,7 +1,7 @@
1
1
  module JqueryTablesorter
2
2
  MAJOR = 1
3
3
  MINOR = 21
4
- TINY = 1
4
+ TINY = 2
5
5
 
6
6
  VERSION = [MAJOR, MINOR, TINY].compact.join('.')
7
7
  end
@@ -1,188 +1,189 @@
1
1
  /*!
2
- * tablesorter (FORK) pager plugin
3
- * updated 5/1/2016 (v2.26.0)
4
- */
2
+ * tablesorter (FORK) pager plugin
3
+ * updated 5/1/2016 (v2.26.0)
4
+ */
5
5
  /*jshint browser:true, jquery:true, unused:false */
6
6
  ;(function($) {
7
7
  'use strict';
8
8
  /*jshint supernew:true */
9
9
  var ts = $.tablesorter;
10
10
 
11
- $.extend({ tablesorterPager: new function() {
11
+ $.extend({
12
+ tablesorterPager: new function() {
13
+
14
+ this.defaults = {
15
+ // target the pager markup
16
+ container: null,
17
+
18
+ // use this format: "http://mydatabase.com?page={page}&size={size}&{sortList:col}&{filterList:fcol}"
19
+ // where {page} is replaced by the page number, {size} is replaced by the number of records to show,
20
+ // {sortList:col} adds the sortList to the url into a "col" array, and {filterList:fcol} adds
21
+ // the filterList to the url into an "fcol" array.
22
+ // So a sortList = [[2,0],[3,0]] becomes "&col[2]=0&col[3]=0" in the url
23
+ // and a filterList = [[2,Blue],[3,13]] becomes "&fcol[2]=Blue&fcol[3]=13" in the url
24
+ ajaxUrl: null,
25
+
26
+ // modify the url after all processing has been applied
27
+ customAjaxUrl: function(table, url) { return url; },
28
+
29
+ // ajax error callback from $.tablesorter.showError function
30
+ // ajaxError: function( config, xhr, settings, exception ){ return exception; };
31
+ // returning false will abort the error message
32
+ ajaxError: null,
33
+
34
+ // modify the $.ajax object to allow complete control over your ajax requests
35
+ ajaxObject: {
36
+ dataType: 'json'
37
+ },
38
+
39
+ // set this to false if you want to block ajax loading on init
40
+ processAjaxOnInit: true,
41
+
42
+ // process ajax so that the following information is returned:
43
+ // [ total_rows (number), rows (array of arrays), headers (array; optional) ]
44
+ // example:
45
+ // [
46
+ // 100, // total rows
47
+ // [
48
+ // [ "row1cell1", "row1cell2", ... "row1cellN" ],
49
+ // [ "row2cell1", "row2cell2", ... "row2cellN" ],
50
+ // ...
51
+ // [ "rowNcell1", "rowNcell2", ... "rowNcellN" ]
52
+ // ],
53
+ // [ "header1", "header2", ... "headerN" ] // optional
54
+ // ]
55
+ ajaxProcessing: function(ajax){ return [ 0, [], null ]; },
56
+
57
+ // output default: '{page}/{totalPages}'
58
+ // possible variables: {size}, {page}, {totalPages}, {filteredPages}, {startRow},
59
+ // {endRow}, {filteredRows} and {totalRows}
60
+ output: '{startRow} to {endRow} of {totalRows} rows', // '{page}/{totalPages}'
61
+
62
+ // apply disabled classname to the pager arrows when the rows at either extreme is visible
63
+ updateArrows: true,
64
+
65
+ // starting page of the pager (zero based index)
66
+ page: 0,
67
+
68
+ // reset pager after filtering; set to desired page #
69
+ // set to false to not change page at filter start
70
+ pageReset: 0,
71
+
72
+ // Number of visible rows
73
+ size: 10,
74
+
75
+ // Number of options to include in the pager number selector
76
+ maxOptionSize: 20,
77
+
78
+ // Save pager page & size if the storage script is loaded (requires $.tablesorter.storage in jquery.tablesorter.widgets.js)
79
+ savePages: true,
80
+
81
+ // defines custom storage key
82
+ storageKey: 'tablesorter-pager',
83
+
84
+ // if true, the table will remain the same height no matter how many records are displayed. The space is made up by an empty
85
+ // table row set to a height to compensate; default is false
86
+ fixedHeight: false,
87
+
88
+ // count child rows towards the set page size? (set true if it is a visible table row within the pager)
89
+ // if true, child row(s) may not appear to be attached to its parent row, may be split across pages or
90
+ // may distort the table if rowspan or cellspans are included.
91
+ countChildRows: false,
92
+
93
+ // remove rows from the table to speed up the sort of large tables.
94
+ // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled.
95
+ removeRows: false, // removing rows in larger tables speeds up the sort
96
+
97
+ // css class names of pager arrows
98
+ cssFirst: '.first', // go to first page arrow
99
+ cssPrev: '.prev', // previous page arrow
100
+ cssNext: '.next', // next page arrow
101
+ cssLast: '.last', // go to last page arrow
102
+ cssGoto: '.gotoPage', // go to page selector - select dropdown that sets the current page
103
+ cssPageDisplay: '.pagedisplay', // location of where the "output" is displayed
104
+ cssPageSize: '.pagesize', // page size selector - select dropdown that sets the "size" option
105
+ cssErrorRow: 'tablesorter-errorRow', // error information row
106
+
107
+ // class added to arrows when at the extremes (i.e. prev/first arrows are "disabled" when on the first page)
108
+ cssDisabled: 'disabled', // Note there is no period "." in front of this class name
109
+
110
+ // stuff not set by the user
111
+ totalRows: 0,
112
+ totalPages: 0,
113
+ filteredRows: 0,
114
+ filteredPages: 0,
115
+ ajaxCounter: 0,
116
+ currentFilters: [],
117
+ startRow: 0,
118
+ endRow: 0,
119
+ $size: null,
120
+ last: {}
12
121
 
13
- this.defaults = {
14
- // target the pager markup
15
- container: null,
16
-
17
- // use this format: "http://mydatabase.com?page={page}&size={size}&{sortList:col}&{filterList:fcol}"
18
- // where {page} is replaced by the page number, {size} is replaced by the number of records to show,
19
- // {sortList:col} adds the sortList to the url into a "col" array, and {filterList:fcol} adds
20
- // the filterList to the url into an "fcol" array.
21
- // So a sortList = [[2,0],[3,0]] becomes "&col[2]=0&col[3]=0" in the url
22
- // and a filterList = [[2,Blue],[3,13]] becomes "&fcol[2]=Blue&fcol[3]=13" in the url
23
- ajaxUrl: null,
24
-
25
- // modify the url after all processing has been applied
26
- customAjaxUrl: function(table, url) { return url; },
27
-
28
- // ajax error callback from $.tablesorter.showError function
29
- // ajaxError: function( config, xhr, settings, exception ){ return exception; };
30
- // returning false will abort the error message
31
- ajaxError: null,
32
-
33
- // modify the $.ajax object to allow complete control over your ajax requests
34
- ajaxObject: {
35
- dataType: 'json'
36
- },
37
-
38
- // set this to false if you want to block ajax loading on init
39
- processAjaxOnInit: true,
40
-
41
- // process ajax so that the following information is returned:
42
- // [ total_rows (number), rows (array of arrays), headers (array; optional) ]
43
- // example:
44
- // [
45
- // 100, // total rows
46
- // [
47
- // [ "row1cell1", "row1cell2", ... "row1cellN" ],
48
- // [ "row2cell1", "row2cell2", ... "row2cellN" ],
49
- // ...
50
- // [ "rowNcell1", "rowNcell2", ... "rowNcellN" ]
51
- // ],
52
- // [ "header1", "header2", ... "headerN" ] // optional
53
- // ]
54
- ajaxProcessing: function(ajax){ return [ 0, [], null ]; },
55
-
56
- // output default: '{page}/{totalPages}'
57
- // possible variables: {size}, {page}, {totalPages}, {filteredPages}, {startRow},
58
- // {endRow}, {filteredRows} and {totalRows}
59
- output: '{startRow} to {endRow} of {totalRows} rows', // '{page}/{totalPages}'
60
-
61
- // apply disabled classname to the pager arrows when the rows at either extreme is visible
62
- updateArrows: true,
63
-
64
- // starting page of the pager (zero based index)
65
- page: 0,
66
-
67
- // reset pager after filtering; set to desired page #
68
- // set to false to not change page at filter start
69
- pageReset: 0,
70
-
71
- // Number of visible rows
72
- size: 10,
73
-
74
- // Number of options to include in the pager number selector
75
- maxOptionSize: 20,
76
-
77
- // Save pager page & size if the storage script is loaded (requires $.tablesorter.storage in jquery.tablesorter.widgets.js)
78
- savePages: true,
79
-
80
- // defines custom storage key
81
- storageKey: 'tablesorter-pager',
82
-
83
- // if true, the table will remain the same height no matter how many records are displayed. The space is made up by an empty
84
- // table row set to a height to compensate; default is false
85
- fixedHeight: false,
86
-
87
- // count child rows towards the set page size? (set true if it is a visible table row within the pager)
88
- // if true, child row(s) may not appear to be attached to its parent row, may be split across pages or
89
- // may distort the table if rowspan or cellspans are included.
90
- countChildRows: false,
91
-
92
- // remove rows from the table to speed up the sort of large tables.
93
- // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled.
94
- removeRows: false, // removing rows in larger tables speeds up the sort
95
-
96
- // css class names of pager arrows
97
- cssFirst: '.first', // go to first page arrow
98
- cssPrev: '.prev', // previous page arrow
99
- cssNext: '.next', // next page arrow
100
- cssLast: '.last', // go to last page arrow
101
- cssGoto: '.gotoPage', // go to page selector - select dropdown that sets the current page
102
- cssPageDisplay: '.pagedisplay', // location of where the "output" is displayed
103
- cssPageSize: '.pagesize', // page size selector - select dropdown that sets the "size" option
104
- cssErrorRow: 'tablesorter-errorRow', // error information row
105
-
106
- // class added to arrows when at the extremes (i.e. prev/first arrows are "disabled" when on the first page)
107
- cssDisabled: 'disabled', // Note there is no period "." in front of this class name
108
-
109
- // stuff not set by the user
110
- totalRows: 0,
111
- totalPages: 0,
112
- filteredRows: 0,
113
- filteredPages: 0,
114
- ajaxCounter: 0,
115
- currentFilters: [],
116
- startRow: 0,
117
- endRow: 0,
118
- $size: null,
119
- last: {}
120
-
121
- };
122
+ };
122
123
 
123
- var pagerEvents = 'filterInit filterStart filterEnd sortEnd disablePager enablePager destroyPager updateComplete ' +
124
+ var pagerEvents = 'filterInit filterStart filterEnd sortEnd disablePager enablePager destroyPager updateComplete ' +
124
125
  'pageSize pageSet pageAndSize pagerUpdate refreshComplete ',
125
126
 
126
- $this = this,
127
-
128
- // hide arrows at extremes
129
- pagerArrows = function( table, p, disable ) {
130
- var a = 'addClass',
131
- r = 'removeClass',
132
- d = p.cssDisabled,
133
- dis = !!disable,
134
- first = ( dis || p.page === 0 ),
135
- tp = getTotalPages( table, p ),
136
- last = ( dis || (p.page === tp - 1) || tp === 0 );
137
- if ( p.updateArrows ) {
138
- p.$container.find(p.cssFirst + ',' + p.cssPrev)[ first ? a : r ](d).attr('aria-disabled', first);
139
- p.$container.find(p.cssNext + ',' + p.cssLast)[ last ? a : r ](d).attr('aria-disabled', last);
140
- }
141
- },
127
+ $this = this,
128
+
129
+ // hide arrows at extremes
130
+ pagerArrows = function( table, p, disable ) {
131
+ var a = 'addClass',
132
+ r = 'removeClass',
133
+ d = p.cssDisabled,
134
+ dis = !!disable,
135
+ first = ( dis || p.page === 0 ),
136
+ tp = getTotalPages( table, p ),
137
+ last = ( dis || (p.page === tp - 1) || tp === 0 );
138
+ if ( p.updateArrows ) {
139
+ p.$container.find(p.cssFirst + ',' + p.cssPrev)[ first ? a : r ](d).attr('aria-disabled', first);
140
+ p.$container.find(p.cssNext + ',' + p.cssLast)[ last ? a : r ](d).attr('aria-disabled', last);
141
+ }
142
+ },
142
143
 
143
- calcFilters = function(table, p) {
144
- var normalized, indx, len,
144
+ calcFilters = function(table, p) {
145
+ var normalized, indx, len,
145
146
  c = table.config,
146
147
  hasFilters = c.$table.hasClass('hasFilters');
147
- if (hasFilters && !p.ajaxUrl) {
148
- if (ts.isEmptyObject(c.cache)) {
149
- // delayInit: true so nothing is in the cache
150
- p.filteredRows = p.totalRows = c.$tbodies.eq(0).children('tr').not( p.countChildRows ? '' : '.' + c.cssChildRow ).length;
151
- } else {
152
- p.filteredRows = 0;
153
- normalized = c.cache[0].normalized;
154
- len = normalized.length;
155
- for (indx = 0; indx < len; indx++) {
156
- p.filteredRows += p.regexRows.test(normalized[indx][c.columns].$row[0].className) ? 0 : 1;
148
+ if (hasFilters && !p.ajaxUrl) {
149
+ if (ts.isEmptyObject(c.cache)) {
150
+ // delayInit: true so nothing is in the cache
151
+ p.filteredRows = p.totalRows = c.$tbodies.eq(0).children('tr').not( p.countChildRows ? '' : '.' + c.cssChildRow ).length;
152
+ } else {
153
+ p.filteredRows = 0;
154
+ normalized = c.cache[0].normalized;
155
+ len = normalized.length;
156
+ for (indx = 0; indx < len; indx++) {
157
+ p.filteredRows += p.regexRows.test(normalized[indx][c.columns].$row[0].className) ? 0 : 1;
158
+ }
157
159
  }
160
+ } else if (!hasFilters) {
161
+ p.filteredRows = p.totalRows;
158
162
  }
159
- } else if (!hasFilters) {
160
- p.filteredRows = p.totalRows;
161
- }
162
- },
163
+ },
163
164
 
164
- updatePageDisplay = function(table, p, completed) {
165
- if ( p.initializing ) { return; }
166
- var s, t, $out, indx, len, options,
165
+ updatePageDisplay = function(table, p, completed) {
166
+ if ( p.initializing ) { return; }
167
+ var s, t, $out, indx, len, options,
167
168
  c = table.config,
168
169
  namespace = c.namespace + 'pager',
169
170
  sz = parsePageSize( p, p.size, 'get' ); // don't allow dividing by zero
170
- if (sz === 'all') { sz = p.totalRows; }
171
- if (p.countChildRows) { t[ t.length ] = c.cssChildRow; }
172
- p.totalPages = Math.ceil( p.totalRows / sz ); // needed for "pageSize" method
173
- c.totalRows = p.totalRows;
174
- parsePageNumber( table, p );
175
- calcFilters(table, p);
176
- c.filteredRows = p.filteredRows;
177
- p.filteredPages = Math.ceil( p.filteredRows / sz ) || 0;
178
- if ( getTotalPages( table, p ) >= 0 ) {
179
- t = (sz * p.page > p.filteredRows) && completed;
180
- p.page = (t) ? p.pageReset || 0 : p.page;
181
- p.startRow = (t) ? sz * p.page + 1 : (p.filteredRows === 0 ? 0 : sz * p.page + 1);
182
- p.endRow = Math.min( p.filteredRows, p.totalRows, sz * ( p.page + 1 ) );
183
- $out = p.$container.find(p.cssPageDisplay);
184
- // form the output string (can now get a new output string from the server)
185
- s = ( p.ajaxData && p.ajaxData.output ? p.ajaxData.output || p.output : p.output )
171
+ if (sz === 'all') { sz = p.totalRows; }
172
+ if (p.countChildRows) { t[ t.length ] = c.cssChildRow; }
173
+ p.totalPages = Math.ceil( p.totalRows / sz ); // needed for "pageSize" method
174
+ c.totalRows = p.totalRows;
175
+ parsePageNumber( table, p );
176
+ calcFilters(table, p);
177
+ c.filteredRows = p.filteredRows;
178
+ p.filteredPages = Math.ceil( p.filteredRows / sz ) || 0;
179
+ if ( getTotalPages( table, p ) >= 0 ) {
180
+ t = (sz * p.page > p.filteredRows) && completed;
181
+ p.page = (t) ? p.pageReset || 0 : p.page;
182
+ p.startRow = (t) ? sz * p.page + 1 : (p.filteredRows === 0 ? 0 : sz * p.page + 1);
183
+ p.endRow = Math.min( p.filteredRows, p.totalRows, sz * ( p.page + 1 ) );
184
+ $out = p.$container.find(p.cssPageDisplay);
185
+ // form the output string (can now get a new output string from the server)
186
+ s = ( p.ajaxData && p.ajaxData.output ? p.ajaxData.output || p.output : p.output )
186
187
  // {page} = one-based index; {page+#} = zero based index +/- value
187
188
  .replace(/\{page([\-+]\d+)?\}/gi, function(m, n){
188
189
  return p.totalPages ? p.page + (n ? parseInt(n, 10) : 1) : 0;
@@ -190,11 +191,11 @@
190
191
  // {totalPages}, {extra}, {extra:0} (array) or {extra : key} (object)
191
192
  .replace(/\{\w+(\s*:\s*\w+)?\}/gi, function(m){
192
193
  var len, indx,
193
- str = m.replace(/[{}\s]/g, ''),
194
- extra = str.split(':'),
195
- data = p.ajaxData,
196
- // return zero for default page/row numbers
197
- deflt = /(rows?|pages?)$/i.test(str) ? 0 : '';
194
+ str = m.replace(/[{}\s]/g, ''),
195
+ extra = str.split(':'),
196
+ data = p.ajaxData,
197
+ // return zero for default page/row numbers
198
+ deflt = /(rows?|pages?)$/i.test(str) ? 0 : '';
198
199
  if (/(startRow|page)/.test(extra[0]) && extra[1] === 'input') {
199
200
  len = ('' + (extra[0] === 'page' ? p.totalPages : p.totalRows)).length;
200
201
  indx = extra[0] === 'page' ? p.page + 1 : p.startRow;
@@ -202,47 +203,47 @@
202
203
  }
203
204
  return extra.length > 1 && data && data[extra[0]] ? data[extra[0]][extra[1]] : p[str] || (data ? data[str] : deflt) || deflt;
204
205
  });
205
- if ( p.$goto.length ) {
206
- t = '';
207
- options = buildPageSelect( table, p );
208
- len = options.length;
209
- for (indx = 0; indx < len; indx++) {
210
- t += '<option value="' + options[indx] + '">' + options[indx] + '</option>';
206
+ if ( p.$goto.length ) {
207
+ t = '';
208
+ options = buildPageSelect( table, p );
209
+ len = options.length;
210
+ for (indx = 0; indx < len; indx++) {
211
+ t += '<option value="' + options[indx] + '">' + options[indx] + '</option>';
212
+ }
213
+ // innerHTML doesn't work in IE9 - http://support2.microsoft.com/kb/276228
214
+ p.$goto.html(t).val( p.page + 1 );
211
215
  }
212
- // innerHTML doesn't work in IE9 - http://support2.microsoft.com/kb/276228
213
- p.$goto.html(t).val( p.page + 1 );
214
- }
215
- if ($out.length) {
216
- $out[ ($out[0].nodeName === 'INPUT') ? 'val' : 'html' ](s);
217
- // rebind startRow/page inputs
218
- $out.find('.ts-startRow, .ts-page').unbind('change' + namespace).bind('change' + namespace, function(){
219
- var v = $(this).val(),
216
+ if ($out.length) {
217
+ $out[ ($out[0].nodeName === 'INPUT') ? 'val' : 'html' ](s);
218
+ // rebind startRow/page inputs
219
+ $out.find('.ts-startRow, .ts-page').unbind('change' + namespace).bind('change' + namespace, function(){
220
+ var v = $(this).val(),
220
221
  pg = $(this).hasClass('ts-startRow') ? Math.floor( v / sz ) + 1 : v;
221
- c.$table.triggerHandler('pageSet' + namespace, [ pg ]);
222
- });
223
- }
224
- }
225
- pagerArrows( table, p );
226
- fixHeight(table, p);
227
- if (p.initialized && completed !== false) {
228
- if (c.debug) {
229
- console.log('Pager: Triggering pagerComplete');
222
+ c.$table.triggerHandler('pageSet' + namespace, [ pg ]);
223
+ });
224
+ }
230
225
  }
231
- c.$table.triggerHandler('pagerComplete', p);
232
- // save pager info to storage
233
- if (p.savePages && ts.storage) {
234
- ts.storage(table, p.storageKey, {
235
- page : p.page,
236
- size : sz === p.totalRows ? 'all' : sz
237
- });
226
+ pagerArrows( table, p );
227
+ fixHeight(table, p);
228
+ if (p.initialized && completed !== false) {
229
+ if (c.debug) {
230
+ console.log('Pager: Triggering pagerComplete');
231
+ }
232
+ c.$table.triggerHandler('pagerComplete', p);
233
+ // save pager info to storage
234
+ if (p.savePages && ts.storage) {
235
+ ts.storage(table, p.storageKey, {
236
+ page : p.page,
237
+ size : sz === p.totalRows ? 'all' : sz
238
+ });
239
+ }
238
240
  }
239
- }
240
- },
241
+ },
241
242
 
242
- buildPageSelect = function( table, p ) {
243
- // Filter the options page number link array if it's larger than 'maxOptionSize'
244
- // as large page set links will slow the browser on large dom inserts
245
- var i, central_focus_size, focus_option_pages, insert_index, option_length, focus_length,
243
+ buildPageSelect = function( table, p ) {
244
+ // Filter the options page number link array if it's larger than 'maxOptionSize'
245
+ // as large page set links will slow the browser on large dom inserts
246
+ var i, central_focus_size, focus_option_pages, insert_index, option_length, focus_length,
246
247
  pg = getTotalPages( table, p ) || 1,
247
248
  // make skip set size multiples of 5
248
249
  skip_set_size = Math.ceil( ( pg / p.maxOptionSize ) / 5 ) * 5,
@@ -254,666 +255,666 @@
254
255
  // construct default options pages array
255
256
  option_pages_start_page = (large_collection) ? skip_set_size : 1;
256
257
 
257
- for ( i = option_pages_start_page; i <= pg; ) {
258
- option_pages[ option_pages.length ] = i;
259
- i = i + ( large_collection ? skip_set_size : 1 );
260
- }
261
- option_pages[ option_pages.length ] = pg;
262
- if (large_collection) {
263
- focus_option_pages = [];
264
- // don't allow central focus size to be > 5 on either side of current page
265
- central_focus_size = Math.max( Math.floor( p.maxOptionSize / skip_set_size ) - 1, 5 );
266
-
267
- start_page = current_page - central_focus_size;
268
- if (start_page < 1) { start_page = 1; }
269
- end_page = current_page + central_focus_size;
270
- if (end_page > pg) { end_page = pg; }
271
- // construct an array to get a focus set around the current page
272
- for (i = start_page; i <= end_page ; i++) {
273
- focus_option_pages[ focus_option_pages.length ] = i;
258
+ for ( i = option_pages_start_page; i <= pg; ) {
259
+ option_pages[ option_pages.length ] = i;
260
+ i = i + ( large_collection ? skip_set_size : 1 );
274
261
  }
262
+ option_pages[ option_pages.length ] = pg;
263
+ if (large_collection) {
264
+ focus_option_pages = [];
265
+ // don't allow central focus size to be > 5 on either side of current page
266
+ central_focus_size = Math.max( Math.floor( p.maxOptionSize / skip_set_size ) - 1, 5 );
267
+
268
+ start_page = current_page - central_focus_size;
269
+ if (start_page < 1) { start_page = 1; }
270
+ end_page = current_page + central_focus_size;
271
+ if (end_page > pg) { end_page = pg; }
272
+ // construct an array to get a focus set around the current page
273
+ for (i = start_page; i <= end_page ; i++) {
274
+ focus_option_pages[ focus_option_pages.length ] = i;
275
+ }
275
276
 
276
- // keep unique values
277
- option_pages = $.grep(option_pages, function(value, indx) {
278
- return $.inArray(value, option_pages) === indx;
279
- });
277
+ // keep unique values
278
+ option_pages = $.grep(option_pages, function(value, indx) {
279
+ return $.inArray(value, option_pages) === indx;
280
+ });
280
281
 
281
- option_length = option_pages.length;
282
- focus_length = focus_option_pages.length;
282
+ option_length = option_pages.length;
283
+ focus_length = focus_option_pages.length;
283
284
 
284
- // make sure at all option_pages aren't replaced
285
- if (option_length - focus_length > skip_set_size / 2 && option_length + focus_length > p.maxOptionSize ) {
286
- insert_index = Math.floor(option_length / 2) - Math.floor(focus_length / 2);
287
- Array.prototype.splice.apply(option_pages, [ insert_index, focus_length ]);
288
- }
289
- option_pages = option_pages.concat(focus_option_pages);
285
+ // make sure at all option_pages aren't replaced
286
+ if (option_length - focus_length > skip_set_size / 2 && option_length + focus_length > p.maxOptionSize ) {
287
+ insert_index = Math.floor(option_length / 2) - Math.floor(focus_length / 2);
288
+ Array.prototype.splice.apply(option_pages, [ insert_index, focus_length ]);
289
+ }
290
+ option_pages = option_pages.concat(focus_option_pages);
290
291
 
291
- }
292
+ }
292
293
 
293
- // keep unique values again
294
- option_pages = $.grep(option_pages, function(value, indx) {
295
- return $.inArray(value, option_pages) === indx;
296
- })
297
- .sort(function(a, b) { return a - b; });
294
+ // keep unique values again
295
+ option_pages = $.grep(option_pages, function(value, indx) {
296
+ return $.inArray(value, option_pages) === indx;
297
+ })
298
+ .sort(function(a, b) { return a - b; });
298
299
 
299
- return option_pages;
300
- },
300
+ return option_pages;
301
+ },
301
302
 
302
- fixHeight = function(table, p) {
303
- var d, h,
303
+ fixHeight = function(table, p) {
304
+ var d, h,
304
305
  c = table.config,
305
306
  $b = c.$tbodies.eq(0);
306
- $b.find('tr.pagerSavedHeightSpacer').remove();
307
- if (p.fixedHeight && !p.isDisabled) {
308
- h = $.data(table, 'pagerSavedHeight');
309
- if (h) {
310
- d = h - $b.height();
311
- if ( d > 5 && $.data(table, 'pagerLastSize') === p.size &&
307
+ $b.find('tr.pagerSavedHeightSpacer').remove();
308
+ if (p.fixedHeight && !p.isDisabled) {
309
+ h = $.data(table, 'pagerSavedHeight');
310
+ if (h) {
311
+ d = h - $b.height();
312
+ if ( d > 5 && $.data(table, 'pagerLastSize') === p.size &&
312
313
  $b.children('tr:visible').length < (p.size === 'all' ? p.totalRows : p.size) ) {
313
- $b.append('<tr class="pagerSavedHeightSpacer ' + c.selectorRemove.slice(1) + '" style="height:' + d + 'px;"></tr>');
314
+ $b.append('<tr class="pagerSavedHeightSpacer ' + c.selectorRemove.slice(1) + '" style="height:' + d + 'px;"></tr>');
315
+ }
314
316
  }
315
317
  }
316
- }
317
- },
318
+ },
318
319
 
319
- changeHeight = function(table, p) {
320
- var h,
320
+ changeHeight = function(table, p) {
321
+ var h,
321
322
  c = table.config,
322
323
  $b = c.$tbodies.eq(0);
323
- $b.find('tr.pagerSavedHeightSpacer').remove();
324
- if (!$b.children('tr:visible').length) {
325
- $b.append('<tr class="pagerSavedHeightSpacer ' + c.selectorRemove.slice(1) + '"><td>&nbsp</td></tr>');
326
- }
327
- h = $b.children('tr').eq(0).height() * (p.size === 'all' ? p.totalRows : p.size);
328
- $.data(table, 'pagerSavedHeight', h);
329
- fixHeight(table, p);
330
- $.data(table, 'pagerLastSize', p.size);
331
- },
332
-
333
- hideRows = function(table, p){
334
- if (!p.ajaxUrl) {
335
- var i,
336
- lastIndex = 0,
337
- c = table.config,
338
- rows = c.$tbodies.eq(0).children('tr'),
339
- l = rows.length,
340
- sz = p.size === 'all' ? p.totalRows : p.size,
341
- s = ( p.page * sz ),
342
- e = s + sz,
343
- f = c.widgetOptions && c.widgetOptions.filter_filteredRow || 'filtered',
344
- last = 0, // for cache indexing
345
- j = 0; // size counter
346
- p.cacheIndex = [];
347
- for ( i = 0; i < l; i++ ){
348
- if ( !rows[i].className.match(f) ) {
349
- if (j === s && rows[i].className.match(c.cssChildRow)) {
350
- // hide child rows @ start of pager (if already visible)
351
- rows[i].style.display = 'none';
352
- } else {
353
- rows[i].style.display = ( j >= s && j < e ) ? '' : 'none';
354
- if (last !== j && j >= s && j < e) {
355
- p.cacheIndex[ p.cacheIndex.length ] = i;
356
- last = j;
357
- }
358
- // don't count child rows
359
- j += rows[i].className.match(c.cssChildRow + '|' + c.selectorRemove.slice(1)) && !p.countChildRows ? 0 : 1;
360
- if ( j === e && rows[i].style.display !== 'none' && rows[i].className.match(ts.css.cssHasChild) ) {
361
- lastIndex = i;
324
+ $b.find('tr.pagerSavedHeightSpacer').remove();
325
+ if (!$b.children('tr:visible').length) {
326
+ $b.append('<tr class="pagerSavedHeightSpacer ' + c.selectorRemove.slice(1) + '"><td>&nbsp</td></tr>');
327
+ }
328
+ h = $b.children('tr').eq(0).height() * (p.size === 'all' ? p.totalRows : p.size);
329
+ $.data(table, 'pagerSavedHeight', h);
330
+ fixHeight(table, p);
331
+ $.data(table, 'pagerLastSize', p.size);
332
+ },
333
+
334
+ hideRows = function(table, p){
335
+ if (!p.ajaxUrl) {
336
+ var i,
337
+ lastIndex = 0,
338
+ c = table.config,
339
+ rows = c.$tbodies.eq(0).children('tr'),
340
+ l = rows.length,
341
+ sz = p.size === 'all' ? p.totalRows : p.size,
342
+ s = ( p.page * sz ),
343
+ e = s + sz,
344
+ f = c.widgetOptions && c.widgetOptions.filter_filteredRow || 'filtered',
345
+ last = 0, // for cache indexing
346
+ j = 0; // size counter
347
+ p.cacheIndex = [];
348
+ for ( i = 0; i < l; i++ ){
349
+ if ( !rows[i].className.match(f) ) {
350
+ if (j === s && rows[i].className.match(c.cssChildRow)) {
351
+ // hide child rows @ start of pager (if already visible)
352
+ rows[i].style.display = 'none';
353
+ } else {
354
+ rows[i].style.display = ( j >= s && j < e ) ? '' : 'none';
355
+ if (last !== j && j >= s && j < e) {
356
+ p.cacheIndex[ p.cacheIndex.length ] = i;
357
+ last = j;
358
+ }
359
+ // don't count child rows
360
+ j += rows[i].className.match(c.cssChildRow + '|' + c.selectorRemove.slice(1)) && !p.countChildRows ? 0 : 1;
361
+ if ( j === e && rows[i].style.display !== 'none' && rows[i].className.match(ts.css.cssHasChild) ) {
362
+ lastIndex = i;
363
+ }
362
364
  }
363
365
  }
364
366
  }
365
- }
366
- // add any attached child rows to last row of pager. Fixes part of issue #396
367
- if ( lastIndex > 0 && rows[lastIndex].className.match(ts.css.cssHasChild) ) {
368
- while ( ++lastIndex < l && rows[lastIndex].className.match(c.cssChildRow) ) {
369
- rows[lastIndex].style.display = '';
367
+ // add any attached child rows to last row of pager. Fixes part of issue #396
368
+ if ( lastIndex > 0 && rows[lastIndex].className.match(ts.css.cssHasChild) ) {
369
+ while ( ++lastIndex < l && rows[lastIndex].className.match(c.cssChildRow) ) {
370
+ rows[lastIndex].style.display = '';
371
+ }
370
372
  }
371
373
  }
372
- }
373
- },
374
-
375
- hideRowsSetup = function(table, p){
376
- p.size = parsePageSize( p, p.$size.val(), 'get' );
377
- p.$size.val( p.size );
378
- $.data(table, 'pagerLastSize', p.size);
379
- pagerArrows( table, p );
380
- if ( !p.removeRows ) {
381
- hideRows(table, p);
382
- $(table).bind('sortEnd filterEnd '.split(' ').join(table.config.namespace + 'pager '), function(){
374
+ },
375
+
376
+ hideRowsSetup = function(table, p){
377
+ p.size = parsePageSize( p, p.$size.val(), 'get' );
378
+ p.$size.val( p.size );
379
+ $.data(table, 'pagerLastSize', p.size);
380
+ pagerArrows( table, p );
381
+ if ( !p.removeRows ) {
383
382
  hideRows(table, p);
384
- });
385
- }
386
- },
383
+ $(table).bind('sortEnd filterEnd '.split(' ').join(table.config.namespace + 'pager '), function(){
384
+ hideRows(table, p);
385
+ });
386
+ }
387
+ },
387
388
 
388
- renderAjax = function(data, table, p, xhr, settings, exception){
389
- // process data
390
- if ( typeof p.ajaxProcessing === 'function' ) {
389
+ renderAjax = function(data, table, p, xhr, settings, exception){
390
+ // process data
391
+ if ( typeof p.ajaxProcessing === 'function' ) {
391
392
 
392
- // in case nothing is returned by ajax, empty out the table; see #1032
393
- // but do it before calling pager_ajaxProcessing because that function may add content
394
- // directly to the table
395
- table.config.$tbodies.eq(0).empty();
393
+ // in case nothing is returned by ajax, empty out the table; see #1032
394
+ // but do it before calling pager_ajaxProcessing because that function may add content
395
+ // directly to the table
396
+ table.config.$tbodies.eq(0).empty();
396
397
 
397
- // ajaxProcessing result: [ total, rows, headers ]
398
- var i, j, t, hsh, $f, $sh, $headers, $h, icon, th, d, l, rr_count, len, sz,
398
+ // ajaxProcessing result: [ total, rows, headers ]
399
+ var i, j, t, hsh, $f, $sh, $headers, $h, icon, th, d, l, rr_count, len, sz,
399
400
  c = table.config,
400
401
  $table = c.$table,
401
402
  tds = '',
402
403
  result = p.ajaxProcessing(data, table, xhr) || [ 0, [] ],
403
404
  hl = $table.find('thead th').length;
404
405
 
405
- // Clean up any previous error.
406
- ts.showError( table );
406
+ // Clean up any previous error.
407
+ ts.showError( table );
407
408
 
408
- if ( exception ) {
409
- if (c.debug) {
410
- console.error('Pager: >> Ajax Error', xhr, settings, exception);
411
- }
412
- ts.showError( table, xhr, settings, exception );
413
- c.$tbodies.eq(0).children('tr').detach();
414
- p.totalRows = 0;
415
- } else {
416
- // process ajax object
417
- if (!$.isArray(result)) {
418
- p.ajaxData = result;
419
- c.totalRows = p.totalRows = result.total;
420
- c.filteredRows = p.filteredRows = typeof result.filteredRows !== 'undefined' ? result.filteredRows : result.total;
421
- th = result.headers;
422
- d = result.rows || [];
409
+ if ( exception ) {
410
+ if (c.debug) {
411
+ console.error('Pager: >> Ajax Error', xhr, settings, exception);
412
+ }
413
+ ts.showError( table, xhr, settings, exception );
414
+ c.$tbodies.eq(0).children('tr').detach();
415
+ p.totalRows = 0;
423
416
  } else {
424
- // allow [ total, rows, headers ] or [ rows, total, headers ]
425
- t = isNaN(result[0]) && !isNaN(result[1]);
426
- // ensure a zero returned row count doesn't fail the logical ||
427
- rr_count = result[t ? 1 : 0];
428
- p.totalRows = isNaN(rr_count) ? p.totalRows || 0 : rr_count;
429
- // can't set filtered rows when returning an array
430
- c.totalRows = c.filteredRows = p.filteredRows = p.totalRows;
431
- // set row data to empty array if nothing found - see http://stackoverflow.com/q/30875583/145346
432
- d = p.totalRows === 0 ? [] : result[t ? 0 : 1] || []; // row data
433
- th = result[2]; // headers
434
- }
435
- l = d && d.length;
436
- if (d instanceof jQuery) {
437
- if (p.processAjaxOnInit) {
438
- // append jQuery object
439
- c.$tbodies.eq(0).empty();
440
- c.$tbodies.eq(0).append(d);
417
+ // process ajax object
418
+ if (!$.isArray(result)) {
419
+ p.ajaxData = result;
420
+ c.totalRows = p.totalRows = result.total;
421
+ c.filteredRows = p.filteredRows = typeof result.filteredRows !== 'undefined' ? result.filteredRows : result.total;
422
+ th = result.headers;
423
+ d = result.rows || [];
424
+ } else {
425
+ // allow [ total, rows, headers ] or [ rows, total, headers ]
426
+ t = isNaN(result[0]) && !isNaN(result[1]);
427
+ // ensure a zero returned row count doesn't fail the logical ||
428
+ rr_count = result[t ? 1 : 0];
429
+ p.totalRows = isNaN(rr_count) ? p.totalRows || 0 : rr_count;
430
+ // can't set filtered rows when returning an array
431
+ c.totalRows = c.filteredRows = p.filteredRows = p.totalRows;
432
+ // set row data to empty array if nothing found - see http://stackoverflow.com/q/30875583/145346
433
+ d = p.totalRows === 0 ? [] : result[t ? 0 : 1] || []; // row data
434
+ th = result[2]; // headers
441
435
  }
442
- } else if (l) {
443
- // build table from array
444
- for ( i = 0; i < l; i++ ) {
445
- tds += '<tr>';
446
- for ( j = 0; j < d[i].length; j++ ) {
447
- // build tbody cells; watch for data containing HTML markup - see #434
448
- tds += /^\s*<td/.test(d[i][j]) ? $.trim(d[i][j]) : '<td>' + d[i][j] + '</td>';
436
+ l = d && d.length;
437
+ if (d instanceof jQuery) {
438
+ if (p.processAjaxOnInit) {
439
+ // append jQuery object
440
+ c.$tbodies.eq(0).empty();
441
+ c.$tbodies.eq(0).append(d);
449
442
  }
450
- tds += '</tr>';
451
- }
452
- // add rows to first tbody
453
- if (p.processAjaxOnInit) {
454
- c.$tbodies.eq(0).html( tds );
455
- }
456
- }
457
- p.processAjaxOnInit = true;
458
- // only add new header text if the length matches
459
- if ( th && th.length === hl ) {
460
- hsh = $table.hasClass('hasStickyHeaders');
461
- $sh = hsh ? c.widgetOptions.$sticky.children('thead:first').children('tr').children() : '';
462
- $f = $table.find('tfoot tr:first').children();
463
- // don't change td headers (may contain pager)
464
- $headers = c.$headers.filter( 'th ' );
465
- len = $headers.length;
466
- for ( j = 0; j < len; j++ ) {
467
- $h = $headers.eq( j );
468
- // add new test within the first span it finds, or just in the header
469
- if ( $h.find('.' + ts.css.icon).length ) {
470
- icon = $h.find('.' + ts.css.icon).clone(true);
471
- $h.find('.tablesorter-header-inner').html( th[j] ).append(icon);
472
- if ( hsh && $sh.length ) {
473
- icon = $sh.eq(j).find('.' + ts.css.icon).clone(true);
474
- $sh.eq(j).find('.tablesorter-header-inner').html( th[j] ).append(icon);
443
+ } else if (l) {
444
+ // build table from array
445
+ for ( i = 0; i < l; i++ ) {
446
+ tds += '<tr>';
447
+ for ( j = 0; j < d[i].length; j++ ) {
448
+ // build tbody cells; watch for data containing HTML markup - see #434
449
+ tds += /^\s*<td/.test(d[i][j]) ? $.trim(d[i][j]) : '<td>' + d[i][j] + '</td>';
475
450
  }
476
- } else {
477
- $h.find('.tablesorter-header-inner').html( th[j] );
478
- if (hsh && $sh.length) {
479
- $sh.eq(j).find('.tablesorter-header-inner').html( th[j] );
451
+ tds += '</tr>';
452
+ }
453
+ // add rows to first tbody
454
+ if (p.processAjaxOnInit) {
455
+ c.$tbodies.eq(0).html( tds );
456
+ }
457
+ }
458
+ p.processAjaxOnInit = true;
459
+ // only add new header text if the length matches
460
+ if ( th && th.length === hl ) {
461
+ hsh = $table.hasClass('hasStickyHeaders');
462
+ $sh = hsh ? c.widgetOptions.$sticky.children('thead:first').children('tr').children() : '';
463
+ $f = $table.find('tfoot tr:first').children();
464
+ // don't change td headers (may contain pager)
465
+ $headers = c.$headers.filter( 'th ' );
466
+ len = $headers.length;
467
+ for ( j = 0; j < len; j++ ) {
468
+ $h = $headers.eq( j );
469
+ // add new test within the first span it finds, or just in the header
470
+ if ( $h.find('.' + ts.css.icon).length ) {
471
+ icon = $h.find('.' + ts.css.icon).clone(true);
472
+ $h.find('.tablesorter-header-inner').html( th[j] ).append(icon);
473
+ if ( hsh && $sh.length ) {
474
+ icon = $sh.eq(j).find('.' + ts.css.icon).clone(true);
475
+ $sh.eq(j).find('.tablesorter-header-inner').html( th[j] ).append(icon);
476
+ }
477
+ } else {
478
+ $h.find('.tablesorter-header-inner').html( th[j] );
479
+ if (hsh && $sh.length) {
480
+ $sh.eq(j).find('.tablesorter-header-inner').html( th[j] );
481
+ }
480
482
  }
483
+ $f.eq(j).html( th[j] );
481
484
  }
482
- $f.eq(j).html( th[j] );
483
485
  }
484
486
  }
485
- }
486
- if (c.showProcessing) {
487
- ts.isProcessing(table); // remove loading icon
488
- }
489
- sz = parsePageSize( p, p.size, 'get' );
490
- // make sure last pager settings are saved, prevents multiple server side calls with
491
- // the same parameters
492
- p.totalPages = sz === 'all' ? 1 : Math.ceil( p.totalRows / sz );
493
- p.last.totalRows = p.totalRows;
494
- p.last.currentFilters = p.currentFilters;
495
- p.last.sortList = (c.sortList || []).join(',');
496
- updatePageDisplay(table, p, false);
497
- // tablesorter core updateCache (not pager)
498
- ts.updateCache( c, function(){
499
- if (p.initialized) {
500
- // apply widgets after table has rendered & after a delay to prevent
501
- // multiple applyWidget blocking code from blocking this trigger
502
- setTimeout(function(){
503
- if (c.debug) {
504
- console.log('Pager: Triggering pagerChange');
505
- }
506
- $table.triggerHandler( 'pagerChange', p );
507
- ts.applyWidget( table );
508
- updatePageDisplay(table, p, true);
509
- }, 0);
487
+ if (c.showProcessing) {
488
+ ts.isProcessing(table); // remove loading icon
510
489
  }
511
- });
490
+ sz = parsePageSize( p, p.size, 'get' );
491
+ // make sure last pager settings are saved, prevents multiple server side calls with
492
+ // the same parameters
493
+ p.totalPages = sz === 'all' ? 1 : Math.ceil( p.totalRows / sz );
494
+ p.last.totalRows = p.totalRows;
495
+ p.last.currentFilters = p.currentFilters;
496
+ p.last.sortList = (c.sortList || []).join(',');
497
+ updatePageDisplay(table, p, false);
498
+ // tablesorter core updateCache (not pager)
499
+ ts.updateCache( c, function(){
500
+ if (p.initialized) {
501
+ // apply widgets after table has rendered & after a delay to prevent
502
+ // multiple applyWidget blocking code from blocking this trigger
503
+ setTimeout(function(){
504
+ if (c.debug) {
505
+ console.log('Pager: Triggering pagerChange');
506
+ }
507
+ $table.triggerHandler( 'pagerChange', p );
508
+ ts.applyWidget( table );
509
+ updatePageDisplay(table, p, true);
510
+ }, 0);
511
+ }
512
+ });
512
513
 
513
- }
514
- if (!p.initialized) {
515
- pagerInitialized(table, p);
516
- }
517
- },
514
+ }
515
+ if (!p.initialized) {
516
+ pagerInitialized(table, p);
517
+ }
518
+ },
518
519
 
519
- getAjax = function(table, p) {
520
- var url = getAjaxUrl(table, p),
520
+ getAjax = function(table, p) {
521
+ var url = getAjaxUrl(table, p),
521
522
  $doc = $(document),
522
523
  counter,
523
524
  c = table.config,
524
525
  namespace = c.namespace + 'pager';
525
- if ( url !== '' ) {
526
- if (c.showProcessing) {
527
- ts.isProcessing(table, true); // show loading icon
528
- }
529
- $doc.bind('ajaxError' + namespace, function(e, xhr, settings, exception) {
530
- renderAjax(null, table, p, xhr, settings, exception);
531
- $doc.unbind('ajaxError' + namespace);
532
- });
526
+ if ( url !== '' ) {
527
+ if (c.showProcessing) {
528
+ ts.isProcessing(table, true); // show loading icon
529
+ }
530
+ $doc.bind('ajaxError' + namespace, function(e, xhr, settings, exception) {
531
+ renderAjax(null, table, p, xhr, settings, exception);
532
+ $doc.unbind('ajaxError' + namespace);
533
+ });
533
534
 
534
- counter = ++p.ajaxCounter;
535
+ counter = ++p.ajaxCounter;
535
536
 
536
- p.last.ajaxUrl = url; // remember processed url
537
- p.ajaxObject.url = url; // from the ajaxUrl option and modified by customAjaxUrl
538
- p.ajaxObject.success = function(data, status, jqxhr) {
539
- // Refuse to process old ajax commands that were overwritten by new ones - see #443
540
- if (counter < p.ajaxCounter){
541
- return;
542
- }
543
- renderAjax(data, table, p, jqxhr);
544
- $doc.unbind('ajaxError' + namespace);
545
- if (typeof p.oldAjaxSuccess === 'function') {
546
- p.oldAjaxSuccess(data);
537
+ p.last.ajaxUrl = url; // remember processed url
538
+ p.ajaxObject.url = url; // from the ajaxUrl option and modified by customAjaxUrl
539
+ p.ajaxObject.success = function(data, status, jqxhr) {
540
+ // Refuse to process old ajax commands that were overwritten by new ones - see #443
541
+ if (counter < p.ajaxCounter){
542
+ return;
543
+ }
544
+ renderAjax(data, table, p, jqxhr);
545
+ $doc.unbind('ajaxError' + namespace);
546
+ if (typeof p.oldAjaxSuccess === 'function') {
547
+ p.oldAjaxSuccess(data);
548
+ }
549
+ };
550
+ if (c.debug) {
551
+ console.log('Pager: Ajax initialized', p.ajaxObject);
547
552
  }
548
- };
549
- if (c.debug) {
550
- console.log('Pager: Ajax initialized', p.ajaxObject);
553
+ $.ajax(p.ajaxObject);
551
554
  }
552
- $.ajax(p.ajaxObject);
553
- }
554
- },
555
+ },
555
556
 
556
- getAjaxUrl = function(table, p) {
557
- var indx, len,
557
+ getAjaxUrl = function(table, p) {
558
+ var indx, len,
558
559
  c = table.config,
559
560
  url = (p.ajaxUrl) ? p.ajaxUrl
560
561
  // allow using "{page+1}" in the url string to switch to a non-zero based index
561
562
  .replace(/\{page([\-+]\d+)?\}/, function(s, n){ return p.page + (n ? parseInt(n, 10) : 0); })
562
563
  // this will pass "all" to server when size is set to "all"
563
564
  .replace(/\{size\}/g, p.size) : '',
564
- sortList = c.sortList,
565
- filterList = p.currentFilters || $(table).data('lastSearch') || [],
566
- sortCol = url.match(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/),
567
- filterCol = url.match(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/),
568
- arry = [];
569
- if (sortCol) {
570
- sortCol = sortCol[1];
571
- len = sortList.length;
572
- for (indx = 0; indx < len; indx++) {
573
- arry[ arry.length ] = sortCol + '[' + sortList[indx][0] + ']=' + sortList[indx][1];
574
- }
575
- // if the arry is empty, just add the col parameter... "&{sortList:col}" becomes "&col"
576
- url = url.replace(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/g, arry.length ? arry.join('&') : sortCol );
565
+ sortList = c.sortList,
566
+ filterList = p.currentFilters || $(table).data('lastSearch') || [],
567
+ sortCol = url.match(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/),
568
+ filterCol = url.match(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/),
577
569
  arry = [];
578
- }
579
- if (filterCol) {
580
- filterCol = filterCol[1];
581
- len = filterList.length;
582
- for (indx = 0; indx < len; indx++) {
583
- if (filterList[indx]) {
584
- arry[ arry.length ] = filterCol + '[' + indx + ']=' + encodeURIComponent( filterList[indx] );
570
+ if (sortCol) {
571
+ sortCol = sortCol[1];
572
+ len = sortList.length;
573
+ for (indx = 0; indx < len; indx++) {
574
+ arry[ arry.length ] = sortCol + '[' + sortList[indx][0] + ']=' + sortList[indx][1];
585
575
  }
576
+ // if the arry is empty, just add the col parameter... "&{sortList:col}" becomes "&col"
577
+ url = url.replace(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/g, arry.length ? arry.join('&') : sortCol );
578
+ arry = [];
586
579
  }
587
- // if the arry is empty, just add the fcol parameter... "&{filterList:fcol}" becomes "&fcol"
588
- url = url.replace(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/g, arry.length ? arry.join('&') : filterCol );
589
- p.currentFilters = filterList;
590
- }
591
- if ( typeof p.customAjaxUrl === 'function' ) {
592
- url = p.customAjaxUrl(table, url);
593
- }
594
- if (c.debug) {
595
- console.log('Pager: Ajax url = ' + url);
596
- }
597
- return url;
598
- },
580
+ if (filterCol) {
581
+ filterCol = filterCol[1];
582
+ len = filterList.length;
583
+ for (indx = 0; indx < len; indx++) {
584
+ if (filterList[indx]) {
585
+ arry[ arry.length ] = filterCol + '[' + indx + ']=' + encodeURIComponent( filterList[indx] );
586
+ }
587
+ }
588
+ // if the arry is empty, just add the fcol parameter... "&{filterList:fcol}" becomes "&fcol"
589
+ url = url.replace(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/g, arry.length ? arry.join('&') : filterCol );
590
+ p.currentFilters = filterList;
591
+ }
592
+ if ( typeof p.customAjaxUrl === 'function' ) {
593
+ url = p.customAjaxUrl(table, url);
594
+ }
595
+ if (c.debug) {
596
+ console.log('Pager: Ajax url = ' + url);
597
+ }
598
+ return url;
599
+ },
599
600
 
600
- renderTable = function(table, rows, p) {
601
- var $tb, index, count, added,
601
+ renderTable = function(table, rows, p) {
602
+ var $tb, index, count, added,
602
603
  $t = $(table),
603
604
  c = table.config,
604
605
  f = c.$table.hasClass('hasFilters'),
605
606
  l = rows && rows.length || 0, // rows may be undefined
606
607
  e = p.size === 'all' ? p.totalRows : p.size,
607
608
  s = ( p.page * e );
608
- if ( l < 1 ) {
609
- if (c.debug) {
610
- console.warn('Pager: >> No rows for pager to render');
609
+ if ( l < 1 ) {
610
+ if (c.debug) {
611
+ console.warn('Pager: >> No rows for pager to render');
612
+ }
613
+ // empty table, abort!
614
+ return;
611
615
  }
612
- // empty table, abort!
613
- return;
614
- }
615
- if ( p.page >= p.totalPages ) {
616
- // lets not render the table more than once
617
- moveToLastPage(table, p);
618
- }
619
- p.cacheIndex = [];
620
- p.isDisabled = false; // needed because sorting will change the page and re-enable the pager
621
- if (p.initialized) {
622
- if (c.debug) {
623
- console.log('Pager: Triggering pagerChange');
616
+ if ( p.page >= p.totalPages ) {
617
+ // lets not render the table more than once
618
+ moveToLastPage(table, p);
624
619
  }
625
- $t.triggerHandler( 'pagerChange', p );
626
- }
627
- if ( !p.removeRows ) {
628
- hideRows(table, p);
629
- } else {
630
- ts.clearTableBody(table);
631
- $tb = ts.processTbody(table, c.$tbodies.eq(0), true);
632
- // not filtered, start from the calculated starting point (s)
633
- // if filtered, start from zero
634
- index = f ? 0 : s;
635
- count = f ? 0 : s;
636
- added = 0;
637
- while (added < e && index < rows.length) {
638
- if (!f || !/filtered/.test(rows[index][0].className)){
639
- count++;
640
- if (count > s && added <= e) {
641
- added++;
642
- p.cacheIndex[ p.cacheIndex.length ] = index;
643
- $tb.append(rows[index]);
620
+ p.cacheIndex = [];
621
+ p.isDisabled = false; // needed because sorting will change the page and re-enable the pager
622
+ if (p.initialized) {
623
+ if (c.debug) {
624
+ console.log('Pager: Triggering pagerChange');
625
+ }
626
+ $t.triggerHandler( 'pagerChange', p );
627
+ }
628
+ if ( !p.removeRows ) {
629
+ hideRows(table, p);
630
+ } else {
631
+ ts.clearTableBody(table);
632
+ $tb = ts.processTbody(table, c.$tbodies.eq(0), true);
633
+ // not filtered, start from the calculated starting point (s)
634
+ // if filtered, start from zero
635
+ index = f ? 0 : s;
636
+ count = f ? 0 : s;
637
+ added = 0;
638
+ while (added < e && index < rows.length) {
639
+ if (!f || !/filtered/.test(rows[index][0].className)){
640
+ count++;
641
+ if (count > s && added <= e) {
642
+ added++;
643
+ p.cacheIndex[ p.cacheIndex.length ] = index;
644
+ $tb.append(rows[index]);
645
+ }
644
646
  }
647
+ index++;
645
648
  }
646
- index++;
649
+ ts.processTbody(table, $tb, false);
647
650
  }
648
- ts.processTbody(table, $tb, false);
649
- }
650
- updatePageDisplay(table, p);
651
- if (table.isUpdating) {
652
- if (c.debug) {
653
- console.log('Pager: Triggering updateComplete');
651
+ updatePageDisplay(table, p);
652
+ if (table.isUpdating) {
653
+ if (c.debug) {
654
+ console.log('Pager: Triggering updateComplete');
655
+ }
656
+ $t.triggerHandler('updateComplete', [ table, true ]);
654
657
  }
655
- $t.triggerHandler('updateComplete', [ table, true ]);
656
- }
657
- },
658
+ },
658
659
 
659
- showAllRows = function(table, p) {
660
- var index, $controls, len;
661
- if ( p.ajax ) {
662
- pagerArrows( table, p, true );
663
- } else {
664
- $.data(table, 'pagerLastPage', p.page);
665
- $.data(table, 'pagerLastSize', p.size);
666
- p.page = 0;
667
- p.size = 'all';
668
- p.totalPages = 1;
669
- $(table)
660
+ showAllRows = function(table, p) {
661
+ var index, $controls, len;
662
+ if ( p.ajax ) {
663
+ pagerArrows( table, p, true );
664
+ } else {
665
+ $.data(table, 'pagerLastPage', p.page);
666
+ $.data(table, 'pagerLastSize', p.size);
667
+ p.page = 0;
668
+ p.size = 'all';
669
+ p.totalPages = 1;
670
+ $(table)
670
671
  .addClass('pagerDisabled')
671
672
  .removeAttr('aria-describedby')
672
673
  .find('tr.pagerSavedHeightSpacer').remove();
673
- renderTable(table, table.config.rowsCopy, p);
674
- p.isDisabled = true;
675
- ts.applyWidget( table );
676
- if (table.config.debug) {
677
- console.log('Pager: Disabled');
674
+ renderTable(table, table.config.rowsCopy, p);
675
+ p.isDisabled = true;
676
+ ts.applyWidget( table );
677
+ if (table.config.debug) {
678
+ console.log('Pager: Disabled');
679
+ }
678
680
  }
679
- }
680
- // disable size selector
681
- $controls = p.$size
681
+ // disable size selector
682
+ $controls = p.$size
682
683
  .add( p.$goto )
683
684
  .add( p.$container.find( '.ts-startRow, .ts-page' ) );
684
- len = $controls.length;
685
- for ( index = 0; index < len; index++ ) {
686
- $controls.eq( index )
685
+ len = $controls.length;
686
+ for ( index = 0; index < len; index++ ) {
687
+ $controls.eq( index )
687
688
  .attr( 'aria-disabled', 'true' )
688
689
  .addClass( p.cssDisabled )[0].disabled = true;
689
- }
690
- },
690
+ }
691
+ },
691
692
 
692
- // updateCache if delayInit: true
693
- updateCache = function(table) {
694
- var c = table.config,
693
+ // updateCache if delayInit: true
694
+ updateCache = function(table) {
695
+ var c = table.config,
695
696
  p = c.pager;
696
- // tablesorter core updateCache (not pager)
697
- ts.updateCache( c, function(){
698
- var i,
697
+ // tablesorter core updateCache (not pager)
698
+ ts.updateCache( c, function(){
699
+ var i,
699
700
  rows = [],
700
701
  n = table.config.cache[0].normalized;
701
- p.totalRows = n.length;
702
- for (i = 0; i < p.totalRows; i++) {
703
- rows[ rows.length ] = n[i][c.columns].$row;
704
- }
705
- c.rowsCopy = rows;
706
- moveToPage(table, p, true);
707
- });
708
- },
709
-
710
- moveToPage = function(table, p, pageMoved) {
711
- if ( p.isDisabled ) { return; }
712
- var tmp,
702
+ p.totalRows = n.length;
703
+ for (i = 0; i < p.totalRows; i++) {
704
+ rows[ rows.length ] = n[i][c.columns].$row;
705
+ }
706
+ c.rowsCopy = rows;
707
+ moveToPage(table, p, true);
708
+ });
709
+ },
710
+
711
+ moveToPage = function(table, p, pageMoved) {
712
+ if ( p.isDisabled ) { return; }
713
+ var tmp,
713
714
  c = table.config,
714
715
  $t = $(table),
715
716
  l = p.last;
716
- if ( pageMoved !== false && p.initialized && ts.isEmptyObject(c.cache)) {
717
- return updateCache(table);
718
- }
719
- // abort page move if the table has filters and has not been initialized
720
- if (p.ajax && ts.hasWidget(table, 'filter') && !c.widgetOptions.filter_initialized) { return; }
721
- parsePageNumber( table, p );
722
- calcFilters(table, p);
723
- // fixes issue where one currentFilter is [] and the other is ['','',''],
724
- // making the next if comparison think the filters are different (joined by commas). Fixes #202.
725
- l.currentFilters = (l.currentFilters || []).join('') === '' ? [] : l.currentFilters;
726
- p.currentFilters = (p.currentFilters || []).join('') === '' ? [] : p.currentFilters;
727
- // don't allow rendering multiple times on the same page/size/totalRows/filters/sorts
728
- if ( l.page === p.page && l.size === p.size && l.totalRows === p.totalRows &&
717
+ if ( pageMoved !== false && p.initialized && ts.isEmptyObject(c.cache)) {
718
+ return updateCache(table);
719
+ }
720
+ // abort page move if the table has filters and has not been initialized
721
+ if (p.ajax && ts.hasWidget(table, 'filter') && !c.widgetOptions.filter_initialized) { return; }
722
+ parsePageNumber( table, p );
723
+ calcFilters(table, p);
724
+ // fixes issue where one currentFilter is [] and the other is ['','',''],
725
+ // making the next if comparison think the filters are different (joined by commas). Fixes #202.
726
+ l.currentFilters = (l.currentFilters || []).join('') === '' ? [] : l.currentFilters;
727
+ p.currentFilters = (p.currentFilters || []).join('') === '' ? [] : p.currentFilters;
728
+ // don't allow rendering multiple times on the same page/size/totalRows/filters/sorts
729
+ if ( l.page === p.page && l.size === p.size && l.totalRows === p.totalRows &&
729
730
  (l.currentFilters || []).join(',') === (p.currentFilters || []).join(',') &&
730
731
  // check for ajax url changes see #730
731
732
  (l.ajaxUrl || '') === (p.ajaxObject.url || '') &&
732
733
  // & ajax url option changes (dynamically add/remove/rename sort & filter parameters)
733
734
  (l.optAjaxUrl || '') === (p.ajaxUrl || '') &&
734
735
  l.sortList === (c.sortList || []).join(',') ) { return; }
735
- if (c.debug) {
736
- console.log('Pager: Changing to page ' + p.page);
737
- }
738
- p.last = {
739
- page : p.page,
740
- size : p.size,
741
- // fixes #408; modify sortList otherwise it auto-updates
742
- sortList : (c.sortList || []).join(','),
743
- totalRows : p.totalRows,
744
- currentFilters : p.currentFilters || [],
745
- ajaxUrl : p.ajaxObject.url || '',
746
- optAjaxUrl : p.ajaxUrl || ''
747
- };
748
- if (p.ajax) {
749
- if ( !p.processAjaxOnInit && !ts.isEmptyObject(p.initialRows) ) {
750
- p.processAjaxOnInit = true;
751
- tmp = p.initialRows;
752
- p.totalRows = typeof tmp.total !== 'undefined' ? tmp.total :
736
+ if (c.debug) {
737
+ console.log('Pager: Changing to page ' + p.page);
738
+ }
739
+ p.last = {
740
+ page : p.page,
741
+ size : p.size,
742
+ // fixes #408; modify sortList otherwise it auto-updates
743
+ sortList : (c.sortList || []).join(','),
744
+ totalRows : p.totalRows,
745
+ currentFilters : p.currentFilters || [],
746
+ ajaxUrl : p.ajaxObject.url || '',
747
+ optAjaxUrl : p.ajaxUrl || ''
748
+ };
749
+ if (p.ajax) {
750
+ if ( !p.processAjaxOnInit && !ts.isEmptyObject(p.initialRows) ) {
751
+ p.processAjaxOnInit = true;
752
+ tmp = p.initialRows;
753
+ p.totalRows = typeof tmp.total !== 'undefined' ? tmp.total :
753
754
  ( c.debug ? console.error('Pager: no initial total page set!') || 0 : 0 );
754
- p.filteredRows = typeof tmp.filtered !== 'undefined' ? tmp.filtered :
755
+ p.filteredRows = typeof tmp.filtered !== 'undefined' ? tmp.filtered :
755
756
  ( c.debug ? console.error('Pager: no initial filtered page set!') || 0 : 0 );
756
- pagerInitialized( table, p );
757
- } else {
758
- getAjax(table, p);
759
- }
760
- } else if (!p.ajax) {
761
- renderTable(table, c.rowsCopy, p);
762
- }
763
- $.data(table, 'pagerLastPage', p.page);
764
- if (p.initialized && pageMoved !== false) {
765
- if (c.debug) {
766
- console.log('Pager: Triggering pageMoved');
757
+ pagerInitialized( table, p );
758
+ } else {
759
+ getAjax(table, p);
760
+ }
761
+ } else if (!p.ajax) {
762
+ renderTable(table, c.rowsCopy, p);
767
763
  }
768
- $t.triggerHandler('pageMoved', p);
769
- ts.applyWidget( table );
770
- if (table.isUpdating) {
764
+ $.data(table, 'pagerLastPage', p.page);
765
+ if (p.initialized && pageMoved !== false) {
771
766
  if (c.debug) {
772
- console.log('Pager: Triggering updateComplete');
767
+ console.log('Pager: Triggering pageMoved');
768
+ }
769
+ $t.triggerHandler('pageMoved', p);
770
+ ts.applyWidget( table );
771
+ if (table.isUpdating) {
772
+ if (c.debug) {
773
+ console.log('Pager: Triggering updateComplete');
774
+ }
775
+ $t.triggerHandler('updateComplete', [ table, true ]);
773
776
  }
774
- $t.triggerHandler('updateComplete', [ table, true ]);
775
777
  }
776
- }
777
- },
778
+ },
778
779
 
779
- getTotalPages = function( table, p ) {
780
- return ts.hasWidget( table, 'filter' ) ? Math.min( p.totalPages, p.filteredPages ) : p.totalPages;
781
- },
780
+ getTotalPages = function( table, p ) {
781
+ return ts.hasWidget( table, 'filter' ) ? Math.min( p.totalPages, p.filteredPages ) : p.totalPages;
782
+ },
782
783
 
783
- // set to either set or get value
784
- parsePageSize = function( p, size, mode ) {
785
- var s = parseInt( size, 10 ) || p.size || p.settings.size || 10;
786
- return /all/i.test( size ) || s === p.totalRows ?
784
+ // set to either set or get value
785
+ parsePageSize = function( p, size, mode ) {
786
+ var s = parseInt( size, 10 ) || p.size || p.settings.size || 10;
787
+ return /all/i.test( size ) || s === p.totalRows ?
787
788
  // "get" to get `p.size` or "set" to set `p.$size.val()`
788
789
  'all' : ( mode === 'get' ? s : p.size );
789
- },
790
-
791
- parsePageNumber = function( table, p ) {
792
- var min = getTotalPages( table, p ) - 1;
793
- p.page = parseInt( p.page, 10 );
794
- if ( p.page < 0 || isNaN( p.page ) ) { p.page = 0; }
795
- if ( p.page > min && min >= 0 ) { p.page = min; }
796
- return p.page;
797
- },
798
-
799
- setPageSize = function(table, size, p) {
800
- p.size = parsePageSize( p, size, 'get' );
801
- p.$size.val( parsePageSize( p, p.size, 'set' ) );
802
- $.data(table, 'pagerLastPage', parsePageNumber( table, p ) );
803
- $.data(table, 'pagerLastSize', p.size);
804
- p.totalPages = p.size === 'all' ? 1 : Math.ceil( p.totalRows / p.size );
805
- p.filteredPages = p.size === 'all' ? 1 : Math.ceil( p.filteredRows / p.size );
806
- moveToPage(table, p);
807
- },
808
-
809
- moveToFirstPage = function(table, p) {
810
- p.page = 0;
811
- moveToPage(table, p);
812
- },
813
-
814
- moveToLastPage = function(table, p) {
815
- p.page = getTotalPages( table, p ) - 1;
816
- moveToPage(table, p);
817
- },
818
-
819
- moveToNextPage = function(table, p) {
820
- p.page++;
821
- var last = getTotalPages( table, p ) - 1;
822
- if ( p.page >= last ) {
823
- p.page = last;
824
- }
825
- moveToPage(table, p);
826
- },
790
+ },
791
+
792
+ parsePageNumber = function( table, p ) {
793
+ var min = getTotalPages( table, p ) - 1;
794
+ p.page = parseInt( p.page, 10 );
795
+ if ( p.page < 0 || isNaN( p.page ) ) { p.page = 0; }
796
+ if ( p.page > min && min >= 0 ) { p.page = min; }
797
+ return p.page;
798
+ },
799
+
800
+ setPageSize = function(table, size, p) {
801
+ p.size = parsePageSize( p, size, 'get' );
802
+ p.$size.val( parsePageSize( p, p.size, 'set' ) );
803
+ $.data(table, 'pagerLastPage', parsePageNumber( table, p ) );
804
+ $.data(table, 'pagerLastSize', p.size);
805
+ p.totalPages = p.size === 'all' ? 1 : Math.ceil( p.totalRows / p.size );
806
+ p.filteredPages = p.size === 'all' ? 1 : Math.ceil( p.filteredRows / p.size );
807
+ moveToPage(table, p);
808
+ },
827
809
 
828
- moveToPrevPage = function(table, p) {
829
- p.page--;
830
- if ( p.page <= 0 ) {
810
+ moveToFirstPage = function(table, p) {
831
811
  p.page = 0;
832
- }
833
- moveToPage(table, p);
834
- },
835
-
836
- pagerInitialized = function(table, p) {
837
- p.initialized = true;
838
- p.initializing = false;
839
- if (table.config.debug) {
840
- console.log('Pager: Triggering pagerInitialized');
841
- }
842
- $(table).triggerHandler( 'pagerInitialized', p );
843
- ts.applyWidget( table );
844
- updatePageDisplay(table, p);
845
- },
812
+ moveToPage(table, p);
813
+ },
814
+
815
+ moveToLastPage = function(table, p) {
816
+ p.page = getTotalPages( table, p ) - 1;
817
+ moveToPage(table, p);
818
+ },
846
819
 
847
- destroyPager = function(table, p) {
848
- var c = table.config,
820
+ moveToNextPage = function(table, p) {
821
+ p.page++;
822
+ var last = getTotalPages( table, p ) - 1;
823
+ if ( p.page >= last ) {
824
+ p.page = last;
825
+ }
826
+ moveToPage(table, p);
827
+ },
828
+
829
+ moveToPrevPage = function(table, p) {
830
+ p.page--;
831
+ if ( p.page <= 0 ) {
832
+ p.page = 0;
833
+ }
834
+ moveToPage(table, p);
835
+ },
836
+
837
+ pagerInitialized = function(table, p) {
838
+ p.initialized = true;
839
+ p.initializing = false;
840
+ if (table.config.debug) {
841
+ console.log('Pager: Triggering pagerInitialized');
842
+ }
843
+ $(table).triggerHandler( 'pagerInitialized', p );
844
+ ts.applyWidget( table );
845
+ updatePageDisplay(table, p);
846
+ },
847
+
848
+ destroyPager = function(table, p) {
849
+ var c = table.config,
849
850
  namespace = c.namespace + 'pager',
850
851
  ctrls = [ p.cssFirst, p.cssPrev, p.cssNext, p.cssLast, p.cssGoto, p.cssPageSize ].join( ',' );
851
- showAllRows(table, p);
852
- p.$container
852
+ showAllRows(table, p);
853
+ p.$container
853
854
  // hide pager controls
854
855
  .hide()
855
856
  // unbind
856
857
  .find( ctrls )
857
858
  .unbind( namespace );
858
- c.appender = null; // remove pager appender function
859
- c.$table.unbind( namespace );
860
- if (ts.storage) {
861
- ts.storage(table, p.storageKey, '');
862
- }
863
- delete c.pager;
864
- delete c.rowsCopy;
865
- },
859
+ c.appender = null; // remove pager appender function
860
+ c.$table.unbind( namespace );
861
+ if (ts.storage) {
862
+ ts.storage(table, p.storageKey, '');
863
+ }
864
+ delete c.pager;
865
+ delete c.rowsCopy;
866
+ },
866
867
 
867
- enablePager = function(table, p, triggered) {
868
- var info, size,
868
+ enablePager = function(table, p, triggered) {
869
+ var info, size,
869
870
  c = table.config;
870
- p.$size.add(p.$goto).add(p.$container.find('.ts-startRow, .ts-page'))
871
+ p.$size.add(p.$goto).add(p.$container.find('.ts-startRow, .ts-page'))
871
872
  .removeClass(p.cssDisabled)
872
873
  .removeAttr('disabled')
873
874
  .attr('aria-disabled', 'false');
874
- p.isDisabled = false;
875
- p.page = $.data(table, 'pagerLastPage') || p.page || 0;
876
- size = p.$size.find('option[selected]').val();
877
- p.size = $.data(table, 'pagerLastSize') || parsePageSize( p, size, 'get' );
878
- p.$size.val( p.size ); // set page size
879
- p.totalPages = p.size === 'all' ? 1 : Math.ceil( getTotalPages( table, p ) / p.size );
880
- // if table id exists, include page display with aria info
881
- if ( table.id ) {
882
- info = table.id + '_pager_info';
883
- p.$container.find(p.cssPageDisplay).attr('id', info);
884
- c.$table.attr('aria-describedby', info);
885
- }
886
- changeHeight(table, p);
887
- if ( triggered ) {
888
- // tablesorter core update table
889
- ts.update( c );
890
- setPageSize(table, p.size, p);
891
- hideRowsSetup(table, p);
892
- if (c.debug) {
893
- console.log('Pager: Enabled');
875
+ p.isDisabled = false;
876
+ p.page = $.data(table, 'pagerLastPage') || p.page || 0;
877
+ size = p.$size.find('option[selected]').val();
878
+ p.size = $.data(table, 'pagerLastSize') || parsePageSize( p, size, 'get' );
879
+ p.$size.val( p.size ); // set page size
880
+ p.totalPages = p.size === 'all' ? 1 : Math.ceil( getTotalPages( table, p ) / p.size );
881
+ // if table id exists, include page display with aria info
882
+ if ( table.id ) {
883
+ info = table.id + '_pager_info';
884
+ p.$container.find(p.cssPageDisplay).attr('id', info);
885
+ c.$table.attr('aria-describedby', info);
894
886
  }
895
- }
896
- };
887
+ changeHeight(table, p);
888
+ if ( triggered ) {
889
+ // tablesorter core update table
890
+ ts.update( c );
891
+ setPageSize(table, p.size, p);
892
+ hideRowsSetup(table, p);
893
+ if (c.debug) {
894
+ console.log('Pager: Enabled');
895
+ }
896
+ }
897
+ };
897
898
 
898
- $this.appender = function(table, rows) {
899
- var c = table.config,
899
+ $this.appender = function(table, rows) {
900
+ var c = table.config,
900
901
  p = c.pager;
901
- if ( !p.ajax ) {
902
- c.rowsCopy = rows;
903
- p.totalRows = p.countChildRows ? c.$tbodies.eq(0).children('tr').length : rows.length;
904
- p.size = $.data(table, 'pagerLastSize') || p.size || p.settings.size || 10;
905
- p.totalPages = p.size === 'all' ? 1 : Math.ceil( p.totalRows / p.size );
906
- renderTable(table, rows, p);
907
- // update display here in case all rows are removed
908
- updatePageDisplay(table, p, false);
909
- }
910
- };
902
+ if ( !p.ajax ) {
903
+ c.rowsCopy = rows;
904
+ p.totalRows = p.countChildRows ? c.$tbodies.eq(0).children('tr').length : rows.length;
905
+ p.size = $.data(table, 'pagerLastSize') || p.size || p.settings.size || 10;
906
+ p.totalPages = p.size === 'all' ? 1 : Math.ceil( p.totalRows / p.size );
907
+ renderTable(table, rows, p);
908
+ // update display here in case all rows are removed
909
+ updatePageDisplay(table, p, false);
910
+ }
911
+ };
911
912
 
912
- $this.construct = function(settings) {
913
- return this.each(function() {
914
- // check if tablesorter has initialized
915
- if (!(this.config && this.hasInitialized)) { return; }
916
- var t, ctrls, fxn, size,
913
+ $this.construct = function(settings) {
914
+ return this.each(function() {
915
+ // check if tablesorter has initialized
916
+ if (!(this.config && this.hasInitialized)) { return; }
917
+ var t, ctrls, fxn, size,
917
918
  table = this,
918
919
  c = table.config,
919
920
  wo = c.widgetOptions,
@@ -922,25 +923,25 @@
922
923
  namespace = c.namespace + 'pager',
923
924
  // added in case the pager is reinitialized after being destroyed.
924
925
  pager = p.$container = $(p.container).addClass('tablesorter-pager').show();
925
- // save a copy of the original settings
926
- p.settings = $.extend( true, {}, $.tablesorterPager.defaults, settings );
927
- if (c.debug) {
928
- console.log('Pager: Initializing');
929
- }
930
- p.oldAjaxSuccess = p.oldAjaxSuccess || p.ajaxObject.success;
931
- c.appender = $this.appender;
932
- p.initializing = true;
933
- if (p.savePages && ts.storage) {
934
- t = ts.storage(table, p.storageKey) || {}; // fixes #387
935
- p.page = isNaN(t.page) ? p.page : t.page;
936
- p.size = t.size === 'all' ? t.size : ( isNaN( t.size ) ? p.size : t.size ) || p.setSize || 10;
937
- $.data(table, 'pagerLastSize', p.size);
938
- pager.find(p.cssPageSize).val(p.size);
939
- }
940
- // skipped rows
941
- p.regexRows = new RegExp('(' + (wo.filter_filteredRow || 'filtered') + '|' + c.selectorRemove.slice(1) + '|' + c.cssChildRow + ')');
926
+ // save a copy of the original settings
927
+ p.settings = $.extend( true, {}, $.tablesorterPager.defaults, settings );
928
+ if (c.debug) {
929
+ console.log('Pager: Initializing');
930
+ }
931
+ p.oldAjaxSuccess = p.oldAjaxSuccess || p.ajaxObject.success;
932
+ c.appender = $this.appender;
933
+ p.initializing = true;
934
+ if (p.savePages && ts.storage) {
935
+ t = ts.storage(table, p.storageKey) || {}; // fixes #387
936
+ p.page = isNaN(t.page) ? p.page : t.page;
937
+ p.size = t.size === 'all' ? t.size : ( isNaN( t.size ) ? p.size : t.size ) || p.setSize || 10;
938
+ $.data(table, 'pagerLastSize', p.size);
939
+ pager.find(p.cssPageSize).val(p.size);
940
+ }
941
+ // skipped rows
942
+ p.regexRows = new RegExp('(' + (wo.filter_filteredRow || 'filtered') + '|' + c.selectorRemove.slice(1) + '|' + c.cssChildRow + ')');
942
943
 
943
- $t
944
+ $t
944
945
  // .unbind( namespace ) adding in jQuery 1.4.3 ( I think )
945
946
  .unbind( pagerEvents.split(' ').join(namespace + ' ').replace(/\s+/g, ' ') )
946
947
  .bind('filterInit filterStart '.split(' ').join(namespace + ' '), function(e, filters) {
@@ -1020,13 +1021,13 @@
1020
1021
  updatePageDisplay(table, p, false);
1021
1022
  });
1022
1023
 
1023
- // clicked controls
1024
- ctrls = [ p.cssFirst, p.cssPrev, p.cssNext, p.cssLast ];
1025
- fxn = [ moveToFirstPage, moveToPrevPage, moveToNextPage, moveToLastPage ];
1026
- if (c.debug && !pager.length) {
1027
- console.warn('Pager: >> Container not found');
1028
- }
1029
- pager.find(ctrls.join(','))
1024
+ // clicked controls
1025
+ ctrls = [ p.cssFirst, p.cssPrev, p.cssNext, p.cssLast ];
1026
+ fxn = [ moveToFirstPage, moveToPrevPage, moveToNextPage, moveToLastPage ];
1027
+ if (c.debug && !pager.length) {
1028
+ console.warn('Pager: >> Container not found');
1029
+ }
1030
+ pager.find(ctrls.join(','))
1030
1031
  .attr('tabindex', 0)
1031
1032
  .unbind('click' + namespace)
1032
1033
  .bind('click' + namespace, function(e){
@@ -1042,94 +1043,95 @@
1042
1043
  }
1043
1044
  });
1044
1045
 
1045
- // goto selector
1046
- p.$goto = pager.find(p.cssGoto);
1047
- if ( p.$goto.length ) {
1048
- p.$goto
1046
+ // goto selector
1047
+ p.$goto = pager.find(p.cssGoto);
1048
+ if ( p.$goto.length ) {
1049
+ p.$goto
1049
1050
  .unbind('change' + namespace)
1050
1051
  .bind('change' + namespace, function(){
1051
1052
  p.page = $(this).val() - 1;
1052
1053
  moveToPage(table, p, true);
1053
1054
  updatePageDisplay(table, p, false);
1054
1055
  });
1055
- } else if (c.debug) {
1056
- console.warn('Pager: >> Goto selector not found');
1057
- }
1058
- // page size selector
1059
- p.$size = pager.find(p.cssPageSize);
1060
- if ( p.$size.length ) {
1061
- // setting an option as selected appears to cause issues with initial page size
1062
- p.$size.find('option').removeAttr('selected');
1063
- p.$size.unbind('change' + namespace).bind('change' + namespace, function() {
1064
- if ( !$(this).hasClass(p.cssDisabled) ) {
1065
- var size = $(this).val();
1066
- p.$size.val( size ); // in case there are more than one pagers
1067
- setPageSize(table, size, p);
1068
- changeHeight(table, p);
1069
- }
1070
- return false;
1071
- });
1072
- } else if (c.debug) {
1073
- console.warn('Pager: >> Size selector not found');
1074
- }
1075
-
1076
- // clear initialized flag
1077
- p.initialized = false;
1078
- // before initialization event
1079
- $t.triggerHandler('pagerBeforeInitialized', p);
1080
-
1081
- enablePager(table, p, false);
1082
- if ( typeof p.ajaxUrl === 'string' ) {
1083
- // ajax pager; interact with database
1084
- p.ajax = true;
1085
- // When filtering with ajax, allow only custom filtering function, disable default
1086
- // filtering since it will be done server side.
1087
- c.widgetOptions.filter_serversideFiltering = true;
1088
- c.serverSideSorting = true;
1089
- moveToPage(table, p);
1090
- } else {
1091
- p.ajax = false;
1092
- // Regular pager; all rows stored in memory
1093
- ts.appendCache( c, true ); // true = don't apply widgets
1094
- hideRowsSetup(table, p);
1095
- }
1056
+ } else if (c.debug) {
1057
+ console.warn('Pager: >> Goto selector not found');
1058
+ }
1059
+ // page size selector
1060
+ p.$size = pager.find(p.cssPageSize);
1061
+ if ( p.$size.length ) {
1062
+ // setting an option as selected appears to cause issues with initial page size
1063
+ p.$size.find('option').removeAttr('selected');
1064
+ p.$size.unbind('change' + namespace).bind('change' + namespace, function() {
1065
+ if ( !$(this).hasClass(p.cssDisabled) ) {
1066
+ var size = $(this).val();
1067
+ p.$size.val( size ); // in case there are more than one pagers
1068
+ setPageSize(table, size, p);
1069
+ changeHeight(table, p);
1070
+ }
1071
+ return false;
1072
+ });
1073
+ } else if (c.debug) {
1074
+ console.warn('Pager: >> Size selector not found');
1075
+ }
1096
1076
 
1097
- // pager initialized
1098
- if (!p.ajax && !p.initialized) {
1099
- p.initializing = false;
1100
- p.initialized = true;
1101
- moveToPage(table, p);
1102
- if (c.debug) {
1103
- console.log('Pager: Triggering pagerInitialized');
1077
+ // clear initialized flag
1078
+ p.initialized = false;
1079
+ // before initialization event
1080
+ $t.triggerHandler('pagerBeforeInitialized', p);
1081
+
1082
+ enablePager(table, p, false);
1083
+ if ( typeof p.ajaxUrl === 'string' ) {
1084
+ // ajax pager; interact with database
1085
+ p.ajax = true;
1086
+ // When filtering with ajax, allow only custom filtering function, disable default
1087
+ // filtering since it will be done server side.
1088
+ c.widgetOptions.filter_serversideFiltering = true;
1089
+ c.serverSideSorting = true;
1090
+ moveToPage(table, p);
1091
+ } else {
1092
+ p.ajax = false;
1093
+ // Regular pager; all rows stored in memory
1094
+ ts.appendCache( c, true ); // true = don't apply widgets
1095
+ hideRowsSetup(table, p);
1104
1096
  }
1105
- c.$table.triggerHandler( 'pagerInitialized', p );
1106
- if ( !( c.widgetOptions.filter_initialized && ts.hasWidget(table, 'filter') ) ) {
1107
- updatePageDisplay(table, p, false);
1097
+
1098
+ // pager initialized
1099
+ if (!p.ajax && !p.initialized) {
1100
+ p.initializing = false;
1101
+ p.initialized = true;
1102
+ moveToPage(table, p);
1103
+ if (c.debug) {
1104
+ console.log('Pager: Triggering pagerInitialized');
1105
+ }
1106
+ c.$table.triggerHandler( 'pagerInitialized', p );
1107
+ if ( !( c.widgetOptions.filter_initialized && ts.hasWidget(table, 'filter') ) ) {
1108
+ updatePageDisplay(table, p, false);
1109
+ }
1108
1110
  }
1109
- }
1110
1111
 
1111
- // make the hasWidget function think that the pager widget is being used
1112
- c.widgetInit.pager = true;
1113
- });
1114
- };
1112
+ // make the hasWidget function think that the pager widget is being used
1113
+ c.widgetInit.pager = true;
1114
+ });
1115
+ };
1115
1116
 
1116
- }() });
1117
+ }()
1118
+ });
1117
1119
 
1118
1120
  // see #486
1119
1121
  ts.showError = function( table, xhr, settings, exception ) {
1120
1122
  var $row,
1121
- $table = $( table ),
1122
- c = $table[0].config,
1123
- wo = c && c.widgetOptions,
1124
- errorRow = c.pager && c.pager.cssErrorRow ||
1125
- wo && wo.pager_css && wo.pager_css.errorRow ||
1126
- 'tablesorter-errorRow',
1127
- typ = typeof xhr,
1128
- valid = true,
1129
- message = '',
1130
- removeRow = function(){
1131
- c.$table.find( 'thead' ).find( '.' + errorRow ).remove();
1132
- };
1123
+ $table = $( table ),
1124
+ c = $table[0].config,
1125
+ wo = c && c.widgetOptions,
1126
+ errorRow = c.pager && c.pager.cssErrorRow ||
1127
+ wo && wo.pager_css && wo.pager_css.errorRow ||
1128
+ 'tablesorter-errorRow',
1129
+ typ = typeof xhr,
1130
+ valid = true,
1131
+ message = '',
1132
+ removeRow = function(){
1133
+ c.$table.find( 'thead' ).find( '.' + errorRow ).remove();
1134
+ };
1133
1135
 
1134
1136
  if ( !$table.length ) {
1135
1137
  console.error('tablesorter showError: no table parameter passed');
@@ -1156,13 +1158,13 @@
1156
1158
  if ( message === '' ) {
1157
1159
  if ( typ === 'object' ) {
1158
1160
  message =
1159
- xhr.status === 0 ? 'Not connected, verify Network' :
1160
- xhr.status === 404 ? 'Requested page not found [404]' :
1161
- xhr.status === 500 ? 'Internal Server Error [500]' :
1162
- exception === 'parsererror' ? 'Requested JSON parse failed' :
1163
- exception === 'timeout' ? 'Time out error' :
1164
- exception === 'abort' ? 'Ajax Request aborted' :
1165
- 'Uncaught error: ' + xhr.statusText + ' [' + xhr.status + ']';
1161
+ xhr.status === 0 ? 'Not connected, verify Network' :
1162
+ xhr.status === 404 ? 'Requested page not found [404]' :
1163
+ xhr.status === 500 ? 'Internal Server Error [500]' :
1164
+ exception === 'parsererror' ? 'Requested JSON parse failed' :
1165
+ exception === 'timeout' ? 'Time out error' :
1166
+ exception === 'abort' ? 'Ajax Request aborted' :
1167
+ 'Uncaught error: ' + xhr.statusText + ' [' + xhr.status + ']';
1166
1168
  } else if ( typ === 'string' ) {
1167
1169
  // keep backward compatibility (external usage just passes a message string)
1168
1170
  message = xhr;
@@ -1174,16 +1176,16 @@
1174
1176
 
1175
1177
  // allow message to include entire row HTML!
1176
1178
  $row = ( /tr\>/.test(message) ? $(message) : $('<tr><td colspan="' + c.columns + '">' + message + '</td></tr>') )
1177
- .click( function() {
1178
- $( this ).remove();
1179
- })
1180
- // add error row to thead instead of tbody, or clicking on the header will result in a parser error
1181
- .appendTo( c.$table.find( 'thead:first' ) )
1182
- .addClass( errorRow + ' ' + c.selectorRemove.slice(1) )
1183
- .attr({
1184
- role : 'alert',
1185
- 'aria-live' : 'assertive'
1186
- });
1179
+ .click( function() {
1180
+ $( this ).remove();
1181
+ })
1182
+ // add error row to thead instead of tbody, or clicking on the header will result in a parser error
1183
+ .appendTo( c.$table.find( 'thead:first' ) )
1184
+ .addClass( errorRow + ' ' + c.selectorRemove.slice(1) )
1185
+ .attr({
1186
+ role : 'alert',
1187
+ 'aria-live' : 'assertive'
1188
+ });
1187
1189
 
1188
1190
  };
1189
1191