jquery-tablesorter 1.11.2 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/jquery-tablesorter/version.rb +1 -1
  4. data/vendor/assets/images/jquery-tablesorter/bootstrap-black-unsorted.png +0 -0
  5. data/vendor/assets/images/jquery-tablesorter/bootstrap-white-unsorted.png +0 -0
  6. data/vendor/assets/images/jquery-tablesorter/metro-black-asc.png +0 -0
  7. data/vendor/assets/images/jquery-tablesorter/metro-black-desc.png +0 -0
  8. data/vendor/assets/images/jquery-tablesorter/metro-loading.gif +0 -0
  9. data/vendor/assets/images/jquery-tablesorter/metro-unsorted.png +0 -0
  10. data/vendor/assets/images/jquery-tablesorter/metro-white-asc.png +0 -0
  11. data/vendor/assets/images/jquery-tablesorter/metro-white-desc.png +0 -0
  12. data/vendor/assets/javascripts/jquery-tablesorter/addons/pager/jquery.tablesorter.pager.js +8 -3
  13. data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.js +94 -29
  14. data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.widgets.js +103 -67
  15. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-columnSelector.js +18 -7
  16. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-cssStickyHeaders.js +10 -7
  17. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-math.js +64 -25
  18. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-output.js +45 -21
  19. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-pager.js +9 -4
  20. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-print.js +122 -0
  21. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-scroller.js +3 -3
  22. data/vendor/assets/stylesheets/jquery-tablesorter/theme.bootstrap.css +9 -3
  23. data/vendor/assets/stylesheets/jquery-tablesorter/theme.green.css +10 -10
  24. data/vendor/assets/stylesheets/jquery-tablesorter/theme.metro-dark.css +192 -0
  25. metadata +12 -2
@@ -1,4 +1,4 @@
1
- /* Column Selector/Responsive table widget (beta) for TableSorter 3/31/2014 (v2.15.12)
1
+ /* Column Selector/Responsive table widget (beta) for TableSorter 5/22/2014 (v2.17.0)
2
2
  * Requires tablesorter v2.8+ and jQuery 1.7+
3
3
  * by Justin Hallett & Rob Garrison
4
4
  */
@@ -12,7 +12,7 @@ namespace = '.tscolsel',
12
12
  tsColSel = ts.columnSelector = {
13
13
 
14
14
  queryAll : '@media only all { [columns] { display: none; } }',
15
- queryBreak : '@media screen and (min-width: [size]) { [columns] { display: table-cell; } }',
15
+ queryBreak : '@media all and (min-width: [size]) { [columns] { display: table-cell; } }',
16
16
 
17
17
  init: function(table, c, wo) {
18
18
  var $t, colSel;
@@ -47,6 +47,15 @@ tsColSel = ts.columnSelector = {
47
47
  tsColSel.updateCols(c, wo);
48
48
  }
49
49
 
50
+ c.$table
51
+ .off('refreshColumnSelector' + namespace)
52
+ .on('refreshColumnSelector' + namespace, function(){
53
+ // make sure we're using current config settings
54
+ var c = this.config;
55
+ tsColSel.updateBreakpoints(c, c.widgetOptions);
56
+ tsColSel.updateCols(c, c.widgetOptions);
57
+ });
58
+
50
59
  },
51
60
 
52
61
  setupSelector: function(table, c, wo) {
@@ -114,10 +123,12 @@ tsColSel = ts.columnSelector = {
114
123
  colSel.lastIndex = -1;
115
124
  wo.columnSelector_breakpoints.sort();
116
125
  tsColSel.updateBreakpoints(c, wo);
117
- c.$table.off('updateAll' + namespace).on('updateAll' + namespace, function(){
118
- tsColSel.updateBreakpoints(c, wo);
119
- tsColSel.updateCols(c, wo);
120
- });
126
+ c.$table
127
+ .off('updateAll' + namespace)
128
+ .on('updateAll' + namespace, function(){
129
+ tsColSel.updateBreakpoints(c, wo);
130
+ tsColSel.updateCols(c, wo);
131
+ });
121
132
  }
122
133
 
123
134
  if (colSel.$container.length) {
@@ -295,7 +306,7 @@ ts.addWidget({
295
306
  remove: function(table, c){
296
307
  var csel = c.selector;
297
308
  csel.$container.empty();
298
- csel.$popup.empty();
309
+ if (csel.$popup) { csel.$popup.empty(); }
299
310
  csel.$style.remove();
300
311
  csel.$breakpoints.remove();
301
312
  c.$table.off('updateAll' + namespace + ' update' + namespace);
@@ -1,4 +1,4 @@
1
- /*! tablesorter CSS Sticky Headers widget - updated 12/17/2013 (v2.15.0)
1
+ /*! tablesorter CSS Sticky Headers widget - updated 5/5/2014 (v2.16.4)
2
2
  * Requires a modern browser, tablesorter v2.8+
3
3
  */
4
4
  /*jshint jquery:true, unused:false */
@@ -9,10 +9,11 @@
9
9
  id: "cssStickyHeaders",
10
10
  priority: 10,
11
11
  options: {
12
- cssStickyHeaders_offset : 0,
13
- cssStickyHeaders_addCaption : false,
14
- cssStickyHeaders_attachTo : null,
15
- cssStickyHeaders_zIndex : 10
12
+ cssStickyHeaders_offset : 0,
13
+ cssStickyHeaders_addCaption : false,
14
+ cssStickyHeaders_attachTo : null,
15
+ cssStickyHeaders_filteredToTop : true,
16
+ cssStickyHeaders_zIndex : 10
16
17
  },
17
18
  init : function(table, thisWidget, c, wo) {
18
19
  var $attach = $(wo.cssStickyHeaders_attachTo),
@@ -44,8 +45,10 @@
44
45
  });
45
46
  });
46
47
  c.$table.bind('filterEnd', function() {
47
- // scroll top of table into view
48
- window.scrollTo(0, c.$table.position().top);
48
+ if (wo.cssStickyHeaders_filteredToTop) {
49
+ // scroll top of table into view
50
+ window.scrollTo(0, c.$table.position().top);
51
+ }
49
52
  });
50
53
 
51
54
  },
@@ -1,4 +1,4 @@
1
- /*! tablesorter math widget - beta - updated 4/27/2014 (v2.16.2)
1
+ /*! tablesorter math widget - beta - updated 5/22/2014 (v2.17.0)
2
2
  * Requires tablesorter v2.16+ and jQuery 1.7+
3
3
  * by Rob Garrison
4
4
  */
@@ -96,7 +96,7 @@
96
96
  },
97
97
 
98
98
  recalculate : function(table, c, wo, init){
99
- if (c && !wo.math_isUpdating) {
99
+ if (c && (!wo.math_isUpdating || init)) {
100
100
 
101
101
  // add data-column attributes to all table cells
102
102
  if (init) {
@@ -150,7 +150,7 @@
150
150
 
151
151
  output : function($cell, wo, value, arry) {
152
152
  // get mask from cell data-attribute: data-math-mask="#,##0.00"
153
- var result = ts.formatMask( $cell.attr('data-' + wo.math_data + '-mask') || wo.math_mask, value );
153
+ var result = ts.formatMask( $cell.attr('data-' + wo.math_data + '-mask') || wo.math_mask, value, wo.math_wrapPrefix, wo.math_wrapSuffix );
154
154
  if ($.isFunction(wo.math_complete)) {
155
155
  result = wo.math_complete($cell, wo, result, value, arry);
156
156
  }
@@ -169,20 +169,52 @@
169
169
  * (c)2011 ecava
170
170
  * Dual licensed under the MIT or GPL Version 2 licenses.
171
171
  */
172
- ts.formatMask = function(m, v){
173
- var isNegative, result, decimal, group, pos_lead_zero, pos_trail_zero, pos_separator, part, szSep,
174
- integer, str, offset, i, l;
172
+ ts.formatMask = function(m, v, tmpPrefix, tmpSuffix){
175
173
  if ( !m || isNaN(+v) ) {
176
174
  return v; // return as it is.
177
175
  }
176
+
177
+ var isNegative, result, decimal, group, posLeadZero, posTrailZero, posSeparator, part, szSep,
178
+ integer, str, offset, i, l, len, start, tmp, end, inv,
179
+ prefix = '',
180
+ suffix = '';
181
+
182
+ // find prefix/suffix
183
+ len = m.length;
184
+ start = m.search( /[0-9\-\+#]/ );
185
+ tmp = start > 0 ? m.substring(0, start) : '';
186
+ prefix = tmp;
187
+ if ( start > 0 && tmpPrefix ) {
188
+ if ( /\{content\}/.test(tmpPrefix || '') ) {
189
+ prefix = (tmpPrefix || '').replace(/\{content\}/g, tmp || '');
190
+ } else {
191
+ prefix = (tmpPrefix || '') + tmp;
192
+ }
193
+ }
194
+ // reverse string: not an ideal method if there are surrogate pairs
195
+ inv = m.split('').reverse().join('');
196
+ end = inv.search( /[0-9\-\+#]/ );
197
+ i = len - end;
198
+ i += (m.substring( i, i + 1 ) === '.') ? 1 : 0;
199
+ tmp = end > 0 ? m.substring( i, len) : '';
200
+ suffix = tmp;
201
+ if (tmp !== '' && tmpSuffix) {
202
+ if ( /\{content\}/.test(tmpSuffix || '') ) {
203
+ suffix = (tmpSuffix || '').replace(/\{content\}/g, tmp || '');
204
+ } else {
205
+ suffix = tmp + (tmpSuffix || '');
206
+ }
207
+ }
208
+ m = m.substring(start, i);
209
+
178
210
  // convert any string to number according to formation sign.
179
- v = m.charAt(0) == '-'? -v : +v;
211
+ v = m.charAt(0) == '-' ? -v : +v;
180
212
  isNegative = v < 0 ? v = -v : 0; // process only abs(), and turn on flag.
181
213
 
182
214
  // search for separator for grp & decimal, anything not digit, not +/- sign, not #.
183
- result = m.match(/[^\d\-\+#]/g);
184
- decimal = (result && result[result.length-1]) || '.'; // treat the right most symbol as decimal
185
- group = (result && result[1] && result[0]) || ','; // treat the left most symbol as group separator
215
+ result = m.match( /[^\d\-\+#]/g );
216
+ decimal = ( result && result[result.length-1] ) || '.'; // treat the right most symbol as decimal
217
+ group = ( result && result[1] && result[0] ) || ','; // treat the left most symbol as group separator
186
218
 
187
219
  // split the decimal for the format string if any.
188
220
  m = m.split( decimal );
@@ -191,18 +223,18 @@
191
223
  v = +(v) + ''; // convert number to string to trim off *all* trailing decimal zero(es)
192
224
 
193
225
  // fill back any trailing zero according to format
194
- pos_trail_zero = m[1] && m[1].lastIndexOf('0'); // look for last zero in format
226
+ posTrailZero = m[1] && m[1].lastIndexOf('0'); // look for last zero in format
195
227
  part = v.split('.');
196
228
  // integer will get !part[1]
197
- if ( !part[1] || part[1] && part[1].length <= pos_trail_zero ) {
198
- v = (+v).toFixed( pos_trail_zero + 1 );
229
+ if ( !part[1] || ( part[1] && part[1].length <= posTrailZero ) ) {
230
+ v = (+v).toFixed( posTrailZero + 1 );
199
231
  }
200
232
  szSep = m[0].split( group ); // look for separator
201
233
  m[0] = szSep.join(''); // join back without separator for counting the pos of any leading 0.
202
234
 
203
- pos_lead_zero = m[0] && m[0].indexOf('0');
204
- if ( pos_lead_zero > -1 ) {
205
- while ( part[0].length < ( m[0].length - pos_lead_zero ) ) {
235
+ posLeadZero = m[0] && m[0].indexOf('0');
236
+ if ( posLeadZero > -1 ) {
237
+ while ( part[0].length < ( m[0].length - posLeadZero ) ) {
206
238
  part[0] = '0' + part[0];
207
239
  }
208
240
  } else if ( +part[0] === 0 ) {
@@ -214,16 +246,17 @@
214
246
 
215
247
  // process the first group separator from decimal (.) only, the rest ignore.
216
248
  // get the length of the last slice of split result.
217
- pos_separator = ( szSep[1] && szSep[ szSep.length - 1 ].length );
218
- if (pos_separator) {
249
+ posSeparator = ( szSep[1] && szSep[ szSep.length - 1 ].length );
250
+ if ( posSeparator ) {
219
251
  integer = v[0];
220
252
  str = '';
221
- offset = integer.length % pos_separator;
253
+ offset = integer.length % posSeparator;
222
254
  l = integer.length;
223
255
  for ( i = 0; i < l; i++ ) {
224
256
  str += integer.charAt(i); // ie6 only support charAt for sz.
225
- // -pos_separator so that won't trail separator on full length
226
- if ( !(( i - offset + 1 ) % pos_separator) && i < l - pos_separator ) {
257
+ // -posSeparator so that won't trail separator on full length
258
+ /*jshint -W018 */
259
+ if ( !( ( i - offset + 1 ) % posSeparator ) && i < l - posSeparator ) {
227
260
  str += group;
228
261
  }
229
262
  }
@@ -231,7 +264,8 @@
231
264
  }
232
265
 
233
266
  v[1] = ( m[1] && v[1] ) ? decimal + v[1] : "";
234
- return ( isNegative ? '-' : '' ) + v[0] + v[1]; // put back any negation and combine integer and fraction.
267
+ // put back any negation, combine integer and fraction, and add back prefix & suffix
268
+ return prefix + ( ( isNegative ? '-' : '' ) + v[0] + v[1] ) + suffix;
235
269
  };
236
270
 
237
271
  ts.equations = {
@@ -332,13 +366,18 @@
332
366
  // complete executed after each fucntion
333
367
  math_complete : null, // function($cell, wo, result, value, arry){ return result; },
334
368
  // order of calculation; "all" is last
335
- math_priority : [ 'row', 'above', 'col' ]
369
+ math_priority : [ 'row', 'above', 'col' ],
370
+ // template for or just prepend the mask prefix & suffix with this HTML
371
+ // e.g. '<span class="red">{content}</span>'
372
+ math_prefix : '',
373
+ math_suffix : ''
336
374
  },
337
375
  init : function(table, thisWidget, c, wo){
338
376
  c.$table
339
377
  .bind('tablesorter-initialized update updateRows addRows updateCell filterReset filterEnd '.split(' ').join('.tsmath '), function(e){
340
- if (!wo.math_isUpdating) {
341
- math.recalculate(table, c, wo, e.type === 'tablesorter-initialized');
378
+ var init = e.type === 'tablesorter-initialized';
379
+ if (!wo.math_isUpdating || init) {
380
+ math.recalculate( table, c, wo, init );
342
381
  }
343
382
  })
344
383
  .bind('updateComplete.tsmath', function(){
@@ -1,4 +1,4 @@
1
- /* Output widget (beta) for TableSorter 4/14/2014 (v2.16.0)
1
+ /* Output widget (beta) for TableSorter 5/22/2014 (v2.17.0)
2
2
  * Requires tablesorter v2.8+ and jQuery 1.7+
3
3
  * Modified from:
4
4
  * HTML Table to CSV: http://www.kunalbabre.com/projects/table2CSV.php (License unknown?)
@@ -42,8 +42,8 @@ output = ts.output = {
42
42
  var $this, row, col, rowlen, collen, txt,
43
43
  wo = c.widgetOptions,
44
44
  tmpRow = [],
45
+ dupe = wo.output_duplicateSpans,
45
46
  addSpanIndex = isHeader && isJSON && wo.output_headerRows && $.isFunction(wo.output_callbackJSON),
46
- rowIndex = 0,
47
47
  cellIndex = 0;
48
48
  $rows.each(function(rowIndex) {
49
49
  if (!tmpRow[rowIndex]) { tmpRow[rowIndex] = []; }
@@ -56,7 +56,7 @@ output = ts.output = {
56
56
  txt = output.formatData( wo, $this.attr(wo.output_dataAttrib) || $this.html(), isHeader );
57
57
  for (row = 1; row <= rowlen; row++) {
58
58
  if (!tmpRow[rowIndex + row]) { tmpRow[rowIndex + row] = []; }
59
- tmpRow[rowIndex + row][cellIndex] = txt;
59
+ tmpRow[rowIndex + row][cellIndex] = isHeader ? txt : dupe ? txt : '';
60
60
  }
61
61
  }
62
62
  // process colspans
@@ -70,11 +70,11 @@ output = ts.output = {
70
70
  for (row = 0; row < rowlen; row++) {
71
71
  if (!tmpRow[rowIndex + row]) { tmpRow[rowIndex + row] = []; }
72
72
  tmpRow[rowIndex + row][cellIndex + col] = addSpanIndex ?
73
- wo.output_callbackJSON($this, txt, cellIndex + col) || txt + '(' + (cellIndex + col) + ')' : txt;
73
+ wo.output_callbackJSON($this, txt, cellIndex + col) || txt + '(' + (cellIndex + col) + ')' : isHeader ? txt : dupe ? txt : '';
74
74
  }
75
75
  } else {
76
76
  tmpRow[rowIndex][cellIndex + col] = addSpanIndex ?
77
- wo.output_callbackJSON($this, txt, cellIndex + col) || txt + '(' + (cellIndex + col) + ')' : txt;
77
+ wo.output_callbackJSON($this, txt, cellIndex + col) || txt + '(' + (cellIndex + col) + ')' : isHeader ? txt : dupe ? txt : '';
78
78
  }
79
79
  }
80
80
  }
@@ -82,7 +82,7 @@ output = ts.output = {
82
82
  // don't include hidden columns
83
83
  if ( $this.css('display') !== 'none' ) {
84
84
  // skip column if already defined
85
- while (tmpRow[rowIndex][cellIndex]) { cellIndex++; }
85
+ while (typeof tmpRow[rowIndex][cellIndex] !== 'undefined') { cellIndex++; }
86
86
  tmpRow[rowIndex][cellIndex] = tmpRow[rowIndex][cellIndex] ||
87
87
  output.formatData( wo, $this.attr(wo.output_dataAttrib) || $this.html(), isHeader );
88
88
  cellIndex++;
@@ -92,6 +92,16 @@ output = ts.output = {
92
92
  return tmpRow;
93
93
  },
94
94
 
95
+ ignoreColumns : function(wo, data) {
96
+ // ignore columns -> remove data from built array (because we've already processed any rowspan/colspan)
97
+ $.each( data, function(indx, val){
98
+ data[indx] = $.grep(val, function(v, cellIndx){
99
+ return $.inArray(cellIndx, wo.output_ignoreColumns) < 0;
100
+ });
101
+ });
102
+ return data;
103
+ },
104
+
95
105
  process : function(c, wo) {
96
106
  var mydata, $this, $rows, headers, csvData, len,
97
107
  hasStringify = window.JSON && JSON.hasOwnProperty('stringify'),
@@ -118,23 +128,30 @@ output = ts.output = {
118
128
  csvData = output.processRow(c, $rows);
119
129
  len = headers.length;
120
130
 
131
+ if (wo.output_ignoreColumns.length) {
132
+ headers = output.ignoreColumns(wo, headers);
133
+ csvData = output.ignoreColumns(wo, csvData);
134
+ }
135
+
121
136
  if (outputJSON) {
122
137
  tmpData = [];
123
138
  $.each( csvData, function(indx, val){
124
139
  // multiple header rows & output_headerRows = true, pick the last row...
125
140
  tmpData.push( output.row2Hash( headers[ (len > 1 && wo.output_headerRows) ? indx % len : len - 1], val ) );
126
141
  });
142
+
127
143
  // requires JSON stringify; if it doesn't exist, the output will show [object Object],... in the output window
128
144
  mydata = hasStringify ? JSON.stringify(tmpData) : tmpData;
129
145
  } else {
130
146
  tmpData = output.row2CSV(wo, wo.output_headerRows ? headers : [ headers[ (len > 1 && wo.output_headerRows) ? indx % len : len - 1] ], outputArray)
131
147
  .concat( output.row2CSV(wo, csvData, outputArray) );
148
+
132
149
  // stringify the array; if stringify doesn't exist the array will be flattened
133
150
  mydata = outputArray && hasStringify ? JSON.stringify(tmpData) : tmpData.join('\n');
134
151
  }
135
152
 
136
153
  // callback; if true returned, continue processing
137
- if (!wo.output_callback(mydata)) { return; }
154
+ if ($.isFunction(wo.output_callback) && !wo.output_callback(c, mydata)) { return; }
138
155
 
139
156
  if ( /p/.test( (wo.output_delivery || '').toLowerCase() ) ) {
140
157
  output.popup(mydata, wo.output_popupStyle, outputJSON || outputArray);
@@ -206,7 +223,7 @@ output = ts.output = {
206
223
  // modified from https://github.com/PixelsCommander/Download-File-JS
207
224
  download : function (wo, data){
208
225
  var e, link,
209
- processedData = 'data:text/csv;charset=utf8,' + encodeURIComponent(data);
226
+ processedData = wo.output_encoding + encodeURIComponent(data);
210
227
 
211
228
  // iOS devices do not support downloading. We have to inform user about this.
212
229
  if (/(iP)/g.test(navigator.userAgent)) {
@@ -242,23 +259,30 @@ output = ts.output = {
242
259
  ts.addWidget({
243
260
  id: "output",
244
261
  options: {
245
- output_separator : ',', // set to "json", "array" or any separator
246
- output_dataAttrib : 'data-name', // header attrib containing modified header name
247
- output_headerRows : false, // if true, include multiple header rows (JSON only)
248
- output_delivery : 'popup', // popup, download
249
- output_saveRows : 'filtered', // all, visible or filtered
250
- output_replaceQuote : '\u201c;', // left double quote
251
- output_includeHTML : false,
252
- output_trimSpaces : true,
253
- output_wrapQuotes : false,
254
- output_popupStyle : 'width=500,height=300',
255
- output_saveFileName : 'mytable.csv',
262
+ output_separator : ',', // set to "json", "array" or any separator
263
+ output_ignoreColumns : [], // columns to ignore [0, 1,... ] (zero-based index)
264
+ output_dataAttrib : 'data-name', // header attrib containing modified header name
265
+ output_headerRows : false, // if true, include multiple header rows (JSON only)
266
+ output_delivery : 'popup', // popup, download
267
+ output_saveRows : 'filtered', // all, visible or filtered
268
+ output_duplicateSpans: true, // duplicate output data in tbody colspan/rowspan
269
+ output_replaceQuote : '\u201c;', // left double quote
270
+ output_includeHTML : false,
271
+ output_trimSpaces : true,
272
+ output_wrapQuotes : false,
273
+ output_popupStyle : 'width=500,height=300',
274
+ output_saveFileName : 'mytable.csv',
256
275
  // callback executed when processing completes
257
276
  // return true to continue download/output
258
277
  // return false to stop delivery & do something else with the data
259
- output_callback : function(data){ return true; },
278
+ output_callback : function(config, data){ return true; },
260
279
  // JSON callback executed when a colspan is encountered in the header
261
- output_callbackJSON : function($cell, txt, cellIndex) { return txt + '(' + (cellIndex + col) + ')'; }
280
+ output_callbackJSON : function($cell, txt, cellIndex) { return txt + '(' + (cellIndex) + ')'; },
281
+ // output data type (with BOM or Windows-1252 is needed for excel)
282
+ // NO BOM : 'data:text/csv;charset=utf8,'
283
+ // With BOM : 'data:text/csv;charset=utf8,%EF%BB%BF'
284
+ // WIN 1252 : 'data:text/csv;charset=windows-1252'
285
+ output_encoding : 'data:text/csv;charset=utf8,'
262
286
  },
263
287
  init: function(table, thisWidget, c) {
264
288
  output.init(c);
@@ -1,4 +1,4 @@
1
- /* Pager widget (beta) for TableSorter 4/23/2014 (v2.16.0) */
1
+ /* Pager widget (beta) for TableSorter 5/22/2014 (v2.17.0) */
2
2
  /*jshint browser:true, jquery:true, unused:false */
3
3
  ;(function($){
4
4
  "use strict";
@@ -131,7 +131,6 @@ tsp = ts.pager = {
131
131
  filteredPages: 0,
132
132
  currentFilters: [],
133
133
  page: wo.pager_startPage,
134
- size: wo.pager_size,
135
134
  startRow: 0,
136
135
  endRow: 0,
137
136
  ajaxCounter: 0,
@@ -147,6 +146,7 @@ tsp = ts.pager = {
147
146
  ts.log('Pager initializing');
148
147
  }
149
148
 
149
+ p.size = $.data(table, 'pagerLastSize') || wo.pager_size;
150
150
  // added in case the pager is reinitialized after being destroyed.
151
151
  p.$container = $(s.container).addClass(wo.pager_css.container).show();
152
152
  // goto selector
@@ -246,6 +246,11 @@ tsp = ts.pager = {
246
246
  })
247
247
  .on('update updateRows updateAll addRows '.split(' ').join('.pager '), function(e){
248
248
  e.stopPropagation();
249
+ tsp.fixHeight(table, c);
250
+ var $rows = c.$tbodies.eq(0).children();
251
+ p.totalRows = $rows.length - ( c.widgetOptions.pager_countChildRows ? 0 : $rows.filter('.' + c.cssChildRow).length );
252
+ p.totalPages = Math.ceil( p.totalRows / p.size );
253
+ tsp.updatePageDisplay(table, c);
249
254
  tsp.hideRows(table, c);
250
255
  // make sure widgets are applied - fixes #450
251
256
  c.$table.trigger('applyWidgets');
@@ -486,7 +491,7 @@ tsp = ts.pager = {
486
491
  ts.log('Ajax Error', xhr, exception);
487
492
  }
488
493
  ts.showError(table, exception.message + ' (' + xhr.status + ')');
489
- c.$tbodies.eq(0).empty();
494
+ c.$tbodies.eq(0).detach();
490
495
  p.totalRows = 0;
491
496
  } else {
492
497
  // process ajax object
@@ -508,7 +513,7 @@ tsp = ts.pager = {
508
513
  if (d instanceof jQuery) {
509
514
  if (wo.pager_processAjaxOnInit) {
510
515
  // append jQuery object
511
- c.$tbodies.eq(0).empty().append(d);
516
+ c.$tbodies.eq(0).detach().append(d);
512
517
  }
513
518
  } else if (l) {
514
519
  // build table from array
@@ -0,0 +1,122 @@
1
+ /* Print widget (beta) for TableSorter 5/22/2014 (v2.17.0)
2
+ * Requires tablesorter v2.8+ and jQuery 1.7+
3
+ */
4
+ /*jshint browser:true, jquery:true, unused:false */
5
+ /*global jQuery: false */
6
+ ;(function($){
7
+ "use strict";
8
+
9
+ var ts = $.tablesorter,
10
+
11
+ printTable = ts.printTable = {
12
+
13
+ event : 'printTable',
14
+ basicStyle : 'table, tr, td, th { border : solid 1px black; border-collapse : collapse; } td, th { padding: 2px; }',
15
+
16
+ init : function(c) {
17
+ c.$table
18
+ .off(printTable.event)
19
+ .on(printTable.event, function(){
20
+ // explicitly use table.config.widgetOptions because we want
21
+ // the most up-to-date values; not the "wo" from initialization
22
+ printTable.process(c, c.widgetOptions);
23
+ });
24
+ },
25
+
26
+ process : function(c, wo) {
27
+ var $this,
28
+ $table = $('<div/>').append(c.$table.clone()),
29
+ printStyle = printTable.basicStyle + 'table { width: 100% }' +
30
+ // hide filter row
31
+ '.tablesorter-filter-row { display: none }' +
32
+ // hide sort arrows
33
+ '.tablesorter-header { background-image: none !important; }';
34
+
35
+ // replace content with data-attribute content
36
+ $table.find('[' + wo.print_dataAttrib + ']').each(function(){
37
+ $this = $(this);
38
+ $this.text( $this.attr(wo.print_dataAttrib) );
39
+ });
40
+
41
+ // === rows ===
42
+ // Assume "visible" means rows hidden by the pager (rows set to "display:none")
43
+ // or hidden by a class name which is added to the wo.print_extraCSS definition
44
+ if (/a/i.test(wo.print_rows)) {
45
+ // force show of all rows
46
+ printStyle += 'tbody tr { display: table-row !important; }';
47
+ } else if (/f/i.test(wo.print_rows)) {
48
+ // add definition to show all non-filtered rows (cells hidden by the pager)
49
+ printStyle += 'tbody tr:not(.' + (wo.filter_filteredRow || 'filtered') + ') { display: table-row !important; }';
50
+ }
51
+
52
+ // === columns ===
53
+ // columnSelector -> c.selector.$style
54
+ // Assume "visible" means hidden columns have a "display:none" style, or a class name
55
+ // add the definition to the wo.print_extraCSS option
56
+ if (/s/i.test(wo.print_columns) && c.selector && c.widgets.indexOf('columnSelector') >= 0) {
57
+ // show selected (visible) columns; make a copy of the columnSelector widget css (not media queries)
58
+ printStyle += c.selector.auto ? '' : c.selector.$style.text();
59
+ } else if (/a/i.test(wo.print_columns)) {
60
+ // force show all cells
61
+ printStyle += 'td, th { display: table-cell !important; }';
62
+ }
63
+
64
+ printStyle += wo.print_extraCSS;
65
+
66
+ // callback function
67
+ if ( $.isFunction(wo.print_callback) ) {
68
+ wo.print_callback( c, $table, printStyle );
69
+ } else {
70
+ printTable.printOutput(c, $table.html(), printStyle);
71
+ }
72
+
73
+ }, // end process
74
+
75
+ printOutput : function(c, data, style) {
76
+ var wo = c.widgetOptions,
77
+ generator = window.open('', wo.print_title, 'width=500,height=300'),
78
+ t = wo.print_title || c.$table.find('caption').text() || c.$table[0].id || document.title || 'table';
79
+ generator.document.write(
80
+ '<html><head><title>' + t + '</title>' +
81
+ ( wo.print_styleSheet ? '<link rel="stylesheet" href="' + wo.print_styleSheet + '">' : '' ) +
82
+ '<style>' + style + '</style>' +
83
+ '</head><body>' + data + '</body></html>'
84
+ );
85
+ generator.print();
86
+ generator.document.close();
87
+ return true;
88
+ },
89
+
90
+ remove : function(c) {
91
+ c.$table.off(printTable.event);
92
+ }
93
+
94
+ };
95
+
96
+ ts.addWidget({
97
+ id: 'print',
98
+ options: {
99
+ print_title : '', // this option > caption > table id > "table"
100
+ print_dataAttrib : 'data-name', // header attrib containing modified header name
101
+ print_rows : 'filtered', // (a)ll, (v)isible or (f)iltered
102
+ print_columns : 'selected', // (a)ll or (s)elected (if columnSelector widget is added)
103
+ print_extraCSS : '', // add any extra css definitions for the popup window here
104
+ print_styleSheet : '', // add the url of your print stylesheet
105
+ // callback executed when processing completes
106
+ // to continue printing, use the following function:
107
+ // function( config, $table, printStyle ) {
108
+ // // do something to the table or printStyle string
109
+ // $.tablesorter.printTable.printOutput( config, $table.html(), printStyle );
110
+ // }
111
+ print_callback : null
112
+ },
113
+ init: function(table, thisWidget, c) {
114
+ printTable.init(c);
115
+ },
116
+ remove: function(table, c){
117
+ printTable.remove(c);
118
+ }
119
+
120
+ });
121
+
122
+ })(jQuery);