jquery-tablesorter 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/README.markdown +48 -31
  2. data/Rakefile +56 -1
  3. data/lib/jquery-tablesorter/version.rb +1 -1
  4. data/vendor/assets/images/jquery-tablesorter/addons/{icons → pager/icons}/first.png +0 -0
  5. data/vendor/assets/images/jquery-tablesorter/addons/{icons → pager/icons}/last.png +0 -0
  6. data/vendor/assets/images/jquery-tablesorter/addons/pager/icons/loading.gif +0 -0
  7. data/vendor/assets/images/jquery-tablesorter/addons/{icons → pager/icons}/next.png +0 -0
  8. data/vendor/assets/images/jquery-tablesorter/addons/{icons → pager/icons}/prev.png +0 -0
  9. data/vendor/assets/images/jquery-tablesorter/black-asc.gif +0 -0
  10. data/vendor/assets/images/jquery-tablesorter/black-desc.gif +0 -0
  11. data/vendor/assets/images/jquery-tablesorter/black-unsorted.gif +0 -0
  12. data/vendor/assets/images/jquery-tablesorter/dropbox-asc1.png +0 -0
  13. data/vendor/assets/images/jquery-tablesorter/dropbox-asc2.png +0 -0
  14. data/vendor/assets/images/jquery-tablesorter/dropbox-desc1.png +0 -0
  15. data/vendor/assets/images/jquery-tablesorter/dropbox-desc2.png +0 -0
  16. data/vendor/assets/images/jquery-tablesorter/green-asc.png +0 -0
  17. data/vendor/assets/images/jquery-tablesorter/green-desc.png +0 -0
  18. data/vendor/assets/images/jquery-tablesorter/green-header.png +0 -0
  19. data/vendor/assets/images/jquery-tablesorter/green-unsorted.png +0 -0
  20. data/vendor/assets/images/jquery-tablesorter/ice-asc.gif +0 -0
  21. data/vendor/assets/images/jquery-tablesorter/ice-desc.gif +0 -0
  22. data/vendor/assets/images/jquery-tablesorter/ice-unsorted.gif +0 -0
  23. data/vendor/assets/images/jquery-tablesorter/white-asc.gif +0 -0
  24. data/vendor/assets/images/jquery-tablesorter/white-desc.gif +0 -0
  25. data/vendor/assets/images/jquery-tablesorter/white-unsorted.gif +0 -0
  26. data/vendor/assets/javascripts/jquery-tablesorter.js +3 -1
  27. data/vendor/assets/javascripts/jquery-tablesorter/addons/{jquery.tablesorter.pager.js → pager/jquery.tablesorter.pager.js} +507 -419
  28. data/vendor/assets/javascripts/jquery-tablesorter/jquery.metadata.js +53 -85
  29. data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.js +465 -314
  30. data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.min.js +6 -0
  31. data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.widgets.js +618 -267
  32. data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.widgets.min.js +12 -0
  33. data/vendor/assets/stylesheets/jquery-tablesorter/addons/{jquery.tablesorter.pager.css → pager/jquery.tablesorter.pager.css} +15 -14
  34. data/vendor/assets/stylesheets/jquery-tablesorter/theme.black-ice.css +161 -0
  35. data/vendor/assets/stylesheets/jquery-tablesorter/theme.blue.css +196 -0
  36. data/vendor/assets/stylesheets/jquery-tablesorter/theme.bootstrap.css +118 -0
  37. data/vendor/assets/stylesheets/jquery-tablesorter/theme.dark.css +162 -0
  38. data/vendor/assets/stylesheets/jquery-tablesorter/theme.default.css +164 -0
  39. data/vendor/assets/stylesheets/jquery-tablesorter/theme.dropbox.css +175 -0
  40. data/vendor/assets/stylesheets/jquery-tablesorter/theme.green.css +174 -0
  41. data/vendor/assets/stylesheets/jquery-tablesorter/theme.grey.css +217 -0
  42. data/vendor/assets/stylesheets/jquery-tablesorter/theme.ice.css +164 -0
  43. data/vendor/assets/stylesheets/jquery-tablesorter/theme.jui.css +128 -0
  44. metadata +44 -14
  45. data/lib/tasks/jquery-tablesorter_tasks.rake +0 -39
  46. data/vendor/assets/images/jquery-tablesorter/addons/icons/loading.gif +0 -0
  47. data/vendor/assets/stylesheets/jquery-tablesorter/blue.css +0 -3
  48. data/vendor/assets/stylesheets/jquery-tablesorter/blue/style.css +0 -128
  49. data/vendor/assets/stylesheets/jquery-tablesorter/ui.css +0 -4
  50. data/vendor/assets/stylesheets/jquery-tablesorter/ui/style.css +0 -67
data/README.markdown CHANGED
@@ -1,71 +1,88 @@
1
- jQuery Table Sorter plugin for Rails
2
- ===
1
+ # jQuery Table Sorter plugin for Rails
3
2
 
4
3
  Simple integration of jquery-tablesorter into the asset pipeline.
5
4
 
6
- Current version: 2.3.11(7/12/2012), [documentation]
5
+ Current tablesorter version: 2.4.6 (10/25/2012), [documentation]
7
6
 
8
7
  Any issue associate with the js/css files, please report to [Mottie's fork].
9
8
 
9
+ ## Installation
10
10
 
11
- NOTICE:
12
- ---
11
+ Add this line to your application's Gemfile:
13
12
 
14
- v0.0.5 users, from v1.0.0, this gem will use [Mottie's fork] :smile:.
13
+ gem 'jquery-tablesorter'
15
14
 
16
- Install
17
- ---
18
- In your Gemfile
15
+ And then execute:
19
16
 
20
- ```
21
- gem 'jquery-tablesorter'
22
- ```
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install jquery-tablesorter
23
22
 
24
- Requirements
25
- ---
23
+ ## Requirements
26
24
 
27
25
  Rails 3.1 and higher
28
26
 
29
- Usage
30
- ---
27
+ ## Usage
31
28
 
32
- ### In your `application.js`
29
+ ### JavaScript files
33
30
 
34
- ```
35
- require jquery-tablesorter
31
+ In your `application.js`
32
+
33
+ ```javascript
34
+ //= require jquery-tablesorter
36
35
  ```
37
36
 
38
- this will require all files.
37
+ This will require all jquery-tablesorter files (exclude addons).
39
38
 
40
39
  Or you can include single file with:
41
40
 
42
- ```
41
+ ```javascript
43
42
  //= require jquery-tablesorter/jquery.metadata
44
43
  //= require jquery-tablesorter/jquery.tablesorter
45
44
  //= require jquery-tablesorter/jquery.tablesorter.widgets
46
- //= require jquery-tablesorter/addons/jquery.tablesorter.pager
45
+ //= require jquery-tablesorter/addons/pager/jquery.tablesorter.pager
47
46
  ```
48
47
 
48
+ ### Stylesheet files
49
49
 
50
- ### In your `application.css`
50
+ In your `application.css`
51
51
 
52
- ```
52
+ ```css
53
53
  /*
54
- * = require jquery-tablesorter/<theme name>
54
+ *= require jquery-tablesorter/<theme name>
55
55
  */
56
56
  ```
57
57
 
58
58
  Avaliable theme names:
59
59
 
60
- * blue
61
- * ui
62
-
60
+ * theme.black-ice
61
+ * theme.blue
62
+ * theme.bootstrap
63
+ * theme.dark
64
+ * theme.default
65
+ * theme.dropbox
66
+ * theme.green
67
+ * theme.grey
68
+ * theme.ice
69
+ * theme.jui
63
70
 
64
- ### In CoffeeScript file:
71
+ pager theme:
65
72
 
73
+ ```css
74
+ /*
75
+ *= require jquery-tablesorter/addons/pager/jquery.tablesorter.pager
76
+ */
66
77
  ```
67
- $('table.tablesorter').tablesorter()
68
- ```
78
+
79
+ ## Contributing
80
+
81
+ 1. Fork it
82
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
83
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
84
+ 4. Push to the branch (`git push origin my-new-feature`)
85
+ 5. Create new Pull Request
69
86
 
70
87
  [Mottie's fork]: https://github.com/Mottie/tablesorter
71
88
  [documentation]: http://mottie.github.com/tablesorter/docs/index.html
data/Rakefile CHANGED
@@ -3,4 +3,59 @@
3
3
  require 'bundler'
4
4
  Bundler::GemHelper.install_tasks
5
5
 
6
- load 'lib/tasks/jquery-tablesorter_tasks.rake'
6
+ namespace :jquery_tablesorter do
7
+ desc 'update tablesorter'
8
+ task :update do
9
+ # javascripts
10
+ #
11
+ javascript_dir = 'vendor/assets/javascripts/jquery-tablesorter'
12
+ FileUtils.mkdir_p(javascript_dir)
13
+ Dir.glob('tablesorter/js/*.js').each do |file|
14
+ FileUtils.cp file, javascript_dir, :verbose => true
15
+ end
16
+
17
+ # stylesheets
18
+ #
19
+ stylesheet_dir = 'vendor/assets/stylesheets/jquery-tablesorter'
20
+ FileUtils.mkdir_p(stylesheet_dir)
21
+ Dir.glob('tablesorter/css/*.css').each do |file|
22
+ FileUtils.cp file, stylesheet_dir, :verbose => true
23
+ end
24
+
25
+ # images
26
+ #
27
+ images_dir = 'vendor/assets/images/jquery-tablesorter'
28
+ FileUtils.mkdir_p(images_dir)
29
+ Dir.glob('tablesorter/css/images/*').each do |file|
30
+ FileUtils.cp file, images_dir, :verbose => true
31
+ end
32
+
33
+ # addons
34
+ #
35
+ ## pager
36
+ pager_stylesheet_dir = stylesheet_dir + '/addons/pager'
37
+ FileUtils.mkdir_p(pager_stylesheet_dir)
38
+ FileUtils.cp 'tablesorter/addons/pager/jquery.tablesorter.pager.css',
39
+ pager_stylesheet_dir,
40
+ :verbose => true
41
+
42
+ pager_javascript_dir = javascript_dir + '/addons/pager'
43
+ FileUtils.mkdir_p(pager_javascript_dir)
44
+ FileUtils.cp 'tablesorter/addons/pager/jquery.tablesorter.pager.js',
45
+ pager_javascript_dir,
46
+ :verbose => true
47
+
48
+ pager_images_dir = images_dir + '/addons/pager'
49
+ FileUtils.mkdir_p(pager_images_dir)
50
+ FileUtils.cp_r 'tablesorter/addons/pager/icons', pager_images_dir,
51
+ :verbose => true
52
+ end
53
+
54
+ desc 'Sanitize image paths'
55
+ task :sanitize_image_paths do
56
+ Dir.glob('vendor/assets/stylesheets/jquery-tablesorter/*.css').each do |file_path|
57
+ content = File.read(file_path).gsub(/url\(images\//, "url(/assets/jquery-tablesorter/")
58
+ File.open(file_path, "w") {|file| file.write content}
59
+ end
60
+ end
61
+ end
@@ -1,3 +1,3 @@
1
1
  module JqueryTablesorter
2
- VERSION = "1.0.5"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -1 +1,3 @@
1
- //= require_tree ./jquery-tablesorter
1
+ //= require jquery-tablesorter/jquery.metadata
2
+ //= require jquery-tablesorter/jquery.tablesorter
3
+ //= require jquery-tablesorter/jquery.tablesorter.widgets
@@ -1,420 +1,508 @@
1
- /*!
2
- * tablesorter pager plugin
3
- * updated 5/28/2012
4
- */
5
- ;(function($) {
6
- $.extend({tablesorterPager: new function() {
7
-
8
- this.defaults = {
9
- // target the pager markup
10
- container: null,
11
-
12
- // use this format: "http:/mydatabase.com?page={page}&size={size}"
13
- // where {page} is replaced by the page number and {size} is replaced by the number of records to show
14
- ajaxUrl: null,
15
-
16
- // process ajax so that the following information is returned:
17
- // [ total_rows (number), rows (array of arrays), headers (array; optional) ]
18
- // example:
19
- // [
20
- // 100, // total rows
21
- // [
22
- // [ "row1cell1", "row1cell2", ... "row1cellN" ],
23
- // [ "row2cell1", "row2cell2", ... "row2cellN" ],
24
- // ...
25
- // [ "rowNcell1", "rowNcell2", ... "rowNcellN" ]
26
- // ],
27
- // [ "header1", "header2", ... "headerN" ] // optional
28
- // ]
29
- ajaxProcessing: function(ajax){ return [ 0, [], null ]; },
30
-
31
- // output default: '{page}/{totalPages}'
32
- output: '{startRow} to {endRow} of {totalRows} rows', // '{page}/{totalPages}'
33
-
34
- // apply disabled classname to the pager arrows when the rows at either extreme is visible
35
- updateArrows: true,
36
-
37
- // starting page of the pager (zero based index)
38
- page: 0,
39
-
40
- // Number of visible rows
41
- size: 10,
42
-
43
- // if true, the table will remain the same height no matter how many records are displayed. The space is made up by an empty
44
- // table row set to a height to compensate; default is false
45
- fixedHeight: false,
46
-
47
- // remove rows from the table to speed up the sort of large tables.
48
- // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled.
49
- removeRows: true, // removing rows in larger tables speeds up the sort
50
-
51
- // css class names of pager arrows
52
- cssNext: '.next', // next page arrow
53
- cssPrev: '.prev', // previous page arrow
54
- cssFirst: '.first', // first page arrow
55
- cssLast: '.last', // last page arrow
56
- cssPageDisplay: '.pagedisplay', // location of where the "output" is displayed
57
- cssPageSize: '.pagesize', // page size selector - select dropdown that sets the "size" option
58
-
59
- // class added to arrows when at the extremes (i.e. prev/first arrows are "disabled" when on the first page)
60
- cssDisabled: 'disabled', // Note there is no period "." in front of this class name
61
-
62
- // stuff not set by the user
63
- totalRows: 0,
64
- totalPages: 0
65
-
66
- };
67
-
68
- var $this = this,
69
-
70
- // hide arrows at extremes
71
- pagerArrows = function(c, disable) {
72
- var a = 'addClass', r = 'removeClass',
73
- d = c.cssDisabled, dis = !!disable;
74
- if (c.updateArrows) {
75
- c.container[(c.totalRows < c.size) ? a : r](d);
76
- $(c.cssFirst + ',' + c.cssPrev, c.container)[(dis || c.page === 0) ? a : r](d);
77
- $(c.cssNext + ',' + c.cssLast, c.container)[(dis || c.page === c.totalPages - 1) ? a : r](d);
78
- }
79
- },
80
-
81
- updatePageDisplay = function(table, c) {
82
- if (c.totalPages > 0) {
83
- c.startRow = c.size * (c.page) + 1;
84
- c.endRow = Math.min(c.totalRows, c.size * (c.page+1));
85
- var out = $(c.cssPageDisplay, c.container),
86
- // form the output string
87
- s = c.output.replace(/\{(page|totalPages|startRow|endRow|totalRows)\}/gi, function(m){
88
- return {
89
- '{page}' : c.page + 1,
90
- '{totalPages}' : c.totalPages,
91
- '{startRow}' : c.startRow,
92
- '{endRow}' : c.endRow,
93
- '{totalRows}' : c.totalRows
94
- }[m];
95
- });
96
- if (out[0]) {
97
- out[ (out[0].tagName === 'INPUT') ? 'val' : 'html' ](s);
98
- }
99
- }
100
- pagerArrows(c);
101
- $(table).trigger('pagerComplete', c);
102
- },
103
-
104
- fixHeight = function(table, c) {
105
- var d, h, $b = $(table.tBodies[0]);
106
- if (c.fixedHeight) {
107
- $b.find('tr.pagerSavedHeightSpacer').remove();
108
- h = $.data(table, 'pagerSavedHeight');
109
- if (h) {
110
- d = h - $b.height();
111
- if (d > 5 && $.data(table, 'pagerLastSize') === c.size && $b.find('tr:visible').length < c.size) {
112
- $b.append('<tr class="pagerSavedHeightSpacer remove-me" style="height:' + d + 'px;"></tr>');
113
- }
114
- }
115
- }
116
- },
117
-
118
- changeHeight = function(table, c) {
119
- var $b = $(table.tBodies[0]);
120
- $b.find('tr.pagerSavedHeightSpacer').remove();
121
- $.data(table, 'pagerSavedHeight', $b.height());
122
- fixHeight(table, c);
123
- $.data(table, 'pagerLastSize', c.size);
124
- },
125
-
126
- hideRows = function(table, c){
127
- var i, rows = $('tr:not(.' + table.config.cssChildRow + ')', table.tBodies),
128
- l = rows.length,
129
- s = (c.page * c.size),
130
- e = (s + c.size);
131
- if (e > l) { e = l; }
132
- for (i = 0; i < l; i++){
133
- rows[i].style.display = (i >= s && i < e) ? '' : 'none';
134
- }
135
- },
136
-
137
- hideRowsSetup = function(table, c){
138
- c.size = parseInt($(c.cssPageSize, c.container).val(), 10) || c.size;
139
- $.data(table, 'pagerLastSize', c.size);
140
- pagerArrows(c);
141
- if (!c.removeRows) {
142
- hideRows(table, c);
143
- $(table).bind('sortEnd.pager', function(){
144
- hideRows(table, c);
145
- });
146
- }
147
- },
148
-
149
- renderAjax = function(data, table, c, exception){
150
- // process data
151
- if (typeof(c.ajaxProcessing) === "function") {
152
- // ajaxProcessing result: [ total, rows, headers ]
153
- var i, j, k, hsh, $f, $sh, $t = $(table), $b = $(table.tBodies).filter(':not(.' + table.config.cssInfoBlock + ')'),
154
- hl = $t.find('thead th').length, tds = '',
155
- err = '<tr class="remove-me"><td style="text-align: center;" colspan="' + hl + '">' +
156
- (exception ? exception.message + ' (' + exception.name + ')' : 'No rows found') + '</td></tr>',
157
- result = c.ajaxProcessing(data) || [ 0, [] ],
158
- d = result[1] || [], l = d.length, th = result[2];
159
- if (l > 0) {
160
- for ( i=0; i < l; i++ ) {
161
- tds += '<tr>';
162
- for (j=0; j < d[i].length; j++) {
163
- // build tbody cells
164
- tds += '<td>' + d[i][j] + '</td>';
165
- }
166
- tds += '</tr>';
167
- }
168
- }
169
- // only add new header text if the length matches
170
- if (th && th.length === hl) {
171
- hsh = $t.hasClass('hasStickyHeaders');
172
- $sh = $t.find('.' + ((c.widgetOptions && c.widgetOptions.stickyHeaders) || 'tablesorter-stickyheader'));
173
- $f = $t.find('tfoot tr:first').children();
174
- $t.find('thead tr.tablesorter-header th').each(function(j){
175
- var $t = $(this),
176
- // add new test within the first span it finds, or just in the header
177
- tar = ($t.find('span').length) ? $t.find('span:first') : $t;
178
- tar.html(th[j]);
179
- $f.eq(j).html(th[j]);
180
- // update sticky headers
181
- if (hsh && $sh.length){
182
- tar = $sh.find('th').eq(j);
183
- tar = (tar.find('span').length) ? tar.find('span:first') : tar;
184
- tar.html(th[j]);
185
- }
186
- });
187
- }
188
- if (exception) {
189
- // add error row to thead instead of tbody, or clicking on the header will result in a parser error
190
- $t.find('thead').append(err);
191
- } else {
192
- $b.html(tds); // add tbody
193
- }
194
- c.temp.remove(); // remove loading icon
195
- $t.trigger('update');
196
- c.totalRows = result[0] || 0;
197
- c.totalPages = Math.ceil(c.totalRows / c.size);
198
- updatePageDisplay(table, c);
199
- fixHeight(table, c);
200
- $t.trigger('pagerChange', c);
201
- }
202
- },
203
-
204
- getAjax = function(table, c){
205
- var $t = $(table),
206
- url = c.ajaxUrl.replace(/\{page\}/g, c.page).replace(/\{size\}/g, c.size);
207
- if (url !== '') {
208
- // loading icon
209
- c.temp = $('<div/>', {
210
- id : 'tablesorterPagerLoading',
211
- width : $t.outerWidth(true),
212
- height: $t.outerHeight(true)
213
- });
214
- $t.before(c.temp);
215
- $(document).ajaxError(function(e, xhr, settings, exception) {
216
- renderAjax(null, table, c, exception);
217
- });
218
- $.getJSON(url, function(data) {
219
- renderAjax(data, table, c);
220
- });
221
- }
222
- },
223
-
224
- renderTable = function(table, rows, c) {
225
- var i, j, o,
226
- f = document.createDocumentFragment(),
227
- l = rows.length,
228
- s = (c.page * c.size),
229
- e = (s + c.size);
230
- if (l < 1) { return; } // empty table, abort!
231
- $(table).trigger('pagerChange', c);
232
- if (!c.removeRows) {
233
- hideRows(table, c);
234
- } else {
235
- if (e > rows.length ) {
236
- e = rows.length;
237
- }
238
- $(table.tBodies[0]).addClass('tablesorter-hidden');
239
- $.tablesorter.clearTableBody(table);
240
- for (i = s; i < e; i++) {
241
- o = rows[i];
242
- l = o.length;
243
- for (j = 0; j < l; j++) {
244
- f.appendChild(o[j]);
245
- }
246
- }
247
- table.tBodies[0].appendChild(f);
248
- $(table.tBodies[0]).removeClass('tablesorter-hidden');
249
- }
250
- if ( c.page >= c.totalPages ) {
251
- moveToLastPage(table, c);
252
- }
253
- updatePageDisplay(table, c);
254
- if (!c.isDisabled) { fixHeight(table, c); }
255
- $(table).trigger('applyWidgets');
256
- },
257
-
258
- showAllRows = function(table, c){
259
- if (c.ajax) {
260
- pagerArrows(c, true);
261
- } else {
262
- c.isDisabled = true;
263
- $.data(table, 'pagerLastPage', c.page);
264
- $.data(table, 'pagerLastSize', c.size);
265
- c.page = 0;
266
- c.size = c.totalRows;
267
- c.totalPages = 1;
268
- $('tr.pagerSavedHeightSpacer', table.tBodies[0]).remove();
269
- renderTable(table, table.config.rowsCopy, c);
270
- }
271
- // disable size selector
272
- $(c.cssPageSize, c.container).addClass(c.cssDisabled)[0].disabled = true;
273
- },
274
-
275
- moveToPage = function(table, c) {
276
- if (c.isDisabled) { return; }
277
- if (c.page < 0 || c.page > (c.totalPages-1)) {
278
- c.page = 0;
279
- }
280
- $.data(table, 'pagerLastPage', c.page);
281
- if (c.ajax) {
282
- getAjax(table, c);
283
- } else {
284
- renderTable(table, table.config.rowsCopy, c);
285
- }
286
- },
287
-
288
- setPageSize = function(table, size, c) {
289
- c.size = size;
290
- $.data(table, 'pagerLastPage', c.page);
291
- $.data(table, 'pagerLastSize', c.size);
292
- c.totalPages = Math.ceil(c.totalRows / c.size);
293
- moveToPage(table, c);
294
- },
295
-
296
- moveToFirstPage = function(table, c) {
297
- c.page = 0;
298
- moveToPage(table, c);
299
- },
300
-
301
- moveToLastPage = function(table, c) {
302
- c.page = (c.totalPages-1);
303
- moveToPage(table, c);
304
- },
305
-
306
- moveToNextPage = function(table, c) {
307
- c.page++;
308
- if (c.page >= (c.totalPages-1)) {
309
- c.page = (c.totalPages-1);
310
- }
311
- moveToPage(table, c);
312
- },
313
-
314
- moveToPrevPage = function(table, c) {
315
- c.page--;
316
- if (c.page <= 0) {
317
- c.page = 0;
318
- }
319
- moveToPage(table, c);
320
- },
321
-
322
- destroyPager = function(table, c){
323
- showAllRows(table, c);
324
- c.container.hide(); // hide pager
325
- table.config.appender = null; // remove pager appender function
326
- $(table).unbind('destroy.pager sortEnd.pager enable.pager disable.pager');
327
- },
328
-
329
- enablePager = function(table, c, triggered){
330
- var p = $(c.cssPageSize, c.container).removeClass(c.cssDisabled).removeAttr('disabled');
331
- c.isDisabled = false;
332
- c.page = $.data(table, 'pagerLastPage') || c.page || 0;
333
- c.size = $.data(table, 'pagerLastSize') || parseInt(p.val(), 10) || c.size;
334
- c.totalPages = Math.ceil(c.totalRows / c.size);
335
- if (triggered) {
336
- $(table).trigger('update');
337
- setPageSize(table, c.size, c);
338
- hideRowsSetup(table, c);
339
- fixHeight(table, c);
340
- }
341
- };
342
-
343
- $this.appender = function(table, rows) {
344
- var c = table.config.pager;
345
- if (!c.ajax) {
346
- table.config.rowsCopy = rows;
347
- c.totalRows = rows.length;
348
- c.size = $.data(table, 'pagerLastSize') || c.size;
349
- c.totalPages = Math.ceil(c.totalRows / c.size);
350
- renderTable(table, rows, c);
351
- }
352
- };
353
-
354
- $this.construct = function(settings) {
355
- return this.each(function() {
356
- var config = this.config,
357
- c = config.pager = $.extend({}, $.tablesorterPager.defaults, settings),
358
- table = this,
359
- $t = $(table),
360
- pager = $(c.container).show(); // added in case the pager is reinitialized after being destroyed.
361
- config.appender = $this.appender;
362
- enablePager(table, c, false);
363
- if (typeof(c.ajaxUrl) === 'string') {
364
- // ajax pager; interact with database
365
- c.ajax = true;
366
- getAjax(table, c);
367
- } else {
368
- c.ajax = false;
369
- // Regular pager; all rows stored in memory
370
- $(this).trigger("appendCache", true);
371
- hideRowsSetup(table, c);
372
- }
373
-
374
- $(c.cssFirst,pager).unbind('click.pager').bind('click.pager', function() {
375
- if (!$(this).hasClass(c.cssDisabled)) { moveToFirstPage(table, c); }
376
- return false;
377
- });
378
- $(c.cssNext,pager).unbind('click.pager').bind('click.pager', function() {
379
- if (!$(this).hasClass(c.cssDisabled)) { moveToNextPage(table, c); }
380
- return false;
381
- });
382
- $(c.cssPrev,pager).unbind('click.pager').bind('click.pager', function() {
383
- if (!$(this).hasClass(c.cssDisabled)) { moveToPrevPage(table, c); }
384
- return false;
385
- });
386
- $(c.cssLast,pager).unbind('click.pager').bind('click.pager', function() {
387
- if (!$(this).hasClass(c.cssDisabled)) { moveToLastPage(table, c); }
388
- return false;
389
- });
390
- $(c.cssPageSize,pager).unbind('change.pager').bind('change.pager', function() {
391
- $(c.cssPageSize,pager).val( $(this).val() ); // in case there are more than one pagers
392
- if (!$(this).hasClass(c.cssDisabled)) {
393
- setPageSize(table, parseInt($(this).val(), 10), c);
394
- changeHeight(table, c);
395
- }
396
- return false;
397
- });
398
-
399
- $t
400
- .unbind('disable.pager enable.pager destroy.pager')
401
- .bind('disable.pager', function(){
402
- showAllRows(table, c);
403
- })
404
- .bind('enable.pager', function(){
405
- enablePager(table, c, true);
406
- })
407
- .bind('destroy.pager', function(){
408
- destroyPager(table, c);
409
- });
410
- });
411
- };
412
-
413
- }
414
- });
415
- // extend plugin scope
416
- $.fn.extend({
417
- tablesorterPager: $.tablesorterPager.construct
418
- });
419
-
1
+ /*!
2
+ * tablesorter pager plugin
3
+ * updated 10/25/2012
4
+ */
5
+ /*jshint browser:true, jquery:true */
6
+ ;(function($) {
7
+ "use strict";
8
+ $.extend({tablesorterPager: new function() {
9
+
10
+ this.defaults = {
11
+ // target the pager markup
12
+ container: null,
13
+
14
+ // use this format: "http://mydatabase.com?page={page}&size={size}&{sortList:col}"
15
+ // where {page} is replaced by the page number and {size} is replaced by the number of records to show
16
+ // {sortList:col} adds the sortList to the url into a "col" array.
17
+ // So a sortList = [[2,0],[3,0]] becomes "&col[2]=0&col[3]=0" in the url
18
+ ajaxUrl: null,
19
+
20
+ // process ajax so that the following information is returned:
21
+ // [ total_rows (number), rows (array of arrays), headers (array; optional) ]
22
+ // example:
23
+ // [
24
+ // 100, // total rows
25
+ // [
26
+ // [ "row1cell1", "row1cell2", ... "row1cellN" ],
27
+ // [ "row2cell1", "row2cell2", ... "row2cellN" ],
28
+ // ...
29
+ // [ "rowNcell1", "rowNcell2", ... "rowNcellN" ]
30
+ // ],
31
+ // [ "header1", "header2", ... "headerN" ] // optional
32
+ // ]
33
+ ajaxProcessing: function(ajax){ return [ 0, [], null ]; },
34
+
35
+ // output default: '{page}/{totalPages}'
36
+ // possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows}
37
+ output: '{startRow} to {endRow} of {totalRows} rows', // '{page}/{totalPages}'
38
+
39
+ // apply disabled classname to the pager arrows when the rows at either extreme is visible
40
+ updateArrows: true,
41
+
42
+ // starting page of the pager (zero based index)
43
+ page: 0,
44
+
45
+ // Number of visible rows
46
+ size: 10,
47
+
48
+ // if true, the table will remain the same height no matter how many records are displayed. The space is made up by an empty
49
+ // table row set to a height to compensate; default is false
50
+ fixedHeight: false,
51
+
52
+ // remove rows from the table to speed up the sort of large tables.
53
+ // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled.
54
+ removeRows: false, // removing rows in larger tables speeds up the sort
55
+
56
+ // css class names of pager arrows
57
+ cssFirst: '.first', // go to first page arrow
58
+ cssPrev: '.prev', // previous page arrow
59
+ cssNext: '.next', // next page arrow
60
+ cssLast: '.last', // go to last page arrow
61
+ cssGoto: '.gotoPage', // go to page selector - select dropdown that sets the current page
62
+ cssPageDisplay: '.pagedisplay', // location of where the "output" is displayed
63
+ cssPageSize: '.pagesize', // page size selector - select dropdown that sets the "size" option
64
+
65
+ // class added to arrows when at the extremes (i.e. prev/first arrows are "disabled" when on the first page)
66
+ cssDisabled: 'disabled', // Note there is no period "." in front of this class name
67
+
68
+ // stuff not set by the user
69
+ totalRows: 0,
70
+ totalPages: 0,
71
+ filteredRows: 0,
72
+ filteredPages: 0
73
+
74
+ };
75
+
76
+ var $this = this,
77
+
78
+ // hide arrows at extremes
79
+ pagerArrows = function(c, disable) {
80
+ var a = 'addClass',
81
+ r = 'removeClass',
82
+ d = c.cssDisabled,
83
+ dis = !!disable,
84
+ // tr = Math.min( c.totalRows, c.filteredRows ),
85
+ tp = Math.min( c.totalPages, c.filteredPages );
86
+ if ( c.updateArrows ) {
87
+ $(c.cssFirst + ',' + c.cssPrev, c.container)[ ( dis || c.page === 0 ) ? a : r ](d);
88
+ $(c.cssNext + ',' + c.cssLast, c.container)[ ( dis || c.page === tp - 1 ) ? a : r ](d);
89
+ }
90
+ },
91
+
92
+ updatePageDisplay = function(table, c) {
93
+ var i, p, s, t, out, f = $(table).hasClass('hasFilters');
94
+ c.filteredRows = (f) ? $(table).find('tbody tr:not(.filtered)').length : c.totalRows;
95
+ c.filteredPages = (f) ? Math.ceil( c.filteredRows / c.size ) : c.totalPages;
96
+ if ( Math.min( c.totalPages, c.filteredPages ) > 0 ) {
97
+ t = (c.size * c.page > c.filteredRows);
98
+ c.startRow = (t) ? 1 : ( c.size * c.page ) + 1;
99
+ c.page = (t) ? 0 : c.page;
100
+ c.endRow = Math.min( c.filteredRows, c.totalRows, c.size * ( c.page + 1 ) );
101
+ out = $(c.cssPageDisplay, c.container);
102
+ // form the output string
103
+ s = c.output.replace(/\{(page|filteredRows|filteredPages|totalPages|startRow|endRow|totalRows)\}/gi, function(m){
104
+ return {
105
+ '{page}' : c.page + 1,
106
+ '{filteredRows}' : c.filteredRows,
107
+ '{filteredPages}' : c.filteredPages,
108
+ '{totalPages}' : c.totalPages,
109
+ '{startRow}' : c.startRow,
110
+ '{endRow}' : c.endRow,
111
+ '{totalRows}' : c.totalRows
112
+ }[m];
113
+ });
114
+ if (out[0]) {
115
+ out[ (out[0].tagName === 'INPUT') ? 'val' : 'html' ](s);
116
+ if ( $(c.cssGoto, c.container).length ) {
117
+ t = '';
118
+ p = Math.min( c.totalPages, c.filteredPages );
119
+ for ( i = 1; i <= p; i++ ) {
120
+ t += '<option>' + i + '</option>';
121
+ }
122
+ $(c.cssGoto, c.container).html(t).val(c.page + 1);
123
+ }
124
+ }
125
+ }
126
+ pagerArrows(c);
127
+ if (c.initialized) { $(table).trigger('pagerComplete', c); }
128
+ },
129
+
130
+ fixHeight = function(table, c) {
131
+ var d, h, $b = $(table.tBodies[0]);
132
+ if (c.fixedHeight) {
133
+ $b.find('tr.pagerSavedHeightSpacer').remove();
134
+ h = $.data(table, 'pagerSavedHeight');
135
+ if (h) {
136
+ d = h - $b.height();
137
+ if ( d > 5 && $.data(table, 'pagerLastSize') === c.size && $b.find('tr:visible').length < c.size ) {
138
+ $b.append('<tr class="pagerSavedHeightSpacer remove-me" style="height:' + d + 'px;"></tr>');
139
+ }
140
+ }
141
+ }
142
+ },
143
+
144
+ changeHeight = function(table, c) {
145
+ var $b = $(table.tBodies[0]);
146
+ $b.find('tr.pagerSavedHeightSpacer').remove();
147
+ $.data(table, 'pagerSavedHeight', $b.height());
148
+ fixHeight(table, c);
149
+ $.data(table, 'pagerLastSize', c.size);
150
+ },
151
+
152
+ hideRows = function(table, c){
153
+ if (!c.ajaxUrl) {
154
+ var i,
155
+ rows = $('tr:not(.' + table.config.cssChildRow + ')', table.tBodies),
156
+ l = rows.length,
157
+ s = ( c.page * c.size ),
158
+ e = s + c.size,
159
+ j = 0; // size counter
160
+ for ( i = 0; i < l; i++ ){
161
+ if (!/filtered/.test(rows[i].className)) {
162
+ rows[i].style.display = ( j >= s && j < e ) ? '' : 'none';
163
+ j++;
164
+ }
165
+ }
166
+ }
167
+ },
168
+
169
+ hideRowsSetup = function(table, c){
170
+ c.size = parseInt( $(c.cssPageSize, c.container).find('option[selected]').val(), 10 ) || c.size;
171
+ $.data(table, 'pagerLastSize', c.size);
172
+ pagerArrows(c);
173
+ if ( !c.removeRows ) {
174
+ hideRows(table, c);
175
+ $(table).bind('sortEnd.pager filterEnd.pager', function(){
176
+ hideRows(table, c);
177
+ });
178
+ }
179
+ },
180
+
181
+ renderAjax = function(data, table, c, exception){
182
+ // process data
183
+ if ( typeof(c.ajaxProcessing) === "function" ) {
184
+ // ajaxProcessing result: [ total, rows, headers ]
185
+ var i, j, hsh, $f, $sh,
186
+ $t = $(table),
187
+ tc = table.config,
188
+ $b = $(table.tBodies).filter(':not(.' + tc.cssInfoBlock + ')'),
189
+ hl = $t.find('thead th').length, tds = '',
190
+ err = '<tr class="' + tc.selectorRemove + '"><td style="text-align: center;" colspan="' + hl + '">' +
191
+ (exception ? exception.message + ' (' + exception.name + ')' : 'No rows found') + '</td></tr>',
192
+ result = c.ajaxProcessing(data) || [ 0, [] ],
193
+ d = result[1] || [],
194
+ l = d.length,
195
+ th = result[2];
196
+ if ( l > 0 ) {
197
+ for ( i = 0; i < l; i++ ) {
198
+ tds += '<tr>';
199
+ for ( j = 0; j < d[i].length; j++ ) {
200
+ // build tbody cells
201
+ tds += '<td>' + d[i][j] + '</td>';
202
+ }
203
+ tds += '</tr>';
204
+ }
205
+ }
206
+ // only add new header text if the length matches
207
+ if ( th && th.length === hl ) {
208
+ hsh = $t.hasClass('hasStickyHeaders');
209
+ $sh = $t.find('.' + ((tc.widgetOptions && tc.widgetOptions.stickyHeaders) || 'tablesorter-stickyheader'));
210
+ $f = $t.find('tfoot tr:first').children();
211
+ $t.find('th.' + tc.cssHeader).each(function(j){
212
+ var $t = $(this), icn;
213
+ // add new test within the first span it finds, or just in the header
214
+ if ( $t.find('.' + tc.cssIcon).length ) {
215
+ icn = $t.find('.' + tc.cssIcon).clone(true);
216
+ $t.find('.tablesorter-header-inner').html( th[j] ).append(icn);
217
+ if ( hsh && $sh.length ) {
218
+ icn = $sh.find('th').eq(j).find('.' + tc.cssIcon).clone(true);
219
+ $sh.find('th').eq(j).find('.tablesorter-header-inner').html( th[j] ).append(icn);
220
+ }
221
+ } else {
222
+ $t.find('.tablesorter-header-inner').html( th[j] );
223
+ $sh.find('th').eq(j).find('.tablesorter-header-inner').html( th[j] );
224
+ }
225
+ $f.eq(j).html( th[j] );
226
+ });
227
+ }
228
+ if ( exception ) {
229
+ // add error row to thead instead of tbody, or clicking on the header will result in a parser error
230
+ $t.find('thead').append(err);
231
+ } else {
232
+ $b.html( tds ); // add tbody
233
+ }
234
+ c.temp.remove(); // remove loading icon
235
+ $t.trigger('update');
236
+ c.totalRows = result[0] || 0;
237
+ c.totalPages = Math.ceil( c.totalRows / c.size );
238
+ updatePageDisplay(table, c);
239
+ fixHeight(table, c);
240
+ if (c.initialized) { $t.trigger('pagerChange', c); }
241
+ }
242
+ if (!c.initialized) {
243
+ c.initialized = true;
244
+ $(table).trigger('pagerInitialized', c);
245
+ }
246
+ },
247
+
248
+ getAjax = function(table, c){
249
+ var $t = $(table),
250
+ url = (c.ajaxUrl) ? c.ajaxUrl.replace(/\{page\}/g, c.page).replace(/\{size\}/g, c.size) : '',
251
+ arry = [],
252
+ sl = table.config.sortList,
253
+ col = url.match(/\{sortList[\s+]?:[\s+]?(.*)\}/);
254
+ if (col) {
255
+ col = col[1];
256
+ $.each(sl, function(i,v){
257
+ arry.push(col + '[' + v[0] + ']=' + v[1]);
258
+ });
259
+ // if the arry is empty, just add the col parameter... "&{sortList:col}" becomes "&col"
260
+ url = url.replace(/\{sortList[\s+]?:[\s+]?(.*)\}/g, arry.length ? arry.join('&') : col );
261
+ }
262
+ if ( url !== '' ) {
263
+ // loading icon
264
+ c.temp = $('<div/>', {
265
+ 'class' : 'tablesorter-processing',
266
+ width : $t.outerWidth(true),
267
+ height: $t.outerHeight(true)
268
+ });
269
+ $t.before( c.temp );
270
+ $(document).ajaxError(function(e, xhr, settings, exception) {
271
+ renderAjax(null, table, c, exception);
272
+ });
273
+ $.getJSON(url, function(data) {
274
+ renderAjax(data, table, c);
275
+ });
276
+ }
277
+ },
278
+
279
+ renderTable = function(table, rows, c) {
280
+ var i, j, o,
281
+ f = document.createDocumentFragment(),
282
+ l = rows.length,
283
+ s = ( c.page * c.size ),
284
+ e = ( s + c.size );
285
+ if ( l < 1 ) { return; } // empty table, abort!
286
+ if (c.initialized) { $(table).trigger('pagerChange', c); }
287
+ if ( !c.removeRows ) {
288
+ hideRows(table, c);
289
+ } else {
290
+ if ( e > rows.length ) {
291
+ e = rows.length;
292
+ }
293
+ $(table.tBodies[0]).addClass('tablesorter-hidden');
294
+ $.tablesorter.clearTableBody(table);
295
+ for ( i = s; i < e; i++ ) {
296
+ o = rows[i];
297
+ l = o.length;
298
+ for ( j = 0; j < l; j++ ) {
299
+ f.appendChild(o[j]);
300
+ }
301
+ }
302
+ table.tBodies[0].appendChild(f);
303
+ $(table.tBodies[0]).removeClass('tablesorter-hidden');
304
+ }
305
+ if ( c.page >= c.totalPages ) {
306
+ moveToLastPage(table, c);
307
+ }
308
+ updatePageDisplay(table, c);
309
+ if ( !c.isDisabled ) { fixHeight(table, c); }
310
+ $(table).trigger('applyWidgets');
311
+ },
312
+
313
+ showAllRows = function(table, c){
314
+ if ( c.ajax ) {
315
+ pagerArrows(c, true);
316
+ } else {
317
+ c.isDisabled = true;
318
+ $.data(table, 'pagerLastPage', c.page);
319
+ $.data(table, 'pagerLastSize', c.size);
320
+ c.page = 0;
321
+ c.size = c.totalRows;
322
+ c.totalPages = 1;
323
+ $('tr.pagerSavedHeightSpacer', table.tBodies[0]).remove();
324
+ renderTable(table, table.config.rowsCopy, c);
325
+ }
326
+ // disable size selector
327
+ $(c.container).find(c.cssPageSize + ',' + c.cssGoto).each(function(){
328
+ $(this).addClass(c.cssDisabled)[0].disabled = true;
329
+ });
330
+ },
331
+
332
+ moveToPage = function(table, c) {
333
+ if ( c.isDisabled ) { return; }
334
+ var p = Math.min( c.totalPages, c.filteredPages );
335
+ if ( c.page < 0 || c.page > ( p - 1 ) ) {
336
+ c.page = 0;
337
+ }
338
+ $.data(table, 'pagerLastPage', c.page);
339
+ if ( c.ajax ) {
340
+ getAjax(table, c);
341
+ } else {
342
+ renderTable(table, table.config.rowsCopy, c);
343
+ }
344
+ if (c.initialized) { $(table).trigger('pageMoved', c); }
345
+ },
346
+
347
+ setPageSize = function(table, size, c) {
348
+ c.size = size;
349
+ $.data(table, 'pagerLastPage', c.page);
350
+ $.data(table, 'pagerLastSize', c.size);
351
+ c.totalPages = Math.ceil( c.totalRows / c.size );
352
+ moveToPage(table, c);
353
+ },
354
+
355
+ moveToFirstPage = function(table, c) {
356
+ c.page = 0;
357
+ moveToPage(table, c);
358
+ },
359
+
360
+ moveToLastPage = function(table, c) {
361
+ c.page = ( Math.min( c.totalPages, c.filteredPages ) - 1 );
362
+ moveToPage(table, c);
363
+ },
364
+
365
+ moveToNextPage = function(table, c) {
366
+ c.page++;
367
+ if ( c.page >= ( Math.min( c.totalPages, c.filteredPages ) - 1 ) ) {
368
+ c.page = ( Math.min( c.totalPages, c.filteredPages ) - 1 );
369
+ }
370
+ moveToPage(table, c);
371
+ },
372
+
373
+ moveToPrevPage = function(table, c) {
374
+ c.page--;
375
+ if ( c.page <= 0 ) {
376
+ c.page = 0;
377
+ }
378
+ moveToPage(table, c);
379
+ },
380
+
381
+ destroyPager = function(table, c){
382
+ showAllRows(table, c);
383
+ $(c.container).hide(); // hide pager
384
+ table.config.appender = null; // remove pager appender function
385
+ $(table).unbind('destroy.pager sortEnd.pager filterEnd.pager enable.pager disable.pager');
386
+ },
387
+
388
+ enablePager = function(table, c, triggered){
389
+ var p = $(c.cssPageSize, c.container).removeClass(c.cssDisabled).removeAttr('disabled');
390
+ c.isDisabled = false;
391
+ c.page = $.data(table, 'pagerLastPage') || c.page || 0;
392
+ c.size = $.data(table, 'pagerLastSize') || parseInt(p.find('option[selected]').val(), 10) || c.size;
393
+ p.val(c.size); // set page size
394
+ c.totalPages = Math.ceil( Math.min( c.totalPages, c.filteredPages ) / c.size);
395
+ if ( triggered ) {
396
+ $(table).trigger('update');
397
+ setPageSize(table, c.size, c);
398
+ hideRowsSetup(table, c);
399
+ fixHeight(table, c);
400
+ }
401
+ };
402
+
403
+ $this.appender = function(table, rows) {
404
+ var c = table.config.pager;
405
+ if ( !c.ajax ) {
406
+ table.config.rowsCopy = rows;
407
+ c.totalRows = rows.length;
408
+ c.size = $.data(table, 'pagerLastSize') || c.size;
409
+ c.totalPages = Math.ceil(c.totalRows / c.size);
410
+ renderTable(table, rows, c);
411
+ }
412
+ };
413
+
414
+ $this.construct = function(settings) {
415
+ return this.each(function() {
416
+ var config = this.config,
417
+ c = config.pager = $.extend( {}, $.tablesorterPager.defaults, settings ),
418
+ table = this,
419
+ $t = $(table),
420
+ pager = $(c.container).addClass('tablesorter-pager').show(); // added in case the pager is reinitialized after being destroyed.
421
+ config.appender = $this.appender;
422
+ // clear initialized flag
423
+ c.initialized = false;
424
+ enablePager(table, c, false);
425
+ if ( typeof(c.ajaxUrl) === 'string' ) {
426
+ // ajax pager; interact with database
427
+ c.ajax = true;
428
+ getAjax(table, c);
429
+ } else {
430
+ c.ajax = false;
431
+ // Regular pager; all rows stored in memory
432
+ $(this).trigger("appendCache", true);
433
+ hideRowsSetup(table, c);
434
+ }
435
+
436
+ // update pager after filter widget completes
437
+ $(table)
438
+ .unbind('filterEnd.pager updateComplete.pager ')
439
+ .bind('filterEnd.pager updateComplete.pager', function() {
440
+ c.page = 0;
441
+ updatePageDisplay(table, c);
442
+ moveToPage(table, c);
443
+ changeHeight(table, c);
444
+ });
445
+
446
+ if ( $(c.cssGoto, pager).length ) {
447
+ $(c.cssGoto, pager).bind('change', function(){
448
+ c.page = $(this).val() - 1;
449
+ moveToPage(table, c);
450
+ });
451
+ updatePageDisplay(table, c);
452
+ }
453
+ $(c.cssFirst,pager).unbind('click.pager').bind('click.pager', function() {
454
+ if ( !$(this).hasClass(c.cssDisabled) ) { moveToFirstPage(table, c); }
455
+ return false;
456
+ });
457
+ $(c.cssNext,pager).unbind('click.pager').bind('click.pager', function() {
458
+ if ( !$(this).hasClass(c.cssDisabled) ) { moveToNextPage(table, c); }
459
+ return false;
460
+ });
461
+ $(c.cssPrev,pager).unbind('click.pager').bind('click.pager', function() {
462
+ if ( !$(this).hasClass(c.cssDisabled) ) { moveToPrevPage(table, c); }
463
+ return false;
464
+ });
465
+ $(c.cssLast,pager).unbind('click.pager').bind('click.pager', function() {
466
+ if ( !$(this).hasClass(c.cssDisabled) ) { moveToLastPage(table, c); }
467
+ return false;
468
+ });
469
+ $(c.cssPageSize,pager).unbind('change.pager').bind('change.pager', function() {
470
+ $(c.cssPageSize,pager).val( $(this).val() ); // in case there are more than one pagers
471
+ if ( !$(this).hasClass(c.cssDisabled) ) {
472
+ setPageSize(table, parseInt( $(this).val(), 10 ), c);
473
+ changeHeight(table, c);
474
+ }
475
+ return false;
476
+ });
477
+
478
+ $t
479
+ .unbind('disable.pager enable.pager destroy.pager update.pager')
480
+ .bind('disable.pager', function(){
481
+ showAllRows(table, c);
482
+ })
483
+ .bind('enable.pager', function(){
484
+ enablePager(table, c, true);
485
+ })
486
+ .bind('destroy.pager', function(){
487
+ destroyPager(table, c);
488
+ })
489
+ .bind('update.pager', function(){
490
+ hideRows(table, c);
491
+ });
492
+
493
+ // pager initialized
494
+ if (!c.ajax) {
495
+ c.initialized = true;
496
+ $(table).trigger('pagerInitialized', c);
497
+ }
498
+ });
499
+ };
500
+
501
+ }()
502
+ });
503
+ // extend plugin scope
504
+ $.fn.extend({
505
+ tablesorterPager: $.tablesorterPager.construct
506
+ });
507
+
420
508
  })(jQuery);