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
@@ -5,7 +5,7 @@
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
  var ts = $.tablesorter;
10
10
 
11
11
  ts.formatter = {
@@ -5,246 +5,246 @@
5
5
  /*jshint browser:true, jquery:true, unused:false */
6
6
  /*global jQuery: false */
7
7
  ;(function($){
8
- "use strict";
9
- var ts = $.tablesorter;
8
+ 'use strict';
9
+ var ts = $.tablesorter;
10
10
 
11
- ts.grouping = {
11
+ ts.grouping = {
12
12
 
13
- types : {
14
- number : function(c, $column, txt, num, group){
15
- var value, word;
16
- if (num > 1 && txt !== '') {
17
- if ($column.hasClass(ts.css.sortAsc)) {
18
- value = Math.floor(parseFloat(txt)/num) * num;
19
- return value > parseFloat(group || 0) ? value : parseFloat(group || 0);
13
+ types : {
14
+ number : function(c, $column, txt, num, group){
15
+ var value, word;
16
+ if (num > 1 && txt !== '') {
17
+ if ($column.hasClass(ts.css.sortAsc)) {
18
+ value = Math.floor(parseFloat(txt) / num) * num;
19
+ return value > parseFloat(group || 0) ? value : parseFloat(group || 0);
20
+ } else {
21
+ value = Math.ceil(parseFloat(txt) / num) * num;
22
+ return value < parseFloat(group || num) - value ? parseFloat(group || num) - value : value;
23
+ }
20
24
  } else {
21
- value = Math.ceil(parseFloat(txt)/num) * num;
22
- return value < parseFloat(group || num) - value ? parseFloat(group || num) - value : value;
25
+ word = (txt + '').match(/\d+/g);
26
+ return word && word.length >= num ? word[num - 1] : txt || '';
23
27
  }
24
- } else {
25
- word = (txt + '').match(/\d+/g);
28
+ },
29
+ separator : function(c, $column, txt, num){
30
+ var word = (txt + '').split(c.widgetOptions.group_separator);
31
+ return $.trim(word && num > 0 && word.length >= num ? word[(num || 1) - 1] : '');
32
+ },
33
+ word : function(c, $column, txt, num){
34
+ var word = (txt + ' ').match(/\w+/g);
26
35
  return word && word.length >= num ? word[num - 1] : txt || '';
36
+ },
37
+ letter : function(c, $column, txt, num){
38
+ return txt ? (txt + ' ').substring(0, num) : '';
39
+ },
40
+ date : function(c, $column, txt, part, group){
41
+ var wo = c.widgetOptions,
42
+ time = new Date(txt || ''),
43
+ hours = time.getHours();
44
+ return part === 'year' ? time.getFullYear() :
45
+ part === 'month' ? wo.group_months[time.getMonth()] :
46
+ part === 'monthyear' ? wo.group_months[time.getMonth()] + ' ' + time.getFullYear() :
47
+ part === 'day' ? wo.group_months[time.getMonth()] + ' ' + time.getDate() :
48
+ part === 'week' ? wo.group_week[time.getDay()] :
49
+ part === 'time' ? ('00' + (hours > 12 ? hours - 12 : hours === 0 ? hours + 12 : hours)).slice(-2) + ':' +
50
+ ('00' + time.getMinutes()).slice(-2) + ' ' + ('00' + wo.group_time[hours >= 12 ? 1 : 0]).slice(-2) :
51
+ wo.group_dateString(time);
27
52
  }
28
53
  },
29
- separator : function(c, $column, txt, num){
30
- var word = (txt + '').split(c.widgetOptions.group_separator);
31
- return $.trim(word && num > 0 && word.length >= num ? word[(num || 1) - 1] : '');
32
- },
33
- word : function(c, $column, txt, num){
34
- var word = (txt + ' ').match(/\w+/g);
35
- return word && word.length >= num ? word[num - 1] : txt || '';
36
- },
37
- letter : function(c, $column, txt, num){
38
- return txt ? (txt + ' ').substring(0, num) : '';
39
- },
40
- date : function(c, $column, txt, part, group){
41
- var wo = c.widgetOptions,
42
- time = new Date(txt || ''),
43
- hours = time.getHours();
44
- return part === 'year' ? time.getFullYear() :
45
- part === 'month' ? wo.group_months[time.getMonth()] :
46
- part === 'monthyear' ? wo.group_months[time.getMonth()] + ' ' + time.getFullYear() :
47
- part === 'day' ? wo.group_months[time.getMonth()] + ' ' + time.getDate() :
48
- part === 'week' ? wo.group_week[time.getDay()] :
49
- part === 'time' ? ('00' + (hours > 12 ? hours - 12 : hours === 0 ? hours + 12 : hours)).slice(-2) + ':' +
50
- ('00' + time.getMinutes()).slice(-2) + ' ' + ('00' + wo.group_time[hours >= 12 ? 1 : 0]).slice(-2) :
51
- wo.group_dateString(time);
52
- }
53
- },
54
54
 
55
- update : function(table, c, wo){
56
- if ($.isEmptyObject(c.cache)) { return; }
57
- var rowIndex, tbodyIndex, currentGroup, $rows, groupClass, grouping, norm_rows, saveName, direction,
58
- lang = wo.grouping_language,
59
- group = '',
60
- savedGroup = false,
61
- column = c.sortList[0] ? c.sortList[0][0] : -1;
62
- c.$table
63
- .find('tr.group-hidden').removeClass('group-hidden').end()
64
- .find('tr.group-header').remove();
65
- if (wo.group_collapsible) {
66
- // clear pager saved spacer height (in case the rows are collapsed)
67
- c.$table.data('pagerSavedHeight', 0);
68
- }
69
- if (column >= 0 && !c.$headerIndexed[column].hasClass('group-false')) {
70
- wo.group_currentGroup = ''; // save current groups
71
- wo.group_currentGroups = {};
55
+ update : function(table, c, wo){
56
+ if ($.isEmptyObject(c.cache)) { return; }
57
+ var rowIndex, tbodyIndex, currentGroup, $rows, groupClass, grouping, norm_rows, saveName, direction,
58
+ lang = wo.grouping_language,
59
+ group = '',
60
+ savedGroup = false,
61
+ column = c.sortList[0] ? c.sortList[0][0] : -1;
62
+ c.$table
63
+ .find('tr.group-hidden').removeClass('group-hidden').end()
64
+ .find('tr.group-header').remove();
65
+ if (wo.group_collapsible) {
66
+ // clear pager saved spacer height (in case the rows are collapsed)
67
+ c.$table.data('pagerSavedHeight', 0);
68
+ }
69
+ if (column >= 0 && !c.$headerIndexed[column].hasClass('group-false')) {
70
+ wo.group_currentGroup = ''; // save current groups
71
+ wo.group_currentGroups = {};
72
72
 
73
- // group class finds "group-{word/separator/letter/number/date/false}-{optional:#/year/month/day/week/time}"
74
- groupClass = (c.$headerIndexed[column].attr('class') || '').match(/(group-\w+(-\w+)?)/g);
75
- // grouping = [ 'group', '{word/separator/letter/number/date/false}', '{#/year/month/day/week/time}' ]
76
- grouping = groupClass ? groupClass[0].split('-') : ['group','letter',1]; // default to letter 1
73
+ // group class finds 'group-{word/separator/letter/number/date/false}-{optional:#/year/month/day/week/time}'
74
+ groupClass = (c.$headerIndexed[column].attr('class') || '').match(/(group-\w+(-\w+)?)/g);
75
+ // grouping = [ 'group', '{word/separator/letter/number/date/false}', '{#/year/month/day/week/time}' ]
76
+ grouping = groupClass ? groupClass[0].split('-') : [ 'group', 'letter', 1 ]; // default to letter 1
77
77
 
78
- // save current grouping
79
- if (wo.group_collapsible && wo.group_saveGroups && ts.storage) {
80
- wo.group_currentGroups = ts.storage( table, 'tablesorter-groups' ) || {};
81
- // include direction when grouping numbers > 1 (reversed direction shows different range values)
82
- direction = (grouping[1] === 'number' && grouping[2] > 1) ? 'dir' + c.sortList[0][1] : '';
83
- // combine column, sort direction & grouping as save key
84
- saveName = wo.group_currentGroup = '' + column + direction + grouping.join('');
85
- if (!wo.group_currentGroups[saveName]) {
86
- wo.group_currentGroups[saveName] = [];
87
- } else {
88
- savedGroup = true;
78
+ // save current grouping
79
+ if (wo.group_collapsible && wo.group_saveGroups && ts.storage) {
80
+ wo.group_currentGroups = ts.storage( table, 'tablesorter-groups' ) || {};
81
+ // include direction when grouping numbers > 1 (reversed direction shows different range values)
82
+ direction = (grouping[1] === 'number' && grouping[2] > 1) ? 'dir' + c.sortList[0][1] : '';
83
+ // combine column, sort direction & grouping as save key
84
+ saveName = wo.group_currentGroup = '' + column + direction + grouping.join('');
85
+ if (!wo.group_currentGroups[saveName]) {
86
+ wo.group_currentGroups[saveName] = [];
87
+ } else {
88
+ savedGroup = true;
89
+ }
89
90
  }
90
- }
91
- for (tbodyIndex = 0; tbodyIndex < c.$tbodies.length; tbodyIndex++) {
92
- norm_rows = c.cache[tbodyIndex].normalized;
93
- group = ''; // clear grouping across tbodies
94
- $rows = c.$tbodies.eq(tbodyIndex).children('tr').not('.' + c.cssChildRow);
95
- for (rowIndex = 0; rowIndex < $rows.length; rowIndex++) {
96
- if ( $rows.eq(rowIndex).is(':visible') ) {
97
- // fixes #438
98
- if (ts.grouping.types[grouping[1]]) {
99
- currentGroup = norm_rows[rowIndex] ?
100
- ts.grouping.types[grouping[1]]( c, c.$headerIndexed[column], norm_rows[rowIndex][column], /date/.test(groupClass) ?
101
- grouping[2] : parseInt(grouping[2] || 1, 10) || 1, group, lang ) : currentGroup;
102
- if (group !== currentGroup) {
103
- group = currentGroup;
104
- // show range if number > 1
105
- if (grouping[1] === 'number' && grouping[2] > 1 && currentGroup !== '') {
106
- currentGroup += ' - ' + (parseInt(currentGroup, 10) +
107
- ((parseInt(grouping[2],10) - 1) * (c.$headerIndexed[column].hasClass(ts.css.sortAsc) ? 1 : -1)));
108
- }
109
- if ($.isFunction(wo.group_formatter)) {
110
- currentGroup = wo.group_formatter((currentGroup || '').toString(), column, table, c, wo) || currentGroup;
111
- }
112
- $rows.eq(rowIndex).before('<tr class="group-header ' + c.selectorRemove.slice(1) +
113
- '" unselectable="on"' + ( c.tabIndex ? ' tabindex="0"' : '' ) + '><td colspan="' +
114
- c.columns + '">' + (wo.group_collapsible ? '<i/>' : '') + '<span class="group-name">' +
115
- currentGroup + '</span><span class="group-count"></span></td></tr>');
116
- if (wo.group_saveGroups && !savedGroup && wo.group_collapsed && wo.group_collapsible) {
117
- // all groups start collapsed
118
- wo.group_currentGroups[wo.group_currentGroup].push(currentGroup);
91
+ for (tbodyIndex = 0; tbodyIndex < c.$tbodies.length; tbodyIndex++) {
92
+ norm_rows = c.cache[tbodyIndex].normalized;
93
+ group = ''; // clear grouping across tbodies
94
+ $rows = c.$tbodies.eq(tbodyIndex).children('tr').not('.' + c.cssChildRow);
95
+ for (rowIndex = 0; rowIndex < $rows.length; rowIndex++) {
96
+ if ( $rows.eq(rowIndex).is(':visible') ) {
97
+ // fixes #438
98
+ if (ts.grouping.types[grouping[1]]) {
99
+ currentGroup = norm_rows[rowIndex] ?
100
+ ts.grouping.types[grouping[1]]( c, c.$headerIndexed[column], norm_rows[rowIndex][column], /date/.test(groupClass) ?
101
+ grouping[2] : parseInt(grouping[2] || 1, 10) || 1, group, lang ) : currentGroup;
102
+ if (group !== currentGroup) {
103
+ group = currentGroup;
104
+ // show range if number > 1
105
+ if (grouping[1] === 'number' && grouping[2] > 1 && currentGroup !== '') {
106
+ currentGroup += ' - ' + (parseInt(currentGroup, 10) +
107
+ ((parseInt(grouping[2], 10) - 1) * (c.$headerIndexed[column].hasClass(ts.css.sortAsc) ? 1 : -1)));
108
+ }
109
+ if ($.isFunction(wo.group_formatter)) {
110
+ currentGroup = wo.group_formatter((currentGroup || '').toString(), column, table, c, wo) || currentGroup;
111
+ }
112
+ $rows.eq(rowIndex).before('<tr class="group-header ' + c.selectorRemove.slice(1) +
113
+ '" unselectable="on"' + ( c.tabIndex ? ' tabindex="0"' : '' ) + '><td colspan="' +
114
+ c.columns + '">' + (wo.group_collapsible ? '<i/>' : '') + '<span class="group-name">' +
115
+ currentGroup + '</span><span class="group-count"></span></td></tr>');
116
+ if (wo.group_saveGroups && !savedGroup && wo.group_collapsed && wo.group_collapsible) {
117
+ // all groups start collapsed
118
+ wo.group_currentGroups[wo.group_currentGroup].push(currentGroup);
119
+ }
119
120
  }
120
121
  }
121
122
  }
122
123
  }
123
124
  }
124
- }
125
- c.$table.find('tr.group-header')
126
- .bind('selectstart', false)
127
- .each(function(){
128
- var isHidden, $label, name,
129
- $row = $(this),
130
- $rows = $row.nextUntil('tr.group-header').filter(':visible');
131
- if (wo.group_count || $.isFunction(wo.group_callback)) {
132
- $label = $row.find('.group-count');
133
- if ($label.length) {
134
- if (wo.group_count) {
135
- $label.html( wo.group_count.replace(/\{num\}/g, $rows.length) );
136
- }
137
- if ($.isFunction(wo.group_callback)) {
138
- wo.group_callback($row.find('td'), $rows, column, table);
125
+ c.$table.find('tr.group-header')
126
+ .bind('selectstart', false)
127
+ .each(function(){
128
+ var isHidden, $label, name,
129
+ $row = $(this),
130
+ $rows = $row.nextUntil('tr.group-header').filter(':visible');
131
+ if (wo.group_count || $.isFunction(wo.group_callback)) {
132
+ $label = $row.find('.group-count');
133
+ if ($label.length) {
134
+ if (wo.group_count) {
135
+ $label.html( wo.group_count.replace(/\{num\}/g, $rows.length) );
136
+ }
137
+ if ($.isFunction(wo.group_callback)) {
138
+ wo.group_callback($row.find('td'), $rows, column, table);
139
+ }
139
140
  }
140
141
  }
141
- }
142
- if (wo.group_saveGroups && wo.group_currentGroups.length && wo.group_currentGroups[wo.group_currentGroup].length) {
143
- name = $row.find('.group-name').text().toLowerCase();
144
- isHidden = $.inArray( name, wo.group_currentGroups[wo.group_currentGroup] ) > -1;
145
- $row.toggleClass('collapsed', isHidden);
146
- $rows.toggleClass('group-hidden', isHidden);
147
- } else if (wo.group_collapsed && wo.group_collapsible) {
148
- $row.addClass('collapsed');
149
- $rows.addClass('group-hidden');
150
- }
151
- });
152
- c.$table.trigger(wo.group_complete);
153
- }
154
- },
142
+ if (wo.group_saveGroups && wo.group_currentGroups.length && wo.group_currentGroups[wo.group_currentGroup].length) {
143
+ name = $row.find('.group-name').text().toLowerCase();
144
+ isHidden = $.inArray( name, wo.group_currentGroups[wo.group_currentGroup] ) > -1;
145
+ $row.toggleClass('collapsed', isHidden);
146
+ $rows.toggleClass('group-hidden', isHidden);
147
+ } else if (wo.group_collapsed && wo.group_collapsible) {
148
+ $row.addClass('collapsed');
149
+ $rows.addClass('group-hidden');
150
+ }
151
+ });
152
+ c.$table.trigger(wo.group_complete);
153
+ }
154
+ },
155
155
 
156
- bindEvents : function(table, c, wo){
157
- if (wo.group_collapsible) {
158
- wo.group_currentGroups = [];
159
- // .on() requires jQuery 1.7+
160
- c.$table.on('click toggleGroup keyup', 'tr.group-header', function(event){
161
- event.stopPropagation();
162
- // pressing enter will toggle the group
163
- if (event.type === 'keyup' && event.which !== 13) { return; }
164
- var isCollapsed, $groups, indx,
165
- $this = $(this),
166
- name = $this.find('.group-name').text().toLowerCase();
167
- // use shift-click to toggle ALL groups
168
- if (event.shiftKey && (event.type === 'click' || event.type ==='keyup')) {
169
- $this.siblings('.group-header').trigger('toggleGroup');
170
- }
171
- $this.toggleClass('collapsed');
172
- // nextUntil requires jQuery 1.4+
173
- $this.nextUntil('tr.group-header').toggleClass('group-hidden', $this.hasClass('collapsed') );
174
- // save collapsed groups
175
- if (wo.group_saveGroups && ts.storage) {
176
- $groups = c.$table.find('.group-header');
177
- isCollapsed = $this.hasClass('collapsed');
178
- if (!wo.group_currentGroups[wo.group_currentGroup]) {
179
- wo.group_currentGroups[wo.group_currentGroup] = [];
156
+ bindEvents : function(table, c, wo){
157
+ if (wo.group_collapsible) {
158
+ wo.group_currentGroups = [];
159
+ // .on() requires jQuery 1.7+
160
+ c.$table.on('click toggleGroup keyup', 'tr.group-header', function(event){
161
+ event.stopPropagation();
162
+ // pressing enter will toggle the group
163
+ if (event.type === 'keyup' && event.which !== 13) { return; }
164
+ var isCollapsed, $groups, indx,
165
+ $this = $(this),
166
+ name = $this.find('.group-name').text().toLowerCase();
167
+ // use shift-click to toggle ALL groups
168
+ if (event.shiftKey && (event.type === 'click' || event.type === 'keyup')) {
169
+ $this.siblings('.group-header').trigger('toggleGroup');
180
170
  }
181
- if (isCollapsed && wo.group_currentGroup) {
182
- wo.group_currentGroups[wo.group_currentGroup].push( name );
183
- } else if (wo.group_currentGroup) {
184
- indx = $.inArray( name, wo.group_currentGroups[wo.group_currentGroup] );
185
- if (indx > -1) {
186
- wo.group_currentGroups[wo.group_currentGroup].splice( indx, 1 );
171
+ $this.toggleClass('collapsed');
172
+ // nextUntil requires jQuery 1.4+
173
+ $this.nextUntil('tr.group-header').toggleClass('group-hidden', $this.hasClass('collapsed') );
174
+ // save collapsed groups
175
+ if (wo.group_saveGroups && ts.storage) {
176
+ $groups = c.$table.find('.group-header');
177
+ isCollapsed = $this.hasClass('collapsed');
178
+ if (!wo.group_currentGroups[wo.group_currentGroup]) {
179
+ wo.group_currentGroups[wo.group_currentGroup] = [];
187
180
  }
181
+ if (isCollapsed && wo.group_currentGroup) {
182
+ wo.group_currentGroups[wo.group_currentGroup].push( name );
183
+ } else if (wo.group_currentGroup) {
184
+ indx = $.inArray( name, wo.group_currentGroups[wo.group_currentGroup] );
185
+ if (indx > -1) {
186
+ wo.group_currentGroups[wo.group_currentGroup].splice( indx, 1 );
187
+ }
188
+ }
189
+ ts.storage( table, 'tablesorter-groups', wo.group_currentGroups );
188
190
  }
189
- ts.storage( table, 'tablesorter-groups', wo.group_currentGroups );
190
- }
191
+ });
192
+ }
193
+ $(wo.group_saveReset).on('click', function(){
194
+ ts.grouping.clearSavedGroups(table);
191
195
  });
192
- }
193
- $(wo.group_saveReset).on('click', function(){
194
- ts.grouping.clearSavedGroups(table);
195
- });
196
- c.$table.on('pagerChange.tsgrouping', function(){
197
- ts.grouping.update(table, c, wo);
198
- });
199
- },
196
+ c.$table.on('pagerChange.tsgrouping', function(){
197
+ ts.grouping.update(table, c, wo);
198
+ });
199
+ },
200
200
 
201
- clearSavedGroups: function(table){
202
- if (table && ts.storage) {
203
- ts.storage(table, 'tablesorter-groups', '');
204
- ts.grouping.update(table, table.config, table.config.widgetOptions);
201
+ clearSavedGroups: function(table){
202
+ if (table && ts.storage) {
203
+ ts.storage(table, 'tablesorter-groups', '');
204
+ ts.grouping.update(table, table.config, table.config.widgetOptions);
205
+ }
205
206
  }
206
- }
207
207
 
208
- };
208
+ };
209
209
 
210
- ts.addWidget({
211
- id: 'group',
212
- priority: 100,
213
- options: {
214
- group_collapsible : true, // make the group header clickable and collapse the rows below it.
215
- group_collapsed : false, // start with all groups collapsed
216
- group_saveGroups : true, // remember collapsed groups
217
- group_saveReset : null, // element to clear saved collapsed groups
218
- group_count : ' ({num})', // if not false, the "{num}" string is replaced with the number of rows in the group
219
- group_separator : '-', // group name separator; used when group-separator-# class is used.
220
- group_formatter : null, // function(txt, column, table, c, wo) { return txt; }
221
- group_callback : null, // function($cell, $rows, column, table){}, callback allowing modification of the group header labels
222
- group_complete : 'groupingComplete', // event triggered on the table when the grouping widget has finished work
210
+ ts.addWidget({
211
+ id: 'group',
212
+ priority: 100,
213
+ options: {
214
+ group_collapsible : true, // make the group header clickable and collapse the rows below it.
215
+ group_collapsed : false, // start with all groups collapsed
216
+ group_saveGroups : true, // remember collapsed groups
217
+ group_saveReset : null, // element to clear saved collapsed groups
218
+ group_count : ' ({num})', // if not false, the '{num}' string is replaced with the number of rows in the group
219
+ group_separator : '-', // group name separator; used when group-separator-# class is used.
220
+ group_formatter : null, // function(txt, column, table, c, wo) { return txt; }
221
+ group_callback : null, // function($cell, $rows, column, table){}, callback allowing modification of the group header labels
222
+ group_complete : 'groupingComplete', // event triggered on the table when the grouping widget has finished work
223
223
 
224
- // checkbox parser text used for checked/unchecked values
225
- group_checkbox : [ 'checked', 'unchecked' ],
226
- // change these default date names based on your language preferences
227
- group_months : [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ],
228
- group_week : [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ],
229
- group_time : [ 'AM', 'PM' ],
230
- // this function is used when "group-date" is set to create the date string
231
- // you can just return date, date.toLocaleString(), date.toLocaleDateString() or d.toLocaleTimeString()
232
- // reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#Conversion_getter
233
- group_dateString : function(date) { return date.toLocaleString(); }
234
- },
235
- init: function(table, thisWidget, c, wo){
236
- ts.grouping.bindEvents(table, c, wo);
237
- },
238
- format: function(table, c, wo) {
239
- ts.grouping.update(table, c, wo);
240
- },
241
- remove : function(table, c, wo){
242
- c.$table
243
- .off('click', 'tr.group-header')
244
- .off('pagerChange.tsgrouping')
245
- .find('.group-hidden').removeClass('group-hidden').end()
246
- .find('tr.group-header').remove();
247
- }
248
- });
224
+ // checkbox parser text used for checked/unchecked values
225
+ group_checkbox : [ 'checked', 'unchecked' ],
226
+ // change these default date names based on your language preferences
227
+ group_months : [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ],
228
+ group_week : [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ],
229
+ group_time : [ 'AM', 'PM' ],
230
+ // this function is used when 'group-date' is set to create the date string
231
+ // you can just return date, date.toLocaleString(), date.toLocaleDateString() or d.toLocaleTimeString()
232
+ // reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#Conversion_getter
233
+ group_dateString : function(date) { return date.toLocaleString(); }
234
+ },
235
+ init: function(table, thisWidget, c, wo){
236
+ ts.grouping.bindEvents(table, c, wo);
237
+ },
238
+ format: function(table, c, wo) {
239
+ ts.grouping.update(table, c, wo);
240
+ },
241
+ remove : function(table, c, wo){
242
+ c.$table
243
+ .off('click', 'tr.group-header')
244
+ .off('pagerChange.tsgrouping')
245
+ .find('.group-hidden').removeClass('group-hidden').end()
246
+ .find('tr.group-header').remove();
247
+ }
248
+ });
249
249
 
250
250
  })(jQuery);