jquery-tablesorter 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4f5f04bd46d8e9001eaed1fd11168abaf1dc01d3
4
+ data.tar.gz: 94b839457b16ae09027b6b31f1aae45900a02f95
5
+ SHA512:
6
+ metadata.gz: e7b986e9531e83e42da0a5a991441a87cc762df6cd9d6f5a2397e47040b8462ac1a8d0a875be2376d36a104c901276533e2de1fd6e660800bac19c2e058388e0
7
+ data.tar.gz: fd625bcab3d94d00687e797837a124e97c364c94a6c7509e5d44bc2992ccdc85f89d32529b19620c9523647764ed95f0411d17100421d0ab6bf28e0fb2b1d462
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2013 Jun Lin
1
+ Copyright 2013 Jun Lin, Erik-B. Ernst
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.markdown CHANGED
@@ -1,10 +1,10 @@
1
1
  # jQuery Table Sorter plugin for Rails
2
2
 
3
- [![Still Maintained](http://stillmaintained.com/linjunpop/jquery-tablesorter-rails.png)](http://stillmaintained.com/linjunpop/jquery-tablesorter-rails)
3
+ [![Gem Version](https://badge.fury.io/rb/jquery-tablesorter.png)](http://badge.fury.io/rb/jquery-tablesorter)
4
4
 
5
5
  Simple integration of jquery-tablesorter into the asset pipeline.
6
6
 
7
- Current tablesorter version: 2.7.5 (2/5/2013), [documentation]
7
+ Current tablesorter version: 2.10.8 (6/3/2013), [documentation]
8
8
 
9
9
  Any issue associate with the js/css files, please report to [Mottie's fork].
10
10
 
@@ -92,7 +92,7 @@ pager theme:
92
92
  2. Run `rake jquery_tablesorter:update`
93
93
  3. Run `rake jquery_tablesorter:sanitize_image_paths`
94
94
  4. Update `README.md` and `CHANGELOG.md`
95
-
95
+
96
96
 
97
97
  [Mottie's fork]: https://github.com/Mottie/tablesorter
98
98
  [documentation]: http://mottie.github.com/tablesorter/docs/index.html
@@ -1,3 +1,3 @@
1
1
  module JqueryTablesorter
2
- VERSION = "1.4.1"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * tablesorter pager plugin
3
- * updated 1/29/2013
3
+ * updated 5/27/2013
4
4
  */
5
5
  /*jshint browser:true, jquery:true, unused:false */
6
6
  ;(function($) {
@@ -20,6 +20,14 @@
20
20
  // and a filterList = [[2,Blue],[3,13]] becomes "&fcol[2]=Blue&fcol[3]=13" in the url
21
21
  ajaxUrl: null,
22
22
 
23
+ // modify the url after all processing has been applied
24
+ customAjaxUrl: function(table, url) { return url; },
25
+
26
+ // modify the $.ajax object to allow complete control over your ajax requests
27
+ ajaxObject: {
28
+ dataType: 'json'
29
+ },
30
+
23
31
  // process ajax so that the following information is returned:
24
32
  // [ total_rows (number), rows (array of arrays), headers (array; optional) ]
25
33
  // example:
@@ -87,21 +95,24 @@
87
95
  dis = !!disable,
88
96
  tp = Math.min( c.totalPages, c.filteredPages );
89
97
  if ( c.updateArrows ) {
90
- $(c.cssFirst + ',' + c.cssPrev, c.container)[ ( dis || c.page === 0 ) ? a : r ](d);
91
- $(c.cssNext + ',' + c.cssLast, c.container)[ ( dis || c.page === tp - 1 ) ? a : r ](d);
98
+ c.$container.find(c.cssFirst + ',' + c.cssPrev)[ ( dis || c.page === 0 ) ? a : r ](d);
99
+ c.$container.find(c.cssNext + ',' + c.cssLast)[ ( dis || c.page === tp - 1 ) ? a : r ](d);
92
100
  }
93
101
  },
94
102
 
95
- updatePageDisplay = function(table, c) {
96
- var i, p, s, t, out, f = $(table).hasClass('hasFilters') && !c.ajaxUrl;
97
- c.filteredRows = (f) ? table.config.$tbodies.children('tr:not(.filtered,.remove-me)').length : c.totalRows;
98
- c.filteredPages = (f) ? Math.ceil( c.filteredRows / c.size ) : c.totalPages;
99
- if ( Math.min( c.totalPages, c.filteredPages ) > 0 ) {
103
+ updatePageDisplay = function(table, c, flag) {
104
+ var i, p, s, t, out,
105
+ tc = table.config,
106
+ f = $(table).hasClass('hasFilters') && !c.ajaxUrl;
107
+ c.totalPages = Math.ceil( c.totalRows / c.size ); // needed for "pageSize" method
108
+ c.filteredRows = (f) ? tc.$tbodies.eq(0).children('tr:not(.' + (tc.widgetOptions && tc.widgetOptions.filter_filteredRow || 'filtered') + ',' + tc.selectorRemove + ')').length : c.totalRows;
109
+ c.filteredPages = (f) ? Math.ceil( c.filteredRows / c.size ) || 1 : c.totalPages;
110
+ if ( Math.min( c.totalPages, c.filteredPages ) >= 0 ) {
100
111
  t = (c.size * c.page > c.filteredRows);
101
- c.startRow = (t) ? 1 : ( c.size * c.page ) + 1;
112
+ c.startRow = (t) ? 1 : (c.filteredRows === 0 ? 0 : c.size * c.page + 1);
102
113
  c.page = (t) ? 0 : c.page;
103
114
  c.endRow = Math.min( c.filteredRows, c.totalRows, c.size * ( c.page + 1 ) );
104
- out = $(c.cssPageDisplay, c.container);
115
+ out = c.$container.find(c.cssPageDisplay);
105
116
  // form the output string
106
117
  s = c.output.replace(/\{(page|filteredRows|filteredPages|totalPages|startRow|endRow|totalRows)\}/gi, function(m){
107
118
  return {
@@ -114,24 +125,24 @@
114
125
  '{totalRows}' : c.totalRows
115
126
  }[m];
116
127
  });
117
- if (out[0]) {
128
+ if (out.length) {
118
129
  out[ (out[0].tagName === 'INPUT') ? 'val' : 'html' ](s);
119
- if ( $(c.cssGoto, c.container).length ) {
130
+ if ( c.$goto.length ) {
120
131
  t = '';
121
132
  p = Math.min( c.totalPages, c.filteredPages );
122
133
  for ( i = 1; i <= p; i++ ) {
123
134
  t += '<option>' + i + '</option>';
124
135
  }
125
- $(c.cssGoto, c.container).html(t).val(c.page + 1);
136
+ c.$goto.html(t).val( c.page + 1 );
126
137
  }
127
138
  }
128
139
  }
129
140
  pagerArrows(c);
130
- if (c.initialized) { $(table).trigger('pagerComplete', c); }
141
+ if (c.initialized && flag !== false) { $(table).trigger('pagerComplete', c); }
131
142
  },
132
143
 
133
144
  fixHeight = function(table, c) {
134
- var d, h, $b = $(table.tBodies[0]);
145
+ var d, h, $b = table.config.$tbodies.eq(0);
135
146
  if (c.fixedHeight) {
136
147
  $b.find('tr.pagerSavedHeightSpacer').remove();
137
148
  h = $.data(table, 'pagerSavedHeight');
@@ -145,7 +156,7 @@
145
156
  },
146
157
 
147
158
  changeHeight = function(table, c) {
148
- var $b = $(table.tBodies[0]);
159
+ var $b = table.config.$tbodies.eq(0);
149
160
  $b.find('tr.pagerSavedHeightSpacer').remove();
150
161
  $.data(table, 'pagerSavedHeight', $b.height());
151
162
  fixHeight(table, c);
@@ -155,13 +166,15 @@
155
166
  hideRows = function(table, c){
156
167
  if (!c.ajaxUrl) {
157
168
  var i,
158
- rows = $(table.tBodies).children('tr:not(.' + table.config.cssChildRow + ')'),
169
+ tc = table.config,
170
+ rows = tc.$tbodies.eq(0).children('tr:not(.' + tc.cssChildRow + ')'),
159
171
  l = rows.length,
160
172
  s = ( c.page * c.size ),
161
173
  e = s + c.size,
174
+ f = tc.widgetOptions && tc.widgetOptions.filter_filteredRow || 'filtered',
162
175
  j = 0; // size counter
163
176
  for ( i = 0; i < l; i++ ){
164
- if (!/filtered/.test(rows[i].className)) {
177
+ if ( !rows[i].className.match(f) ) {
165
178
  rows[i].style.display = ( j >= s && j < e ) ? '' : 'none';
166
179
  j++;
167
180
  }
@@ -170,7 +183,7 @@
170
183
  },
171
184
 
172
185
  hideRowsSetup = function(table, c){
173
- c.size = parseInt( $(c.cssPageSize, c.container).find('option[selected]').val(), 10 ) || c.size;
186
+ c.size = parseInt( c.$size.val(), 10 ) || c.size;
174
187
  $.data(table, 'pagerLastSize', c.size);
175
188
  pagerArrows(c);
176
189
  if ( !c.removeRows ) {
@@ -181,65 +194,87 @@
181
194
  }
182
195
  },
183
196
 
184
- renderAjax = function(data, table, c, exception){
197
+ renderAjax = function(data, table, c, xhr, exception){
185
198
  // process data
186
199
  if ( typeof(c.ajaxProcessing) === "function" ) {
187
200
  // ajaxProcessing result: [ total, rows, headers ]
188
- var i, j, hsh, $f, $sh,
201
+ var i, j, hsh, $f, $sh, th, d, l, $err,
189
202
  $t = $(table),
190
203
  tc = table.config,
191
204
  hl = $t.find('thead th').length, tds = '',
192
- err = '<tr class="' + c.cssErrorRow + ' ' + tc.selectorRemove.replace(/(tr)?\./g,'') + '"><td style="text-align: center;" colspan="' + hl + '">' +
193
- (exception ? exception.message + ' (' + exception.name + ')' : 'No rows found') + '</td></tr>',
194
- result = c.ajaxProcessing(data) || [ 0, [] ],
195
- d = result[1] || [],
196
- l = d.length,
197
- th = result[2];
198
- if ( l > 0 ) {
199
- for ( i = 0; i < l; i++ ) {
200
- tds += '<tr>';
201
- for ( j = 0; j < d[i].length; j++ ) {
202
- // build tbody cells
203
- tds += '<td>' + d[i][j] + '</td>';
204
- }
205
- tds += '</tr>';
206
- }
207
- }
208
- // only add new header text if the length matches
209
- if ( th && th.length === hl ) {
210
- hsh = $t.hasClass('hasStickyHeaders');
211
- $sh = $t.find('.' + ((tc.widgetOptions && tc.widgetOptions.stickyHeaders) || 'tablesorter-stickyheader'));
212
- $f = $t.find('tfoot tr:first').children();
213
- $t.find('th.' + tc.cssHeader).each(function(j){
214
- var $t = $(this), icn;
215
- // add new test within the first span it finds, or just in the header
216
- if ( $t.find('.' + tc.cssIcon).length ) {
217
- icn = $t.find('.' + tc.cssIcon).clone(true);
218
- $t.find('.tablesorter-header-inner').html( th[j] ).append(icn);
219
- if ( hsh && $sh.length ) {
220
- icn = $sh.find('th').eq(j).find('.' + tc.cssIcon).clone(true);
221
- $sh.find('th').eq(j).find('.tablesorter-header-inner').html( th[j] ).append(icn);
222
- }
223
- } else {
224
- $t.find('.tablesorter-header-inner').html( th[j] );
225
- $sh.find('th').eq(j).find('.tablesorter-header-inner').html( th[j] );
226
- }
227
- $f.eq(j).html( th[j] );
228
- });
229
- }
230
-
205
+ result = c.ajaxProcessing(data, table) || [ 0, [] ],
206
+ // allow [ total, rows, headers ] or [ rows, total, headers ]
207
+ t = isNaN(result[0]) && !isNaN(result[1]);
208
+
231
209
  $t.find('thead tr.' + c.cssErrorRow).remove(); // Clean up any previous error.
210
+
232
211
  if ( exception ) {
212
+ $err = $('<tr class="' + c.cssErrorRow + '"><td style="text-align:center;" colspan="' + hl + '">' + (
213
+ xhr.status === 0 ? 'Not connected, verify Network' :
214
+ xhr.status === 404 ? 'Requested page not found [404]' :
215
+ xhr.status === 500 ? 'Internal Server Error [500]' :
216
+ exception === 'parsererror' ? 'Requested JSON parse failed' :
217
+ exception === 'timeout' ? 'Time out error' :
218
+ exception === 'abort' ? 'Ajax Request aborted' :
219
+ 'Uncaught error: ' + xhr.statusText + ' [' + xhr.status + ']' ) + '</td></tr>')
220
+ .click(function(){
221
+ $(this).remove();
222
+ })
233
223
  // add error row to thead instead of tbody, or clicking on the header will result in a parser error
234
- $t.find('thead').append(err);
224
+ .appendTo( $t.find('thead:first') );
225
+ tc.$tbodies.eq(0).empty();
235
226
  } else {
236
- $(table.tBodies[0]).html( tds ); // add rows to first tbody
227
+ c.totalRows = result[t ? 1 : 0] || c.totalRows || 0;
228
+ d = result[t ? 0 : 1] || []; // row data
229
+ l = d.length;
230
+ th = result[2]; // headers
231
+ if (d instanceof jQuery) {
232
+ // append jQuery object
233
+ tc.$tbodies.eq(0).empty().append(d);
234
+ } else if (d.length) {
235
+ // build table from array
236
+ if ( l > 0 ) {
237
+ for ( i = 0; i < l; i++ ) {
238
+ tds += '<tr>';
239
+ for ( j = 0; j < d[i].length; j++ ) {
240
+ // build tbody cells
241
+ tds += '<td>' + d[i][j] + '</td>';
242
+ }
243
+ tds += '</tr>';
244
+ }
245
+ }
246
+ // add rows to first tbody
247
+ tc.$tbodies.eq(0).html( tds );
248
+ }
249
+ // only add new header text if the length matches
250
+ if ( th && th.length === hl ) {
251
+ hsh = $t.hasClass('hasStickyHeaders');
252
+ $sh = hsh ? tc.$sticky.children('thead:first').children().children() : '';
253
+ $f = $t.find('tfoot tr:first').children();
254
+ $t.find('th.' + tc.cssHeader).each(function(j){
255
+ var $t = $(this), icn;
256
+ // add new test within the first span it finds, or just in the header
257
+ if ( $t.find('.' + tc.cssIcon).length ) {
258
+ icn = $t.find('.' + tc.cssIcon).clone(true);
259
+ $t.find('.tablesorter-header-inner').html( th[j] ).append(icn);
260
+ if ( hsh && $sh.length ) {
261
+ icn = $sh.eq(j).find('.' + tc.cssIcon).clone(true);
262
+ $sh.eq(j).find('.tablesorter-header-inner').html( th[j] ).append(icn);
263
+ }
264
+ } else {
265
+ $t.find('.tablesorter-header-inner').html( th[j] );
266
+ if (hsh && $sh.length) {
267
+ $sh.eq(j).find('.tablesorter-header-inner').html( th[j] );
268
+ }
269
+ }
270
+ $f.eq(j).html( th[j] );
271
+ });
272
+ }
237
273
  }
238
274
  if (tc.showProcessing) {
239
275
  $.tablesorter.isProcessing(table); // remove loading icon
240
276
  }
241
277
  $t.trigger('update');
242
- c.totalRows = result[0] || 0;
243
278
  c.totalPages = Math.ceil( c.totalRows / c.size );
244
279
  updatePageDisplay(table, c);
245
280
  fixHeight(table, c);
@@ -253,30 +288,39 @@
253
288
 
254
289
  getAjax = function(table, c){
255
290
  var url = getAjaxUrl(table, c),
291
+ $doc = $(document),
256
292
  tc = table.config;
257
293
  if ( url !== '' ) {
258
294
  if (tc.showProcessing) {
259
295
  $.tablesorter.isProcessing(table, true); // show loading icon
260
296
  }
261
- $(document).bind('ajaxError.pager', function(e, xhr, settings, exception) {
262
- if (settings.url === url) {
263
- renderAjax(null, table, c, exception);
264
- $(document).unbind('ajaxError.pager');
297
+ $doc.bind('ajaxError.pager', function(e, xhr, settings, exception) {
298
+ if (url.match(settings.url)) {
299
+ renderAjax(null, table, c, xhr, exception);
300
+ $doc.unbind('ajaxError.pager');
265
301
  }
266
302
  });
267
- $.getJSON(url, function(data) {
303
+ c.ajaxObject.url = url; // from the ajaxUrl option and modified by customAjaxUrl
304
+ c.ajaxObject.success = function(data) {
268
305
  renderAjax(data, table, c);
269
- $(document).unbind('ajaxError.pager');
270
- });
306
+ $doc.unbind('ajaxError.pager');
307
+ if (typeof c.oldAjaxSuccess === 'function') {
308
+ c.oldAjaxSuccess(data);
309
+ }
310
+ };
311
+ $.ajax(c.ajaxObject);
271
312
  }
272
313
  },
273
-
314
+
274
315
  getAjaxUrl = function(table, c) {
275
- var url = (c.ajaxUrl) ? c.ajaxUrl.replace(/\{page\}/g, c.page).replace(/\{size\}/g, c.size) : '',
316
+ var url = (c.ajaxUrl) ? c.ajaxUrl
317
+ // allow using "{page+1}" in the url string to switch to a non-zero based index
318
+ .replace(/\{page([\-+]\d+)?\}/, function(s,n){ return c.page + (n ? parseInt(n, 10) : 0); })
319
+ .replace(/\{size\}/g, c.size) : '',
276
320
  sl = table.config.sortList,
277
321
  fl = c.currentFilters || [],
278
- sortCol = url.match(/\{sortList[\s+]?:[\s+]?([^}]*)\}/),
279
- filterCol = url.match(/\{filterList[\s+]?:[\s+]?([^}]*)\}/),
322
+ sortCol = url.match(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/),
323
+ filterCol = url.match(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/),
280
324
  arry = [];
281
325
  if (sortCol) {
282
326
  sortCol = sortCol[1];
@@ -284,7 +328,8 @@
284
328
  arry.push(sortCol + '[' + v[0] + ']=' + v[1]);
285
329
  });
286
330
  // if the arry is empty, just add the col parameter... "&{sortList:col}" becomes "&col"
287
- url = url.replace(/\{sortList[\s+]?:[\s+]?([^\}]*)\}/g, arry.length ? arry.join('&') : sortCol );
331
+ url = url.replace(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/g, arry.length ? arry.join('&') : sortCol );
332
+ arry = [];
288
333
  }
289
334
  if (filterCol) {
290
335
  filterCol = filterCol[1];
@@ -294,16 +339,17 @@
294
339
  }
295
340
  });
296
341
  // if the arry is empty, just add the fcol parameter... "&{filterList:fcol}" becomes "&fcol"
297
- url = url.replace(/\{filterList[\s+]?:[\s+]?([^\}]*)\}/g, arry.length ? arry.join('&') : filterCol );
342
+ url = url.replace(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/g, arry.length ? arry.join('&') : filterCol );
343
+ }
344
+ if ( typeof(c.customAjaxUrl) === "function" ) {
345
+ url = c.customAjaxUrl(table, url);
298
346
  }
299
-
300
347
  return url;
301
348
  },
302
349
 
303
350
  renderTable = function(table, rows, c) {
304
351
  c.isDisabled = false; // needed because sorting will change the page and re-enable the pager
305
- var i, j, o,
306
- f = document.createDocumentFragment(),
352
+ var i, j, o, $tb,
307
353
  l = rows.length,
308
354
  s = ( c.page * c.size ),
309
355
  e = ( s + c.size );
@@ -315,17 +361,16 @@
315
361
  if ( e > rows.length ) {
316
362
  e = rows.length;
317
363
  }
318
- $(table.tBodies[0]).addClass('tablesorter-hidden');
319
364
  $.tablesorter.clearTableBody(table);
365
+ $tb = $.tablesorter.processTbody(table, table.config.$tbodies.eq(0), true);
320
366
  for ( i = s; i < e; i++ ) {
321
367
  o = rows[i];
322
368
  l = o.length;
323
369
  for ( j = 0; j < l; j++ ) {
324
- f.appendChild(o[j]);
370
+ $tb.appendChild(o[j]);
325
371
  }
326
372
  }
327
- table.tBodies[0].appendChild(f);
328
- $(table.tBodies[0]).removeClass('tablesorter-hidden');
373
+ $.tablesorter.processTbody(table, $tb, false);
329
374
  }
330
375
  if ( c.page >= c.totalPages ) {
331
376
  moveToLastPage(table, c);
@@ -345,21 +390,20 @@
345
390
  c.page = 0;
346
391
  c.size = c.totalRows;
347
392
  c.totalPages = 1;
348
- $('tr.pagerSavedHeightSpacer', table.tBodies[0]).remove();
393
+ $(table).find('tr.pagerSavedHeightSpacer').remove();
349
394
  renderTable(table, table.config.rowsCopy, c);
350
395
  }
351
396
  // disable size selector
352
- $(c.container).find(c.cssPageSize + ',' + c.cssGoto).each(function(){
397
+ c.$size.add(c.$goto).each(function(){
353
398
  $(this).addClass(c.cssDisabled)[0].disabled = true;
354
399
  });
355
400
  },
356
401
 
357
- moveToPage = function(table, c) {
402
+ moveToPage = function(table, c, flag) {
358
403
  if ( c.isDisabled ) { return; }
359
404
  var p = Math.min( c.totalPages, c.filteredPages );
360
- if ( c.page < 0 || c.page > ( p - 1 ) ) {
361
- c.page = 0;
362
- }
405
+ if ( c.page < 0 ) { c.page = 0; }
406
+ if ( c.page > ( p - 1 ) && p !== 0 ) { c.page = p - 1; }
363
407
  if (c.ajax) {
364
408
  getAjax(table, c);
365
409
  } else if (!c.ajax) {
@@ -367,11 +411,14 @@
367
411
  }
368
412
  $.data(table, 'pagerLastPage', c.page);
369
413
  $.data(table, 'pagerUpdateTriggered', true);
370
- if (c.initialized) { $(table).trigger('pageMoved', c); }
414
+ if (c.initialized && flag !== false) {
415
+ $(table).trigger('pageMoved', c);
416
+ }
371
417
  },
372
418
 
373
419
  setPageSize = function(table, size, c) {
374
420
  c.size = size;
421
+ c.$size.val(size);
375
422
  $.data(table, 'pagerLastPage', c.page);
376
423
  $.data(table, 'pagerLastSize', c.size);
377
424
  c.totalPages = Math.ceil( c.totalRows / c.size );
@@ -406,14 +453,14 @@
406
453
 
407
454
  destroyPager = function(table, c){
408
455
  showAllRows(table, c);
409
- $(c.container).hide(); // hide pager
456
+ c.$container.hide(); // hide pager
410
457
  table.config.appender = null; // remove pager appender function
411
458
  $(table).unbind('destroy.pager sortEnd.pager filterEnd.pager enable.pager disable.pager');
412
459
  },
413
460
 
414
461
  enablePager = function(table, c, triggered){
415
- var p = $(c.cssPageSize, c.container).removeClass(c.cssDisabled).removeAttr('disabled');
416
- $(c.container).find(c.cssGoto).removeClass(c.cssDisabled).removeAttr('disabled');
462
+ var p = c.$size.removeClass(c.cssDisabled).removeAttr('disabled');
463
+ c.$goto.removeClass(c.cssDisabled).removeAttr('disabled');
417
464
  c.isDisabled = false;
418
465
  c.page = $.data(table, 'pagerLastPage') || c.page || 0;
419
466
  c.size = $.data(table, 'pagerLastSize') || parseInt(p.find('option[selected]').val(), 10) || c.size;
@@ -448,7 +495,9 @@
448
495
  table = this,
449
496
  tc = table.config,
450
497
  $t = $(table),
451
- pager = $(c.container).addClass('tablesorter-pager').show(); // added in case the pager is reinitialized after being destroyed.
498
+ // added in case the pager is reinitialized after being destroyed.
499
+ pager = c.$container = $(c.container).addClass('tablesorter-pager').show();
500
+ c.oldAjaxSuccess = c.oldAjaxSuccess || c.ajaxObject.success;
452
501
  config.appender = $this.appender;
453
502
 
454
503
  $t
@@ -464,39 +513,51 @@
464
513
  $.data(table, 'pagerUpdateTriggered', false);
465
514
  return;
466
515
  }
467
- if (e.type === 'filterEnd') { c.page = 0; }
468
- updatePageDisplay(table, c);
469
- moveToPage(table, c);
516
+ moveToPage(table, c, false);
517
+ updatePageDisplay(table, c, false);
470
518
  fixHeight(table, c);
471
519
  })
472
- .bind('disable.pager', function(){
520
+ .bind('disable.pager', function(e){
521
+ e.stopPropagation();
473
522
  showAllRows(table, c);
474
523
  })
475
- .bind('enable.pager', function(){
524
+ .bind('enable.pager', function(e){
525
+ e.stopPropagation();
476
526
  enablePager(table, c, true);
477
527
  })
478
- .bind('destroy.pager', function(){
528
+ .bind('destroy.pager', function(e){
529
+ e.stopPropagation();
479
530
  destroyPager(table, c);
480
531
  })
481
- .bind('update.pager', function(){
532
+ .bind('update.pager', function(e){
533
+ e.stopPropagation();
482
534
  hideRows(table, c);
483
535
  })
484
536
  .bind('pageSize.pager', function(e,v){
485
- c.size = parseInt(v, 10) || 10;
537
+ e.stopPropagation();
538
+ setPageSize(table, parseInt(v, 10) || 10, c);
486
539
  hideRows(table, c);
487
- updatePageDisplay(table, c);
540
+ updatePageDisplay(table, c, false);
541
+ if (c.$size.length) { c.$size.val(c.size); } // twice?
542
+ })
543
+ .bind('pageSet.pager', function(e,v){
544
+ e.stopPropagation();
545
+ c.page = (parseInt(v, 10) || 1) - 1;
546
+ if (c.$goto.length) { c.$goto.val(c.size); } // twice?
547
+ moveToPage(table, c);
548
+ updatePageDisplay(table, c, false);
488
549
  });
489
550
 
490
551
  // clicked controls
491
- ctrls = [c.cssFirst, c.cssPrev, c.cssNext, c.cssLast];
552
+ ctrls = [ c.cssFirst, c.cssPrev, c.cssNext, c.cssLast ];
492
553
  fxn = [ moveToFirstPage, moveToPrevPage, moveToNextPage, moveToLastPage ];
493
554
  pager.find(ctrls.join(','))
494
555
  .unbind('click.pager')
495
556
  .bind('click.pager', function(e){
496
- var i, $this = $(this), l = ctrls.length;
497
- if ( !$this.hasClass(c.cssDisabled) ) {
557
+ var i, $t = $(this), l = ctrls.length;
558
+ if ( !$t.hasClass(c.cssDisabled) ) {
498
559
  for (i = 0; i < l; i++) {
499
- if ($this.is(ctrls[i])) {
560
+ if ($t.is(ctrls[i])) {
500
561
  fxn[i](table, c);
501
562
  break;
502
563
  }
@@ -506,21 +567,22 @@
506
567
  });
507
568
 
508
569
  // goto selector
509
- if ( pager.find(c.cssGoto).length ) {
510
- pager.find(c.cssGoto)
570
+ c.$goto = pager.find(c.cssGoto);
571
+ if ( c.$goto.length ) {
572
+ c.$goto
511
573
  .unbind('change')
512
574
  .bind('change', function(){
513
575
  c.page = $(this).val() - 1;
514
576
  moveToPage(table, c);
515
577
  });
516
- updatePageDisplay(table, c);
578
+ updatePageDisplay(table, c, false);
517
579
  }
518
580
 
519
581
  // page size selector
520
- t = pager.find(c.cssPageSize);
521
- if ( t.length ) {
522
- t.unbind('change.pager').bind('change.pager', function() {
523
- t.val( $(this).val() ); // in case there are more than one pagers
582
+ c.$size = pager.find(c.cssPageSize);
583
+ if ( c.$size.length ) {
584
+ c.$size.unbind('change.pager').bind('change.pager', function() {
585
+ c.$size.val( $(this).val() ); // in case there are more than one pagers
524
586
  if ( !$(this).hasClass(c.cssDisabled) ) {
525
587
  setPageSize(table, parseInt( $(this).val(), 10 ), c);
526
588
  changeHeight(table, c);
@@ -551,7 +613,7 @@
551
613
  }
552
614
 
553
615
  changeHeight(table, c);
554
-
616
+
555
617
  // pager initialized
556
618
  if (!c.ajax) {
557
619
  c.initialized = true;