jquery-tablesorter 1.17.2 → 1.17.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/jquery-tablesorter/version.rb +1 -1
  4. data/vendor/assets/javascripts/jquery-tablesorter/addons/pager/jquery.tablesorter.pager.js +76 -71
  5. data/vendor/assets/javascripts/jquery-tablesorter/extras/jquery.dragtable.mod.js +1 -1
  6. data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.combined.js +2647 -2576
  7. data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.js +174 -119
  8. data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.widgets.js +2487 -2471
  9. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-extract.js +15 -15
  10. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-iso8601.js +1 -1
  11. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-month.js +4 -4
  12. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-range.js +1 -1
  13. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-two-digit-year.js +12 -12
  14. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-weekday.js +4 -4
  15. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date.js +1 -1
  16. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-duration.js +1 -1
  17. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-feet-inch-fraction.js +6 -6
  18. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-file-type.js +22 -22
  19. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-globalize.js +1 -1
  20. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-ignore-articles.js +15 -15
  21. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-image.js +3 -3
  22. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-input-select.js +10 -3
  23. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-metric.js +2 -2
  24. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-named-numbers.js +3 -3
  25. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-network.js +1 -1
  26. data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-roman.js +4 -4
  27. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-alignChar.js +122 -121
  28. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-build-table.js +13 -13
  29. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-chart.js +2 -2
  30. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-columnSelector.js +324 -324
  31. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-columns.js +60 -60
  32. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-editable.js +219 -219
  33. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-formatter-html5.js +360 -361
  34. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-formatter-jui.js +666 -666
  35. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-formatter-select2.js +124 -124
  36. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-type-insideRange.js +1 -1
  37. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter.js +1448 -1433
  38. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-formatter.js +1 -1
  39. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-grouping.js +213 -213
  40. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-headerTitles.js +3 -3
  41. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-math.js +271 -216
  42. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-output.js +339 -320
  43. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-pager.js +1057 -1045
  44. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-print.js +109 -109
  45. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-reflow.js +114 -115
  46. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-resizable.js +360 -359
  47. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-saveSort.js +59 -59
  48. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-scroller.js +818 -806
  49. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-sort2Hash.js +128 -0
  50. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-sortTbodies.js +195 -195
  51. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-staticRow.js +90 -90
  52. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-stickyHeaders.js +257 -257
  53. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-storage.js +76 -76
  54. data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-uitheme.js +170 -170
  55. metadata +3 -3
  56. data/vendor/assets/javascripts/jquery-tablesorter/extras/jquery.quicksearch.js +0 -195
@@ -32,7 +32,7 @@
32
32
  .off(wo.chart_event)
33
33
  .on(wo.chart_event, function() {
34
34
  if (this.hasInitialized) {
35
- // refresh "c" variable in case options are updated dynamically
35
+ // refresh 'c' variable in case options are updated dynamically
36
36
  var c = this.config;
37
37
  chart.getCols(c, c.widgetOptions);
38
38
  chart.getData(c, c.widgetOptions);
@@ -258,7 +258,7 @@
258
258
  // Set the label column
259
259
  chart_labelCol: 0,
260
260
  // data sort, should always be first row, might want [[0,1]]
261
- chart_sort: [[0,0]],
261
+ chart_sort: [ [ 0, 0 ] ],
262
262
  // event to trigger get updated data
263
263
  chart_event: 'chartData'
264
264
  },
@@ -5,362 +5,362 @@
5
5
  /*jshint browser:true, jquery:true, unused:false */
6
6
  /*global jQuery: false */
7
7
  ;(function($){
8
- "use strict";
8
+ 'use strict';
9
9
 
10
- var ts = $.tablesorter,
11
- namespace = '.tscolsel',
12
- tsColSel = ts.columnSelector = {
10
+ var ts = $.tablesorter,
11
+ namespace = '.tscolsel',
12
+ tsColSel = ts.columnSelector = {
13
13
 
14
- queryAll : '@media only all { [columns] { display: none; } } ',
15
- queryBreak : '@media all and (min-width: [size]) { [columns] { display: table-cell; } } ',
14
+ queryAll : '@media only all { [columns] { display: none; } } ',
15
+ queryBreak : '@media all and (min-width: [size]) { [columns] { display: table-cell; } } ',
16
16
 
17
- init: function(table, c, wo) {
18
- var $t, colSel;
17
+ init: function(table, c, wo) {
18
+ var $t, colSel;
19
19
 
20
- // abort if no input is contained within the layout
21
- $t = $(wo.columnSelector_layout);
22
- if (!$t.find('input').add( $t.filter('input') ).length) {
23
- if (c.debug) {
24
- ts.log('ColumnSelector: >> ERROR: Column Selector aborting, no input found in the layout! ***');
20
+ // abort if no input is contained within the layout
21
+ $t = $(wo.columnSelector_layout);
22
+ if (!$t.find('input').add( $t.filter('input') ).length) {
23
+ if (c.debug) {
24
+ console.error('ColumnSelector: >> ERROR: Column Selector aborting, no input found in the layout! ***');
25
+ }
26
+ return;
25
27
  }
26
- return;
27
- }
28
28
 
29
- // unique table class name
30
- c.$table.addClass( c.namespace.slice(1) + 'columnselector' );
29
+ // unique table class name
30
+ c.$table.addClass( c.namespace.slice(1) + 'columnselector' );
31
31
 
32
- // build column selector/state array
33
- colSel = c.selector = { $container : $(wo.columnSelector_container || '<div>') };
34
- colSel.$style = $('<style></style>').prop('disabled', true).appendTo('head');
35
- colSel.$breakpoints = $('<style></style>').prop('disabled', true).appendTo('head');
32
+ // build column selector/state array
33
+ colSel = c.selector = { $container : $(wo.columnSelector_container || '<div>') };
34
+ colSel.$style = $('<style></style>').prop('disabled', true).appendTo('head');
35
+ colSel.$breakpoints = $('<style></style>').prop('disabled', true).appendTo('head');
36
36
 
37
- colSel.isInitializing = true;
38
- tsColSel.setupSelector(table, c, wo);
37
+ colSel.isInitializing = true;
38
+ tsColSel.setupSelector(table, c, wo);
39
39
 
40
- if (wo.columnSelector_mediaquery) {
41
- tsColSel.setupBreakpoints(c, wo);
42
- }
40
+ if (wo.columnSelector_mediaquery) {
41
+ tsColSel.setupBreakpoints(c, wo);
42
+ }
43
43
 
44
- colSel.isInitializing = false;
45
- if (colSel.$container.length) {
46
- tsColSel.updateCols(c, wo);
47
- } else if (c.debug) {
48
- ts.log('ColumnSelector: >> container not found');
49
- }
44
+ colSel.isInitializing = false;
45
+ if (colSel.$container.length) {
46
+ tsColSel.updateCols(c, wo);
47
+ } else if (c.debug) {
48
+ console.warn('ColumnSelector: >> container not found');
49
+ }
50
50
 
51
- c.$table
52
- .off('refreshColumnSelector' + namespace)
53
- .on('refreshColumnSelector' + namespace, function(e, opt){
54
- // make sure we're using current config settings
55
- var i,
56
- isArry = $.isArray(opt),
57
- c = this.config,
58
- wo = c.widgetOptions;
59
- // see #798
60
- if (opt && c.selector.$container.length) {
61
- if (isArry) {
62
- // make sure array contains numbers
63
- $.each(opt, function(i,v){
64
- opt[i] = parseInt(v, 10);
65
- });
66
- for (i = 0; i < c.columns; i++) {
67
- c.selector.$container
68
- .find('input[data-column=' + i + ']')
69
- .prop('checked', $.inArray( i, opt ) >= 0 );
51
+ c.$table
52
+ .off('refreshColumnSelector' + namespace)
53
+ .on('refreshColumnSelector' + namespace, function(e, opt){
54
+ // make sure we're using current config settings
55
+ var i,
56
+ isArry = $.isArray(opt),
57
+ c = this.config,
58
+ wo = c.widgetOptions;
59
+ // see #798
60
+ if (opt && c.selector.$container.length) {
61
+ if (isArry) {
62
+ // make sure array contains numbers
63
+ $.each(opt, function(i, v){
64
+ opt[i] = parseInt(v, 10);
65
+ });
66
+ for (i = 0; i < c.columns; i++) {
67
+ c.selector.$container
68
+ .find('input[data-column=' + i + ']')
69
+ .prop('checked', $.inArray( i, opt ) >= 0 );
70
+ }
70
71
  }
72
+ // if passing an array, set auto to false to allow manual column selection & update columns
73
+ tsColSel.updateAuto( c, wo, colSel.$container.find('input[data-column="auto"]').prop('checked', !isArry) );
74
+ } else {
75
+ tsColSel.updateBreakpoints(c, wo);
76
+ tsColSel.updateCols(c, wo);
71
77
  }
72
- // if passing an array, set auto to false to allow manual column selection & update columns
73
- tsColSel.updateAuto( c, wo, colSel.$container.find('input[data-column="auto"]').prop('checked', !isArry) );
74
- } else {
75
- tsColSel.updateBreakpoints(c, wo);
76
- tsColSel.updateCols(c, wo);
78
+ });
79
+
80
+ },
81
+
82
+ setupSelector: function(table, c, wo) {
83
+ var name,
84
+ colSel = c.selector,
85
+ $container = colSel.$container,
86
+ useStorage = wo.columnSelector_saveColumns && ts.storage,
87
+ // get stored column states
88
+ saved = useStorage ? ts.storage( table, 'tablesorter-columnSelector' ) : [],
89
+ state = useStorage ? ts.storage( table, 'tablesorter-columnSelector-auto') : {};
90
+
91
+ // initial states
92
+ colSel.auto = $.isEmptyObject(state) || $.type(state.auto) !== 'boolean' ? wo.columnSelector_mediaqueryState : state.auto;
93
+ colSel.states = [];
94
+ colSel.$column = [];
95
+ colSel.$wrapper = [];
96
+ colSel.$checkbox = [];
97
+ // populate the selector container
98
+ c.$table.children('thead').find('tr:first th', table).each(function() {
99
+ var $this = $(this),
100
+ // if no data-priority is assigned, default to 1, but don't remove it from the selector list
101
+ priority = $this.attr(wo.columnSelector_priority) || 1,
102
+ colId = $this.attr('data-column'),
103
+ state = ts.getData(this, c.headers[colId], 'columnSelector');
104
+
105
+ // if this column not hidable at all
106
+ // include getData check (includes 'columnSelector-false' class, data attribute, etc)
107
+ if ( isNaN(priority) && priority.length > 0 || state === 'disable' ||
108
+ ( wo.columnSelector_columns[colId] && wo.columnSelector_columns[colId] === 'disable') ) {
109
+ return true; // goto next
110
+ }
111
+
112
+ // set default state; storage takes priority
113
+ colSel.states[colId] = saved && typeof saved[colId] !== 'undefined' ?
114
+ saved[colId] : typeof wo.columnSelector_columns[colId] !== 'undefined' ?
115
+ wo.columnSelector_columns[colId] : (state === 'true' || state !== 'false');
116
+ colSel.$column[colId] = $(this);
117
+
118
+ // set default col title
119
+ name = $this.attr(wo.columnSelector_name) || $this.text();
120
+
121
+ if ($container.length) {
122
+ colSel.$wrapper[colId] = $(wo.columnSelector_layout.replace(/\{name\}/g, name)).appendTo($container);
123
+ colSel.$checkbox[colId] = colSel.$wrapper[colId]
124
+ // input may not be wrapped within the layout template
125
+ .find('input').add( colSel.$wrapper[colId].filter('input') )
126
+ .attr('data-column', colId)
127
+ .toggleClass( wo.columnSelector_cssChecked, colSel.states[colId] )
128
+ .prop('checked', colSel.states[colId])
129
+ .on('change', function(){
130
+ colSel.states[colId] = this.checked;
131
+ tsColSel.updateCols(c, wo);
132
+ }).change();
77
133
  }
78
134
  });
79
135
 
80
- },
81
-
82
- setupSelector: function(table, c, wo) {
83
- var name,
84
- colSel = c.selector,
85
- $container = colSel.$container,
86
- useStorage = wo.columnSelector_saveColumns && ts.storage,
87
- // get stored column states
88
- saved = useStorage ? ts.storage( table, 'tablesorter-columnSelector' ) : [],
89
- state = useStorage ? ts.storage( table, 'tablesorter-columnSelector-auto') : {};
90
-
91
- // initial states
92
- colSel.auto = $.isEmptyObject(state) || $.type(state.auto) !== "boolean" ? wo.columnSelector_mediaqueryState : state.auto;
93
- colSel.states = [];
94
- colSel.$column = [];
95
- colSel.$wrapper = [];
96
- colSel.$checkbox = [];
97
- // populate the selector container
98
- c.$table.children('thead').find('tr:first th', table).each(function() {
99
- var $this = $(this),
100
- // if no data-priority is assigned, default to 1, but don't remove it from the selector list
101
- priority = $this.attr(wo.columnSelector_priority) || 1,
102
- colId = $this.attr('data-column'),
103
- state = ts.getData(this, c.headers[colId], 'columnSelector');
104
-
105
- // if this column not hidable at all
106
- // include getData check (includes "columnSelector-false" class, data attribute, etc)
107
- if ( isNaN(priority) && priority.length > 0 || state === 'disable' ||
108
- ( wo.columnSelector_columns[colId] && wo.columnSelector_columns[colId] === 'disable') ) {
109
- return true; // goto next
110
- }
136
+ },
137
+
138
+ setupBreakpoints: function(c, wo){
139
+ var colSel = c.selector;
111
140
 
112
- // set default state; storage takes priority
113
- colSel.states[colId] = saved && typeof(saved[colId]) !== 'undefined' ?
114
- saved[colId] : typeof(wo.columnSelector_columns[colId]) !== 'undefined' ?
115
- wo.columnSelector_columns[colId] : (state === 'true' || state !== 'false');
116
- colSel.$column[colId] = $(this);
117
-
118
- // set default col title
119
- name = $this.attr(wo.columnSelector_name) || $this.text();
120
-
121
- if ($container.length) {
122
- colSel.$wrapper[colId] = $(wo.columnSelector_layout.replace(/\{name\}/g, name)).appendTo($container);
123
- colSel.$checkbox[colId] = colSel.$wrapper[colId]
124
- // input may not be wrapped within the layout template
125
- .find('input').add( colSel.$wrapper[colId].filter('input') )
126
- .attr('data-column', colId)
127
- .toggleClass( wo.columnSelector_cssChecked, colSel.states[colId] )
128
- .prop('checked', colSel.states[colId])
129
- .on('change', function(){
130
- colSel.states[colId] = this.checked;
141
+ // add responsive breakpoints
142
+ if (wo.columnSelector_mediaquery) {
143
+ // used by window resize function
144
+ colSel.lastIndex = -1;
145
+ tsColSel.updateBreakpoints(c, wo);
146
+ c.$table
147
+ .off('updateAll' + namespace)
148
+ .on('updateAll' + namespace, function(){
149
+ tsColSel.updateBreakpoints(c, wo);
131
150
  tsColSel.updateCols(c, wo);
132
- }).change();
151
+ });
133
152
  }
134
- });
135
-
136
- },
137
153
 
138
- setupBreakpoints: function(c, wo){
139
- var colSel = c.selector;
140
-
141
- // add responsive breakpoints
142
- if (wo.columnSelector_mediaquery) {
143
- // used by window resize function
144
- colSel.lastIndex = -1;
145
- tsColSel.updateBreakpoints(c, wo);
146
- c.$table
147
- .off('updateAll' + namespace)
148
- .on('updateAll' + namespace, function(){
149
- tsColSel.updateBreakpoints(c, wo);
154
+ if (colSel.$container.length) {
155
+ // Add media queries toggle
156
+ if (wo.columnSelector_mediaquery) {
157
+ colSel.$auto = $( wo.columnSelector_layout.replace(/\{name\}/g, wo.columnSelector_mediaqueryName) ).prependTo(colSel.$container);
158
+ colSel.$auto
159
+ // needed in case the input in the layout is not wrapped
160
+ .find('input').add( colSel.$auto.filter('input') )
161
+ .attr('data-column', 'auto')
162
+ .prop('checked', colSel.auto)
163
+ .toggleClass( wo.columnSelector_cssChecked, colSel.auto )
164
+ .on('change', function(){
165
+ tsColSel.updateAuto(c, wo, $(this));
166
+ }).change();
167
+ }
168
+ // Add a bind on update to re-run col setup
169
+ c.$table.off('update' + namespace).on('update' + namespace, function() {
150
170
  tsColSel.updateCols(c, wo);
151
171
  });
152
- }
153
-
154
- if (colSel.$container.length) {
155
- // Add media queries toggle
156
- if (wo.columnSelector_mediaquery) {
157
- colSel.$auto = $( wo.columnSelector_layout.replace(/\{name\}/g, wo.columnSelector_mediaqueryName) ).prependTo(colSel.$container);
158
- colSel.$auto
159
- // needed in case the input in the layout is not wrapped
160
- .find('input').add( colSel.$auto.filter('input') )
161
- .attr('data-column', 'auto')
162
- .prop('checked', colSel.auto)
163
- .toggleClass( wo.columnSelector_cssChecked, colSel.auto )
164
- .on('change', function(){
165
- tsColSel.updateAuto(c, wo, $(this));
166
- }).change();
167
172
  }
168
- // Add a bind on update to re-run col setup
169
- c.$table.off('update' + namespace).on('update' + namespace, function() {
170
- tsColSel.updateCols(c, wo);
173
+ },
174
+
175
+ updateAuto: function(c, wo, $el) {
176
+ var colSel = c.selector;
177
+ colSel.auto = $el.prop('checked') || false;
178
+ $.each( colSel.$checkbox, function(i, $cb){
179
+ if ($cb) {
180
+ $cb[0].disabled = colSel.auto;
181
+ colSel.$wrapper[i].toggleClass('disabled', colSel.auto);
182
+ }
171
183
  });
172
- }
173
- },
174
-
175
- updateAuto: function(c, wo, $el) {
176
- var colSel = c.selector;
177
- colSel.auto = $el.prop('checked') || false;
178
- $.each( colSel.$checkbox, function(i, $cb){
179
- if ($cb) {
180
- $cb[0].disabled = colSel.auto;
181
- colSel.$wrapper[i].toggleClass('disabled', colSel.auto);
184
+ if (wo.columnSelector_mediaquery) {
185
+ tsColSel.updateBreakpoints(c, wo);
182
186
  }
183
- });
184
- if (wo.columnSelector_mediaquery) {
185
- tsColSel.updateBreakpoints(c, wo);
186
- }
187
- tsColSel.updateCols(c, wo);
188
- // copy the column selector to a popup/tooltip
189
- if (c.selector.$popup) {
190
- c.selector.$popup.find('.tablesorter-column-selector')
191
- .html( colSel.$container.html() )
192
- .find('input').each(function(){
193
- var indx = $(this).attr('data-column');
194
- $(this).prop( 'checked', indx === 'auto' ? colSel.auto : colSel.states[indx] );
187
+ tsColSel.updateCols(c, wo);
188
+ // copy the column selector to a popup/tooltip
189
+ if (c.selector.$popup) {
190
+ c.selector.$popup.find('.tablesorter-column-selector')
191
+ .html( colSel.$container.html() )
192
+ .find('input').each(function(){
193
+ var indx = $(this).attr('data-column');
194
+ $(this).prop( 'checked', indx === 'auto' ? colSel.auto : colSel.states[indx] );
195
+ });
196
+ }
197
+ if (wo.columnSelector_saveColumns && ts.storage) {
198
+ ts.storage( c.$table[0], 'tablesorter-columnSelector-auto', { auto : colSel.auto } );
199
+ }
200
+ // trigger columnUpdate if auto is true (it gets skipped in updateCols()
201
+ if (colSel.auto) {
202
+ c.$table.trigger('columnUpdate');
203
+ }
204
+ },
205
+
206
+ updateBreakpoints: function(c, wo) {
207
+ var priority, column, breaks, temp,
208
+ colSel = c.selector,
209
+ prefix = c.namespace + 'columnselector',
210
+ mediaAll = [],
211
+ breakpts = '';
212
+ if (wo.columnSelector_mediaquery && !colSel.auto) {
213
+ colSel.$breakpoints.prop('disabled', true);
214
+ colSel.$style.prop('disabled', false);
215
+ return;
216
+ }
217
+
218
+ // only 6 breakpoints (same as jQuery Mobile)
219
+ for (priority = 0; priority < 6; priority++){
220
+ /*jshint loopfunc:true */
221
+ breaks = [];
222
+ c.$headers.filter('[' + wo.columnSelector_priority + '=' + (priority + 1) + ']').each(function(){
223
+ column = parseInt($(this).attr('data-column'), 10) + 1;
224
+ temp = ' col:nth-child(' + column + ')';
225
+ breaks.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
226
+ temp = ' tr th:nth-child(' + column + ')';
227
+ breaks.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
228
+ temp = ' tr td:nth-child(' + column + ')';
229
+ breaks.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
195
230
  });
196
- }
197
- if (wo.columnSelector_saveColumns && ts.storage) {
198
- ts.storage( c.$table[0], 'tablesorter-columnSelector-auto', { auto : colSel.auto } );
199
- }
200
- // trigger columnUpdate if auto is true (it gets skipped in updateCols()
201
- if (colSel.auto) {
202
- c.$table.trigger('columnUpdate');
203
- }
204
- },
205
-
206
- updateBreakpoints: function(c, wo) {
207
- var priority, column, breaks, temp,
208
- colSel = c.selector,
209
- prefix = c.namespace + 'columnselector',
210
- mediaAll = [],
211
- breakpts = '';
212
- if (wo.columnSelector_mediaquery && !colSel.auto) {
213
- colSel.$breakpoints.prop('disabled', true);
214
- colSel.$style.prop('disabled', false);
215
- return;
216
- }
231
+ if (breaks.length) {
232
+ mediaAll = mediaAll.concat( breaks );
233
+ breakpts += tsColSel.queryBreak
234
+ .replace(/\[size\]/g, wo.columnSelector_breakpoints[priority])
235
+ .replace(/\[columns\]/g, breaks.join(','));
236
+ }
237
+ }
238
+ if (colSel.$style) {
239
+ colSel.$style.prop('disabled', true);
240
+ }
241
+ if (mediaAll.length) {
242
+ colSel.$breakpoints
243
+ .prop('disabled', false)
244
+ .html( tsColSel.queryAll.replace(/\[columns\]/g, mediaAll.join(',')) + breakpts );
245
+ }
246
+ },
217
247
 
218
- // only 6 breakpoints (same as jQuery Mobile)
219
- for (priority = 0; priority < 6; priority++){
220
- /*jshint loopfunc:true */
221
- breaks = [];
222
- c.$headers.filter('[' + wo.columnSelector_priority + '=' + (priority + 1) + ']').each(function(){
223
- column = parseInt($(this).attr('data-column'), 10) + 1;
224
- temp = ' col:nth-child(' + column + ')';
225
- breaks.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
226
- temp = ' tr th:nth-child(' + column + ')';
227
- breaks.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
228
- temp = ' tr td:nth-child(' + column + ')';
229
- breaks.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
248
+ updateCols: function(c, wo) {
249
+ if (wo.columnSelector_mediaquery && c.selector.auto || c.selector.isInitializing) {
250
+ return;
251
+ }
252
+ var column, temp,
253
+ colSel = c.selector,
254
+ styles = [],
255
+ prefix = c.namespace + 'columnselector';
256
+ colSel.$container.find('input[data-column]').filter('[data-column!="auto"]').each(function(){
257
+ if (!this.checked) {
258
+ column = parseInt( $(this).attr('data-column'), 10 ) + 1;
259
+ temp = ' col:nth-child(' + column + ')';
260
+ styles.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
261
+ temp = ' tr th:nth-child(' + column + ')';
262
+ styles.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
263
+ temp = ' tr td:nth-child(' + column + ')';
264
+ styles.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
265
+ }
266
+ $(this).toggleClass( wo.columnSelector_cssChecked, this.checked );
230
267
  });
231
- if (breaks.length) {
232
- mediaAll = mediaAll.concat( breaks );
233
- breakpts += tsColSel.queryBreak
234
- .replace(/\[size\]/g, wo.columnSelector_breakpoints[priority])
235
- .replace(/\[columns\]/g, breaks.join(','));
268
+ if (wo.columnSelector_mediaquery){
269
+ colSel.$breakpoints.prop('disabled', true);
236
270
  }
237
- }
238
- if (colSel.$style) {
239
- colSel.$style.prop('disabled', true);
240
- }
241
- if (mediaAll.length) {
242
- colSel.$breakpoints
243
- .prop('disabled', false)
244
- .html( tsColSel.queryAll.replace(/\[columns\]/g, mediaAll.join(',')) + breakpts );
245
- }
246
- },
247
-
248
- updateCols: function(c, wo) {
249
- if (wo.columnSelector_mediaquery && c.selector.auto || c.selector.isInitializing) {
250
- return;
251
- }
252
- var column, temp,
253
- colSel = c.selector,
254
- styles = [],
255
- prefix = c.namespace + 'columnselector';
256
- colSel.$container.find('input[data-column]').filter('[data-column!="auto"]').each(function(){
257
- if (!this.checked) {
258
- column = parseInt( $(this).attr('data-column'), 10 ) + 1;
259
- temp = ' col:nth-child(' + column + ')';
260
- styles.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
261
- temp = ' tr th:nth-child(' + column + ')';
262
- styles.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
263
- temp = ' tr td:nth-child(' + column + ')';
264
- styles.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
271
+ if (colSel.$style) {
272
+ colSel.$style.prop('disabled', false).html( styles.length ? styles.join(',') + ' { display: none; }' : '' );
265
273
  }
266
- $(this).toggleClass( wo.columnSelector_cssChecked, this.checked );
267
- });
268
- if (wo.columnSelector_mediaquery){
269
- colSel.$breakpoints.prop('disabled', true);
270
- }
271
- if (colSel.$style) {
272
- colSel.$style.prop('disabled', false).html( styles.length ? styles.join(',') + ' { display: none; }' : '' );
273
- }
274
- if (wo.columnSelector_saveColumns && ts.storage) {
275
- ts.storage( c.$table[0], 'tablesorter-columnSelector', colSel.states );
276
- }
277
- c.$table.trigger('columnUpdate');
278
- },
279
-
280
- attachTo : function(table, elm) {
281
- table = $(table)[0];
282
- var colSel, wo, indx,
283
- c = table.config,
284
- $popup = $(elm);
285
- if ($popup.length && c) {
286
- if (!$popup.find('.tablesorter-column-selector').length) {
287
- // add a wrapper to add the selector into, in case the popup has other content
288
- $popup.append('<span class="tablesorter-column-selector"></span>');
274
+ if (wo.columnSelector_saveColumns && ts.storage) {
275
+ ts.storage( c.$table[0], 'tablesorter-columnSelector', colSel.states );
289
276
  }
290
- colSel = c.selector;
291
- wo = c.widgetOptions;
292
- $popup.find('.tablesorter-column-selector')
293
- .html( colSel.$container.html() )
294
- .find('input').each(function(){
295
- var indx = $(this).attr('data-column'),
296
- isChecked = indx === 'auto' ? colSel.auto : colSel.states[indx];
297
- $(this)
298
- .toggleClass( wo.columnSelector_cssChecked, isChecked )
299
- .prop( 'checked', isChecked );
277
+ c.$table.trigger('columnUpdate');
278
+ },
279
+
280
+ attachTo : function(table, elm) {
281
+ table = $(table)[0];
282
+ var colSel, wo, indx,
283
+ c = table.config,
284
+ $popup = $(elm);
285
+ if ($popup.length && c) {
286
+ if (!$popup.find('.tablesorter-column-selector').length) {
287
+ // add a wrapper to add the selector into, in case the popup has other content
288
+ $popup.append('<span class="tablesorter-column-selector"></span>');
289
+ }
290
+ colSel = c.selector;
291
+ wo = c.widgetOptions;
292
+ $popup.find('.tablesorter-column-selector')
293
+ .html( colSel.$container.html() )
294
+ .find('input').each(function(){
295
+ var indx = $(this).attr('data-column'),
296
+ isChecked = indx === 'auto' ? colSel.auto : colSel.states[indx];
297
+ $(this)
298
+ .toggleClass( wo.columnSelector_cssChecked, isChecked )
299
+ .prop( 'checked', isChecked );
300
+ });
301
+ colSel.$popup = $popup.on('change', 'input', function(){
302
+ // data input
303
+ indx = $(this).toggleClass( wo.columnSelector_cssChecked, this.checked ).attr('data-column');
304
+ // update original popup
305
+ colSel.$container.find('input[data-column="' + indx + '"]')
306
+ .prop('checked', this.checked)
307
+ .trigger('change');
300
308
  });
301
- colSel.$popup = $popup.on('change', 'input', function(){
302
- // data input
303
- indx = $(this).toggleClass( wo.columnSelector_cssChecked, this.checked ).attr('data-column');
304
- // update original popup
305
- colSel.$container.find('input[data-column="' + indx + '"]')
306
- .prop('checked', this.checked)
307
- .trigger('change');
308
- });
309
+ }
309
310
  }
310
- }
311
-
312
- };
313
-
314
- ts.addWidget({
315
- id: "columnSelector",
316
- priority: 10,
317
- options: {
318
- // target the column selector markup
319
- columnSelector_container : null,
320
- // column status, true = display, false = hide
321
- // disable = do not display on list
322
- columnSelector_columns : {},
323
- // remember selected columns
324
- columnSelector_saveColumns: true,
325
-
326
- // container layout
327
- columnSelector_layout : '<label><input type="checkbox">{name}</label>',
328
- // data attribute containing column name to use in the selector container
329
- columnSelector_name : 'data-selector-name',
330
-
331
- /* Responsive Media Query settings */
332
- // enable/disable mediaquery breakpoints
333
- columnSelector_mediaquery: true,
334
- // toggle checkbox name
335
- columnSelector_mediaqueryName: 'Auto: ',
336
- // breakpoints checkbox initial setting
337
- columnSelector_mediaqueryState: true,
338
- // responsive table hides columns with priority 1-6 at these breakpoints
339
- // see http://view.jquerymobile.com/1.3.2/dist/demos/widgets/table-column-toggle/#Applyingapresetbreakpoint
340
- // *** set to false to disable ***
341
- columnSelector_breakpoints : [ '20em', '30em', '40em', '50em', '60em', '70em' ],
342
- // data attribute containing column priority
343
- // duplicates how jQuery mobile uses priorities:
344
- // http://view.jquerymobile.com/1.3.2/dist/demos/widgets/table-column-toggle/
345
- columnSelector_priority : 'data-priority',
346
- // class name added to checked checkboxes - this fixes an issue with Chrome not updating FontAwesome
347
- // applied icons; use this class name (input.checked) instead of input:checked
348
- columnSelector_cssChecked : 'checked'
349
-
350
- },
351
- init: function(table, thisWidget, c, wo) {
352
- tsColSel.init(table, c, wo);
353
- },
354
- remove: function(table, c, wo, refreshing) {
355
- if (refreshing) { return; }
356
- var csel = c.selector;
357
- csel.$container.empty();
358
- if (csel.$popup) { csel.$popup.empty(); }
359
- csel.$style.remove();
360
- csel.$breakpoints.remove();
361
- c.$table.off('updateAll' + namespace + ' update' + namespace);
362
- }
363
-
364
- });
311
+
312
+ };
313
+
314
+ ts.addWidget({
315
+ id: 'columnSelector',
316
+ priority: 10,
317
+ options: {
318
+ // target the column selector markup
319
+ columnSelector_container : null,
320
+ // column status, true = display, false = hide
321
+ // disable = do not display on list
322
+ columnSelector_columns : {},
323
+ // remember selected columns
324
+ columnSelector_saveColumns: true,
325
+
326
+ // container layout
327
+ columnSelector_layout : '<label><input type="checkbox">{name}</label>',
328
+ // data attribute containing column name to use in the selector container
329
+ columnSelector_name : 'data-selector-name',
330
+
331
+ /* Responsive Media Query settings */
332
+ // enable/disable mediaquery breakpoints
333
+ columnSelector_mediaquery: true,
334
+ // toggle checkbox name
335
+ columnSelector_mediaqueryName: 'Auto: ',
336
+ // breakpoints checkbox initial setting
337
+ columnSelector_mediaqueryState: true,
338
+ // responsive table hides columns with priority 1-6 at these breakpoints
339
+ // see http://view.jquerymobile.com/1.3.2/dist/demos/widgets/table-column-toggle/#Applyingapresetbreakpoint
340
+ // *** set to false to disable ***
341
+ columnSelector_breakpoints : [ '20em', '30em', '40em', '50em', '60em', '70em' ],
342
+ // data attribute containing column priority
343
+ // duplicates how jQuery mobile uses priorities:
344
+ // http://view.jquerymobile.com/1.3.2/dist/demos/widgets/table-column-toggle/
345
+ columnSelector_priority : 'data-priority',
346
+ // class name added to checked checkboxes - this fixes an issue with Chrome not updating FontAwesome
347
+ // applied icons; use this class name (input.checked) instead of input:checked
348
+ columnSelector_cssChecked : 'checked'
349
+
350
+ },
351
+ init: function(table, thisWidget, c, wo) {
352
+ tsColSel.init(table, c, wo);
353
+ },
354
+ remove: function(table, c, wo, refreshing) {
355
+ if (refreshing) { return; }
356
+ var csel = c.selector;
357
+ csel.$container.empty();
358
+ if (csel.$popup) { csel.$popup.empty(); }
359
+ csel.$style.remove();
360
+ csel.$breakpoints.remove();
361
+ c.$table.off('updateAll' + namespace + ' update' + namespace);
362
+ }
363
+
364
+ });
365
365
 
366
366
  })(jQuery);