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
@@ -10,755 +10,755 @@
10
10
  /*jshint browser:true, jquery:true, unused:false */
11
11
  /*global jQuery: false */
12
12
  ;(function($){
13
- "use strict";
13
+ 'use strict';
14
14
 
15
- var ts = $.tablesorter || {},
15
+ var ts = $.tablesorter || {},
16
16
 
17
- // compare option selector class name (jQuery selector)
18
- compareSelect = '.compare-select',
17
+ // compare option selector class name (jQuery selector)
18
+ compareSelect = '.compare-select',
19
19
 
20
- tsff = ts.filterFormatter = $.extend( {}, ts.filterFormatter, {
20
+ tsff = ts.filterFormatter = $.extend( {}, ts.filterFormatter, {
21
21
 
22
- addCompare: function($cell, indx, options){
23
- if (options.compare && $.isArray(options.compare) && options.compare.length > 1) {
24
- var opt = '',
25
- compareSelectClass = [ compareSelect.slice(1), ' ' + compareSelect.slice(1), '' ],
26
- txt = options.cellText ? '<label class="' + compareSelectClass.join('-label') + indx + '">' + options.cellText + '</label>' : '';
27
- $.each(options.compare, function(i, c){
28
- opt += '<option ' + (options.selected === i ? 'selected' : '') + '>' + c + '</option>';
29
- });
30
- $cell
31
- .wrapInner('<div class="' + compareSelectClass.join('-wrapper') + indx + '" />')
32
- .prepend( txt + '<select class="' + compareSelectClass.join('') + indx + '" />' )
33
- .find('select')
34
- .append(opt);
35
- }
36
- },
37
-
38
- updateCompare : function($cell, $input, o) {
39
- var val = $input.val() || '',
40
- num = val.replace(/\s*?[><=]\s*?/g, ''),
41
- compare = val.match(/[><=]/g) || '';
42
- if (o.compare) {
43
- if ($.isArray(o.compare)){
44
- compare = (compare || []).join('') || o.compare[o.selected || 0];
45
- }
46
- $cell.find(compareSelect).val( compare );
47
- }
48
- return [ val, num ];
49
- },
50
-
51
- /**********************\
52
- jQuery UI Spinner
53
- \**********************/
54
- uiSpinner: function($cell, indx, spinnerDef) {
55
- var o = $.extend({
56
- // filter formatter options
57
- delayed : true,
58
- addToggle : true,
59
- exactMatch : true,
60
- value : 1,
61
- cellText : '',
62
- compare : '',
63
- // include ANY jQuery UI spinner options below
64
- min : 0,
65
- max : 100,
66
- step : 1,
67
- disabled : false
68
-
69
- }, spinnerDef ),
70
- c = $cell.closest('table')[0].config,
71
- // Add a hidden input to hold the range values
72
- $input = $('<input class="filter" type="hidden">')
73
- .appendTo($cell)
74
- // hidden filter update namespace trigger by filter widget
75
- .bind('change' + c.namespace + 'filter', function(){
76
- updateSpinner({ value: this.value, delayed: false });
77
- }),
78
- $shcell = [],
79
-
80
- // this function updates the hidden input and adds the current values to the header cell text
81
- updateSpinner = function(ui, notrigger) {
82
- var chkd = true, state,
83
- // ui is not undefined on create
84
- v = ui && ui.value && ts.formatFloat((ui.value + '').replace(/[><=]/g,'')) ||
85
- $cell.find('.spinner').val() || o.value,
86
- compare = ($.isArray(o.compare) ? $cell.find(compareSelect).val() || o.compare[ o.selected || 0] : o.compare) || '',
87
- searchType = ui && typeof ui.delayed === 'boolean' ? ui.delayed : c.$table[0].hasInitialized ? o.delayed || '' : true;
88
- if (o.addToggle) {
89
- chkd = $cell.find('.toggle').is(':checked');
22
+ addCompare: function($cell, indx, options){
23
+ if (options.compare && $.isArray(options.compare) && options.compare.length > 1) {
24
+ var opt = '',
25
+ compareSelectClass = [ compareSelect.slice(1), ' ' + compareSelect.slice(1), '' ],
26
+ txt = options.cellText ? '<label class="' + compareSelectClass.join('-label') + indx + '">' + options.cellText + '</label>' : '';
27
+ $.each(options.compare, function(i, c){
28
+ opt += '<option ' + (options.selected === i ? 'selected' : '') + '>' + c + '</option>';
29
+ });
30
+ $cell
31
+ .wrapInner('<div class="' + compareSelectClass.join('-wrapper') + indx + '" />')
32
+ .prepend( txt + '<select class="' + compareSelectClass.join('') + indx + '" />' )
33
+ .find('select')
34
+ .append(opt);
90
35
  }
91
- state = o.disabled || !chkd ? 'disable' : 'enable';
92
- $cell.find('.filter')
93
- // add equal to the beginning, so we filter exact numbers
94
- .val( chkd ? (compare ? compare : o.exactMatch ? '=' : '') + v : '' )
95
- .trigger( notrigger ? '' : 'search', searchType ).end()
96
- .find('.spinner').spinner(state).val(v);
97
- // update sticky header cell
98
- if ($shcell.length) {
99
- $shcell
100
- .find('.spinner').spinner(state).val(v).end()
101
- .find(compareSelect).val( compare );
102
- if (o.addToggle) {
103
- $shcell.find('.toggle')[0].checked = chkd;
36
+ },
37
+
38
+ updateCompare : function($cell, $input, o) {
39
+ var val = $input.val() || '',
40
+ num = val.replace(/\s*?[><=]\s*?/g, ''),
41
+ compare = val.match(/[><=]/g) || '';
42
+ if (o.compare) {
43
+ if ($.isArray(o.compare)){
44
+ compare = (compare || []).join('') || o.compare[o.selected || 0];
104
45
  }
46
+ $cell.find(compareSelect).val( compare );
105
47
  }
106
- };
107
-
108
- // add callbacks; preserve added callbacks
109
- o.oldcreate = o.create;
110
- o.oldspin = o.spin;
111
- o.create = function(event, ui) {
112
- updateSpinner(); // ui is an empty object on create
113
- if (typeof o.oldcreate === 'function') { o.oldcreate(event, ui); }
114
- };
115
- o.spin = function(event, ui) {
116
- updateSpinner(ui);
117
- if (typeof o.oldspin === 'function') { o.oldspin(event, ui); }
118
- };
119
- if (o.addToggle) {
120
- $('<div class="button"><input id="uispinnerbutton' + indx + '" type="checkbox" class="toggle" />' +
121
- '<label for="uispinnerbutton' + indx + '"></label></div>')
122
- .appendTo($cell)
123
- .find('.toggle')
124
- .bind('change', function(){
125
- updateSpinner();
126
- });
127
- }
128
- // make sure we use parsed data
129
- $cell.closest('thead').find('th[data-column=' + indx + ']').addClass('filter-parsed');
130
- // add a jQuery UI spinner!
131
- $('<input class="spinner spinner' + indx + '" />')
132
- .val(o.value)
133
- .appendTo($cell)
134
- .spinner(o)
135
- .bind('change keyup', function(){
136
- updateSpinner();
137
- });
138
-
139
- // update spinner from hidden input, in case of saved filters
140
- c.$table.bind('filterFomatterUpdate', function(){
141
- var val = tsff.updateCompare($cell, $input, o)[0];
142
- $cell.find('.spinner').val( val );
143
- updateSpinner({ value: val }, true);
144
- ts.filter.formatterUpdated($cell, indx);
145
- });
146
-
147
- if (o.compare) {
148
- // add compare select
149
- tsff.addCompare($cell, indx, o);
150
- $cell.find(compareSelect).bind('change', function(){
151
- updateSpinner();
152
- });
153
- }
48
+ return [ val, num ];
49
+ },
154
50
 
155
- // has sticky headers?
156
- c.$table.bind('stickyHeadersInit', function(){
157
- $shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
51
+ /**********************\
52
+ jQuery UI Spinner
53
+ \**********************/
54
+ uiSpinner: function($cell, indx, spinnerDef) {
55
+ var o = $.extend({
56
+ // filter formatter options
57
+ delayed : true,
58
+ addToggle : true,
59
+ exactMatch : true,
60
+ value : 1,
61
+ cellText : '',
62
+ compare : '',
63
+ // include ANY jQuery UI spinner options below
64
+ min : 0,
65
+ max : 100,
66
+ step : 1,
67
+ disabled : false
68
+
69
+ }, spinnerDef ),
70
+ c = $cell.closest('table')[0].config,
71
+ // Add a hidden input to hold the range values
72
+ $input = $('<input class="filter" type="hidden">')
73
+ .appendTo($cell)
74
+ // hidden filter update namespace trigger by filter widget
75
+ .bind('change' + c.namespace + 'filter', function(){
76
+ updateSpinner({ value: this.value, delayed: false });
77
+ }),
78
+ $shcell = [],
79
+
80
+ // this function updates the hidden input and adds the current values to the header cell text
81
+ updateSpinner = function(ui, notrigger) {
82
+ var chkd = true, state,
83
+ // ui is not undefined on create
84
+ v = ui && ui.value && ts.formatFloat((ui.value + '').replace(/[><=]/g, '')) ||
85
+ $cell.find('.spinner').val() || o.value,
86
+ compare = ($.isArray(o.compare) ? $cell.find(compareSelect).val() || o.compare[ o.selected || 0] : o.compare) || '',
87
+ searchType = ui && typeof ui.delayed === 'boolean' ? ui.delayed : c.$table[0].hasInitialized ? o.delayed || '' : true;
88
+ if (o.addToggle) {
89
+ chkd = $cell.find('.toggle').is(':checked');
90
+ }
91
+ state = o.disabled || !chkd ? 'disable' : 'enable';
92
+ $cell.find('.filter')
93
+ // add equal to the beginning, so we filter exact numbers
94
+ .val( chkd ? (compare ? compare : o.exactMatch ? '=' : '') + v : '' )
95
+ .trigger( notrigger ? '' : 'search', searchType ).end()
96
+ .find('.spinner').spinner(state).val(v);
97
+ // update sticky header cell
98
+ if ($shcell.length) {
99
+ $shcell
100
+ .find('.spinner').spinner(state).val(v).end()
101
+ .find(compareSelect).val( compare );
102
+ if (o.addToggle) {
103
+ $shcell.find('.toggle')[0].checked = chkd;
104
+ }
105
+ }
106
+ };
107
+
108
+ // add callbacks; preserve added callbacks
109
+ o.oldcreate = o.create;
110
+ o.oldspin = o.spin;
111
+ o.create = function(event, ui) {
112
+ updateSpinner(); // ui is an empty object on create
113
+ if (typeof o.oldcreate === 'function') { o.oldcreate(event, ui); }
114
+ };
115
+ o.spin = function(event, ui) {
116
+ updateSpinner(ui);
117
+ if (typeof o.oldspin === 'function') { o.oldspin(event, ui); }
118
+ };
158
119
  if (o.addToggle) {
159
- $('<div class="button"><input id="stickyuispinnerbutton' + indx + '" type="checkbox" class="toggle" />' +
160
- '<label for="stickyuispinnerbutton' + indx + '"></label></div>')
161
- .appendTo($shcell)
120
+ $('<div class="button"><input id="uispinnerbutton' + indx + '" type="checkbox" class="toggle" />' +
121
+ '<label for="uispinnerbutton' + indx + '"></label></div>')
122
+ .appendTo($cell)
162
123
  .find('.toggle')
163
124
  .bind('change', function(){
164
- $cell.find('.toggle')[0].checked = this.checked;
165
125
  updateSpinner();
166
126
  });
167
127
  }
128
+ // make sure we use parsed data
129
+ $cell.closest('thead').find('th[data-column=' + indx + ']').addClass('filter-parsed');
168
130
  // add a jQuery UI spinner!
169
131
  $('<input class="spinner spinner' + indx + '" />')
170
132
  .val(o.value)
171
- .appendTo($shcell)
133
+ .appendTo($cell)
172
134
  .spinner(o)
173
135
  .bind('change keyup', function(){
174
- $cell.find('.spinner').val( this.value );
175
136
  updateSpinner();
176
137
  });
177
138
 
139
+ // update spinner from hidden input, in case of saved filters
140
+ c.$table.bind('filterFomatterUpdate', function(){
141
+ var val = tsff.updateCompare($cell, $input, o)[0];
142
+ $cell.find('.spinner').val( val );
143
+ updateSpinner({ value: val }, true);
144
+ ts.filter.formatterUpdated($cell, indx);
145
+ });
146
+
178
147
  if (o.compare) {
179
148
  // add compare select
180
- tsff.addCompare($shcell, indx, o);
181
- $shcell.find(compareSelect).bind('change', function(){
182
- $cell.find(compareSelect).val( $(this).val() );
149
+ tsff.addCompare($cell, indx, o);
150
+ $cell.find(compareSelect).bind('change', function(){
183
151
  updateSpinner();
184
152
  });
185
153
  }
186
154
 
187
- });
155
+ // has sticky headers?
156
+ c.$table.bind('stickyHeadersInit', function(){
157
+ $shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
158
+ if (o.addToggle) {
159
+ $('<div class="button"><input id="stickyuispinnerbutton' + indx + '" type="checkbox" class="toggle" />' +
160
+ '<label for="stickyuispinnerbutton' + indx + '"></label></div>')
161
+ .appendTo($shcell)
162
+ .find('.toggle')
163
+ .bind('change', function(){
164
+ $cell.find('.toggle')[0].checked = this.checked;
165
+ updateSpinner();
166
+ });
167
+ }
168
+ // add a jQuery UI spinner!
169
+ $('<input class="spinner spinner' + indx + '" />')
170
+ .val(o.value)
171
+ .appendTo($shcell)
172
+ .spinner(o)
173
+ .bind('change keyup', function(){
174
+ $cell.find('.spinner').val( this.value );
175
+ updateSpinner();
176
+ });
188
177
 
189
- // on reset
190
- c.$table.bind('filterReset', function(){
191
- if ($.isArray(o.compare)) {
192
- $cell.add($shcell).find(compareSelect).val( o.compare[ o.selected || 0 ] );
193
- }
194
- // turn off the toggle checkbox
195
- if (o.addToggle) {
196
- $cell.find('.toggle')[0].checked = false;
197
- }
198
- $cell.find('.spinner').spinner('value', o.value);
199
- setTimeout(function(){
200
- updateSpinner();
201
- }, 0);
202
- });
203
-
204
- updateSpinner();
205
- return $input;
206
- },
207
-
208
- /**********************\
209
- jQuery UI Slider
210
- \**********************/
211
- uiSlider: function($cell, indx, sliderDef) {
212
- var o = $.extend({
213
- // filter formatter options
214
- delayed : true,
215
- valueToHeader : false,
216
- exactMatch : true,
217
- cellText : '',
218
- compare : '',
219
- allText : 'all',
220
- // include ANY jQuery UI spinner options below
221
- // except values, since this is a non-range setup
222
- value : 0,
223
- min : 0,
224
- max : 100,
225
- step : 1,
226
- range : "min"
227
- }, sliderDef ),
228
- c = $cell.closest('table')[0].config,
229
- // Add a hidden input to hold the range values
230
- $input = $('<input class="filter" type="hidden">')
231
- .appendTo($cell)
232
- // hidden filter update namespace trigger by filter widget
233
- .bind('change' + c.namespace + 'filter', function(){
234
- updateSlider({ value: this.value });
235
- }),
236
- $shcell = [],
237
-
238
- // this function updates the hidden input and adds the current values to the header cell text
239
- updateSlider = function(ui, notrigger) {
240
- // ui is not undefined on create
241
- var v = typeof ui !== "undefined" ? ts.formatFloat((ui.value + '').replace(/[><=]/g,'')) || o.value : o.value,
242
- val = o.compare ? v : v === o.min ? o.allText : v,
243
- compare = ($.isArray(o.compare) ? $cell.find(compareSelect).val() || o.compare[ o.selected || 0] : o.compare) || '',
244
- result = compare + val,
245
- searchType = ui && typeof ui.delayed === 'boolean' ? ui.delayed : c.$table[0].hasInitialized ? o.delayed || '' : true;
246
- if (o.valueToHeader) {
247
- // add range indication to the header cell above!
248
- $cell.closest('thead').find('th[data-column=' + indx + ']').find('.curvalue').html(' (' + result + ')');
249
- } else {
250
- // add values to the handle data-value attribute so the css tooltip will work properly
251
- $cell.find('.ui-slider-handle').addClass('value-popup').attr('data-value', result);
252
- }
253
- // update the hidden input;
254
- // ****** ADD AN EQUAL SIGN TO THE BEGINNING! <- this makes the slide exactly match the number ******
255
- // when the value is at the minimum, clear the hidden input so all rows will be seen
178
+ if (o.compare) {
179
+ // add compare select
180
+ tsff.addCompare($shcell, indx, o);
181
+ $shcell.find(compareSelect).bind('change', function(){
182
+ $cell.find(compareSelect).val( $(this).val() );
183
+ updateSpinner();
184
+ });
185
+ }
256
186
 
257
- $cell.find('.filter')
258
- .val( ( compare ? compare + v : v === o.min ? '' : (o.exactMatch ? '=' : '') + v ) )
259
- .trigger( notrigger ? '' : 'search', searchType ).end()
260
- .find('.slider').slider('value', v);
187
+ });
261
188
 
262
- // update sticky header cell
263
- if ($shcell.length) {
264
- $shcell
265
- .find(compareSelect).val( compare ).end()
266
- .find('.slider').slider('value', v);
189
+ // on reset
190
+ c.$table.bind('filterReset', function(){
191
+ if ($.isArray(o.compare)) {
192
+ $cell.add($shcell).find(compareSelect).val( o.compare[ o.selected || 0 ] );
193
+ }
194
+ // turn off the toggle checkbox
195
+ if (o.addToggle) {
196
+ $cell.find('.toggle')[0].checked = false;
197
+ }
198
+ $cell.find('.spinner').spinner('value', o.value);
199
+ setTimeout(function(){
200
+ updateSpinner();
201
+ }, 0);
202
+ });
203
+
204
+ updateSpinner();
205
+ return $input;
206
+ },
207
+
208
+ /**********************\
209
+ jQuery UI Slider
210
+ \**********************/
211
+ uiSlider: function($cell, indx, sliderDef) {
212
+ var o = $.extend({
213
+ // filter formatter options
214
+ delayed : true,
215
+ valueToHeader : false,
216
+ exactMatch : true,
217
+ cellText : '',
218
+ compare : '',
219
+ allText : 'all',
220
+ // include ANY jQuery UI spinner options below
221
+ // except values, since this is a non-range setup
222
+ value : 0,
223
+ min : 0,
224
+ max : 100,
225
+ step : 1,
226
+ range : 'min'
227
+ }, sliderDef ),
228
+ c = $cell.closest('table')[0].config,
229
+ // Add a hidden input to hold the range values
230
+ $input = $('<input class="filter" type="hidden">')
231
+ .appendTo($cell)
232
+ // hidden filter update namespace trigger by filter widget
233
+ .bind('change' + c.namespace + 'filter', function(){
234
+ updateSlider({ value: this.value });
235
+ }),
236
+ $shcell = [],
237
+
238
+ // this function updates the hidden input and adds the current values to the header cell text
239
+ updateSlider = function(ui, notrigger) {
240
+ // ui is not undefined on create
241
+ var v = typeof ui !== 'undefined' ? ts.formatFloat((ui.value + '').replace(/[><=]/g, '')) || o.value : o.value,
242
+ val = o.compare ? v : v === o.min ? o.allText : v,
243
+ compare = ($.isArray(o.compare) ? $cell.find(compareSelect).val() || o.compare[ o.selected || 0] : o.compare) || '',
244
+ result = compare + val,
245
+ searchType = ui && typeof ui.delayed === 'boolean' ? ui.delayed : c.$table[0].hasInitialized ? o.delayed || '' : true;
267
246
  if (o.valueToHeader) {
268
- $shcell.closest('thead').find('th[data-column=' + indx + ']').find('.curvalue').html(' (' + result + ')');
247
+ // add range indication to the header cell above!
248
+ $cell.closest('thead').find('th[data-column=' + indx + ']').find('.curvalue').html(' (' + result + ')');
269
249
  } else {
270
- $shcell.find('.ui-slider-handle').addClass('value-popup').attr('data-value', result);
250
+ // add values to the handle data-value attribute so the css tooltip will work properly
251
+ $cell.find('.ui-slider-handle').addClass('value-popup').attr('data-value', result);
271
252
  }
272
- }
253
+ // update the hidden input;
254
+ // ****** ADD AN EQUAL SIGN TO THE BEGINNING! <- this makes the slide exactly match the number ******
255
+ // when the value is at the minimum, clear the hidden input so all rows will be seen
273
256
 
274
- };
275
- $cell.closest('thead').find('th[data-column=' + indx + ']').addClass('filter-parsed');
257
+ $cell.find('.filter')
258
+ .val( ( compare ? compare + v : v === o.min ? '' : (o.exactMatch ? '=' : '') + v ) )
259
+ .trigger( notrigger ? '' : 'search', searchType ).end()
260
+ .find('.slider').slider('value', v);
276
261
 
277
- // add span to header for value - only works if the line in the updateSlider() function is also un-commented out
278
- if (o.valueToHeader) {
279
- $cell.closest('thead').find('th[data-column=' + indx + ']').find('.tablesorter-header-inner').append('<span class="curvalue" />');
280
- }
262
+ // update sticky header cell
263
+ if ($shcell.length) {
264
+ $shcell
265
+ .find(compareSelect).val( compare ).end()
266
+ .find('.slider').slider('value', v);
267
+ if (o.valueToHeader) {
268
+ $shcell.closest('thead').find('th[data-column=' + indx + ']').find('.curvalue').html(' (' + result + ')');
269
+ } else {
270
+ $shcell.find('.ui-slider-handle').addClass('value-popup').attr('data-value', result);
271
+ }
272
+ }
281
273
 
282
- // add callbacks; preserve added callbacks
283
- o.oldcreate = o.create;
284
- o.oldslide = o.slide;
285
- o.create = function(event, ui) {
286
- updateSlider(); // ui is an empty object on create
287
- if (typeof o.oldcreate === 'function') { o.oldcreate(event, ui); }
288
- };
289
- o.slide = function(event, ui) {
290
- updateSlider(ui);
291
- if (typeof o.oldslide === 'function') { o.oldslide(event, ui); }
292
- };
293
- // add a jQuery UI slider!
294
- $('<div class="slider slider' + indx + '"/>')
295
- .appendTo($cell)
296
- .slider(o);
297
-
298
- // update slider from hidden input, in case of saved filters
299
- c.$table.bind('filterFomatterUpdate', function(){
300
- var val = tsff.updateCompare($cell, $input, o)[0];
301
- $cell.find('.slider').slider('value', val );
302
- updateSlider({ value: val }, false);
303
- ts.filter.formatterUpdated($cell, indx);
304
- });
305
-
306
- if (o.compare) {
307
- // add compare select
308
- tsff.addCompare($cell, indx, o);
309
- $cell.find(compareSelect).bind('change', function(){
310
- updateSlider({ value: $cell.find('.slider').slider('value') });
311
- });
312
- }
274
+ };
275
+ $cell.closest('thead').find('th[data-column=' + indx + ']').addClass('filter-parsed');
313
276
 
314
- // on reset
315
- c.$table.bind('filterReset', function(){
316
- if ($.isArray(o.compare)) {
317
- $cell.add($shcell).find(compareSelect).val( o.compare[ o.selected || 0 ] );
277
+ // add span to header for value - only works if the line in the updateSlider() function is also un-commented out
278
+ if (o.valueToHeader) {
279
+ $cell.closest('thead').find('th[data-column=' + indx + ']').find('.tablesorter-header-inner').append('<span class="curvalue" />');
318
280
  }
319
- setTimeout(function(){
320
- updateSlider({ value: o.value });
321
- }, 0);
322
- });
323
-
324
- // has sticky headers?
325
- c.$table.bind('stickyHeadersInit', function(){
326
- $shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
327
281
 
282
+ // add callbacks; preserve added callbacks
283
+ o.oldcreate = o.create;
284
+ o.oldslide = o.slide;
285
+ o.create = function(event, ui) {
286
+ updateSlider(); // ui is an empty object on create
287
+ if (typeof o.oldcreate === 'function') { o.oldcreate(event, ui); }
288
+ };
289
+ o.slide = function(event, ui) {
290
+ updateSlider(ui);
291
+ if (typeof o.oldslide === 'function') { o.oldslide(event, ui); }
292
+ };
328
293
  // add a jQuery UI slider!
329
294
  $('<div class="slider slider' + indx + '"/>')
330
- .val(o.value)
331
- .appendTo($shcell)
332
- .slider(o)
333
- .bind('change keyup', function(){
334
- $cell.find('.slider').slider('value', this.value );
335
- updateSlider();
336
- });
295
+ .appendTo($cell)
296
+ .slider(o);
297
+
298
+ // update slider from hidden input, in case of saved filters
299
+ c.$table.bind('filterFomatterUpdate', function(){
300
+ var val = tsff.updateCompare($cell, $input, o)[0];
301
+ $cell.find('.slider').slider('value', val );
302
+ updateSlider({ value: val }, false);
303
+ ts.filter.formatterUpdated($cell, indx);
304
+ });
337
305
 
338
306
  if (o.compare) {
339
307
  // add compare select
340
- tsff.addCompare($shcell, indx, o);
341
- $shcell.find(compareSelect).bind('change', function(){
342
- $cell.find(compareSelect).val( $(this).val() );
343
- updateSlider();
308
+ tsff.addCompare($cell, indx, o);
309
+ $cell.find(compareSelect).bind('change', function(){
310
+ updateSlider({ value: $cell.find('.slider').slider('value') });
344
311
  });
345
312
  }
346
313
 
347
- });
348
-
349
- return $input;
350
- },
351
-
352
- /*************************\
353
- jQuery UI Range Slider (2 handles)
354
- \*************************/
355
- uiRange: function($cell, indx, rangeDef) {
356
- var o = $.extend({
357
- // filter formatter options
358
- delayed : true,
359
- valueToHeader : false,
360
- // include ANY jQuery UI spinner options below
361
- // except value, since this one is range specific)
362
- values : [0, 100],
363
- min : 0,
364
- max : 100,
365
- range : true
366
- }, rangeDef ),
367
- c = $cell.closest('table')[0].config,
368
- // Add a hidden input to hold the range values
369
- $input = $('<input class="filter" type="hidden">')
370
- .appendTo($cell)
371
- // hidden filter update namespace trigger by filter widget
372
- .bind('change' + c.namespace + 'filter', function(){
373
- getRange();
374
- }),
375
- $shcell = [],
376
-
377
- getRange = function(){
378
- var val = $input.val(),
379
- v = val.split(' - ');
380
- if (val === '') { v = [ o.min, o.max ]; }
381
- if (v && v[1]) {
382
- updateUiRange({ values: v, delay: false }, true);
383
- }
314
+ // on reset
315
+ c.$table.bind('filterReset', function(){
316
+ if ($.isArray(o.compare)) {
317
+ $cell.add($shcell).find(compareSelect).val( o.compare[ o.selected || 0 ] );
318
+ }
319
+ setTimeout(function(){
320
+ updateSlider({ value: o.value });
321
+ }, 0);
322
+ });
323
+
324
+ // has sticky headers?
325
+ c.$table.bind('stickyHeadersInit', function(){
326
+ $shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
327
+
328
+ // add a jQuery UI slider!
329
+ $('<div class="slider slider' + indx + '"/>')
330
+ .val(o.value)
331
+ .appendTo($shcell)
332
+ .slider(o)
333
+ .bind('change keyup', function(){
334
+ $cell.find('.slider').slider('value', this.value );
335
+ updateSlider();
336
+ });
337
+
338
+ if (o.compare) {
339
+ // add compare select
340
+ tsff.addCompare($shcell, indx, o);
341
+ $shcell.find(compareSelect).bind('change', function(){
342
+ $cell.find(compareSelect).val( $(this).val() );
343
+ updateSlider();
344
+ });
345
+ }
346
+
347
+ });
348
+
349
+ return $input;
384
350
  },
385
351
 
386
- // this function updates the hidden input and adds the current values to the header cell text
387
- updateUiRange = function(ui, notrigger) {
388
- // ui.values are undefined for some reason on create
389
- var val = ui && ui.values || o.values,
390
- result = val[0] + ' - ' + val[1],
391
- // make range an empty string if entire range is covered so the filter row will hide (if set)
392
- range = val[0] === o.min && val[1] === o.max ? '' : result,
393
- searchType = ui && typeof ui.delayed === 'boolean' ? ui.delayed : c.$table[0].hasInitialized ? o.delayed || '': true;
394
- if (o.valueToHeader) {
395
- // add range indication to the header cell above (if not using the css method)!
396
- $cell.closest('thead').find('th[data-column=' + indx + ']').find('.currange').html(' (' + result + ')');
397
- } else {
398
- // add values to the handle data-value attribute so the css tooltip will work properly
399
- $cell.find('.ui-slider-handle')
400
- .addClass('value-popup')
401
- .eq(0).attr('data-value', val[0]).end() // adding value to data attribute
402
- .eq(1).attr('data-value', val[1]); // value popup shown via css
403
- }
404
- // update the hidden input
405
- $cell.find('.filter').val(range)
406
- .trigger(notrigger ? '' : 'search', searchType).end()
407
- .find('.range').slider('values', val);
408
- // update sticky header cell
409
- if ($shcell.length) {
410
- $shcell.find('.range').slider('values', val);
352
+ /*************************\
353
+ jQuery UI Range Slider (2 handles)
354
+ \*************************/
355
+ uiRange: function($cell, indx, rangeDef) {
356
+ var o = $.extend({
357
+ // filter formatter options
358
+ delayed : true,
359
+ valueToHeader : false,
360
+ // include ANY jQuery UI spinner options below
361
+ // except value, since this one is range specific)
362
+ values : [ 0, 100 ],
363
+ min : 0,
364
+ max : 100,
365
+ range : true
366
+ }, rangeDef ),
367
+ c = $cell.closest('table')[0].config,
368
+ // Add a hidden input to hold the range values
369
+ $input = $('<input class="filter" type="hidden">')
370
+ .appendTo($cell)
371
+ // hidden filter update namespace trigger by filter widget
372
+ .bind('change' + c.namespace + 'filter', function(){
373
+ getRange();
374
+ }),
375
+ $shcell = [],
376
+
377
+ getRange = function(){
378
+ var val = $input.val(),
379
+ v = val.split(' - ');
380
+ if (val === '') { v = [ o.min, o.max ]; }
381
+ if (v && v[1]) {
382
+ updateUiRange({ values: v, delay: false }, true);
383
+ }
384
+ },
385
+
386
+ // this function updates the hidden input and adds the current values to the header cell text
387
+ updateUiRange = function(ui, notrigger) {
388
+ // ui.values are undefined for some reason on create
389
+ var val = ui && ui.values || o.values,
390
+ result = val[0] + ' - ' + val[1],
391
+ // make range an empty string if entire range is covered so the filter row will hide (if set)
392
+ range = val[0] === o.min && val[1] === o.max ? '' : result,
393
+ searchType = ui && typeof ui.delayed === 'boolean' ? ui.delayed : c.$table[0].hasInitialized ? o.delayed || '' : true;
411
394
  if (o.valueToHeader) {
412
- $shcell.closest('thead').find('th[data-column=' + indx + ']').find('.currange').html(' (' + result + ')');
395
+ // add range indication to the header cell above (if not using the css method)!
396
+ $cell.closest('thead').find('th[data-column=' + indx + ']').find('.currange').html(' (' + result + ')');
413
397
  } else {
414
- $shcell.find('.ui-slider-handle')
415
- .addClass('value-popup')
416
- .eq(0).attr('data-value', val[0]).end() // adding value to data attribute
417
- .eq(1).attr('data-value', val[1]); // value popup shown via css
398
+ // add values to the handle data-value attribute so the css tooltip will work properly
399
+ $cell.find('.ui-slider-handle')
400
+ .addClass('value-popup')
401
+ .eq(0).attr('data-value', val[0]).end() // adding value to data attribute
402
+ .eq(1).attr('data-value', val[1]); // value popup shown via css
403
+ }
404
+ // update the hidden input
405
+ $cell.find('.filter').val(range)
406
+ .trigger(notrigger ? '' : 'search', searchType).end()
407
+ .find('.range').slider('values', val);
408
+ // update sticky header cell
409
+ if ($shcell.length) {
410
+ $shcell.find('.range').slider('values', val);
411
+ if (o.valueToHeader) {
412
+ $shcell.closest('thead').find('th[data-column=' + indx + ']').find('.currange').html(' (' + result + ')');
413
+ } else {
414
+ $shcell.find('.ui-slider-handle')
415
+ .addClass('value-popup')
416
+ .eq(0).attr('data-value', val[0]).end() // adding value to data attribute
417
+ .eq(1).attr('data-value', val[1]); // value popup shown via css
418
+ }
418
419
  }
420
+
421
+ };
422
+ $cell.closest('thead').find('th[data-column=' + indx + ']').addClass('filter-parsed');
423
+
424
+ // add span to header for value - only works if the line in the updateUiRange() function is also un-commented out
425
+ if (o.valueToHeader) {
426
+ $cell.closest('thead').find('th[data-column=' + indx + ']').find('.tablesorter-header-inner').append('<span class="currange"/>');
419
427
  }
420
428
 
421
- };
422
- $cell.closest('thead').find('th[data-column=' + indx + ']').addClass('filter-parsed');
429
+ // add callbacks; preserve added callbacks
430
+ o.oldcreate = o.create;
431
+ o.oldslide = o.slide;
432
+ // add a jQuery UI range slider!
433
+ o.create = function(event, ui) {
434
+ updateUiRange(); // ui is an empty object on create
435
+ if (typeof o.oldcreate === 'function') { o.oldcreate(event, ui); }
436
+ };
437
+ o.slide = function(event, ui) {
438
+ updateUiRange(ui);
439
+ if (typeof o.oldslide === 'function') { o.oldslide(event, ui); }
440
+ };
441
+ $('<div class="range range' + indx + '"/>')
442
+ .appendTo($cell)
443
+ .slider(o);
423
444
 
424
- // add span to header for value - only works if the line in the updateUiRange() function is also un-commented out
425
- if (o.valueToHeader) {
426
- $cell.closest('thead').find('th[data-column=' + indx + ']').find('.tablesorter-header-inner').append('<span class="currange"/>');
427
- }
445
+ // update slider from hidden input, in case of saved filters
446
+ c.$table.bind('filterFomatterUpdate', function(){
447
+ getRange();
448
+ ts.filter.formatterUpdated($cell, indx);
449
+ });
450
+
451
+ // on reset
452
+ c.$table.bind('filterReset', function(){
453
+ $cell.find('.range').slider('values', o.values);
454
+ setTimeout(function(){
455
+ updateUiRange();
456
+ }, 0);
457
+ });
458
+
459
+ // has sticky headers?
460
+ c.$table.bind('stickyHeadersInit', function(){
461
+ $shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
462
+
463
+ // add a jQuery UI slider!
464
+ $('<div class="range range' + indx + '"/>')
465
+ .val(o.value)
466
+ .appendTo($shcell)
467
+ .slider(o)
468
+ .bind('change keyup', function(){
469
+ $cell.find('.range').val( this.value );
470
+ updateUiRange();
471
+ });
428
472
 
429
- // add callbacks; preserve added callbacks
430
- o.oldcreate = o.create;
431
- o.oldslide = o.slide;
432
- // add a jQuery UI range slider!
433
- o.create = function(event, ui) {
434
- updateUiRange(); // ui is an empty object on create
435
- if (typeof o.oldcreate === 'function') { o.oldcreate(event, ui); }
436
- };
437
- o.slide = function(event, ui) {
438
- updateUiRange(ui);
439
- if (typeof o.oldslide === 'function') { o.oldslide(event, ui); }
440
- };
441
- $('<div class="range range' + indx +'"/>')
442
- .appendTo($cell)
443
- .slider(o);
444
-
445
- // update slider from hidden input, in case of saved filters
446
- c.$table.bind('filterFomatterUpdate', function(){
447
- getRange();
448
- ts.filter.formatterUpdated($cell, indx);
449
- });
450
-
451
- // on reset
452
- c.$table.bind('filterReset', function(){
453
- $cell.find('.range').slider('values', o.values);
454
- setTimeout(function(){
455
- updateUiRange();
456
- }, 0);
457
- });
458
-
459
- // has sticky headers?
460
- c.$table.bind('stickyHeadersInit', function(){
461
- $shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
462
-
463
- // add a jQuery UI slider!
464
- $('<div class="range range' + indx + '"/>')
465
- .val(o.value)
466
- .appendTo($shcell)
467
- .slider(o)
468
- .bind('change keyup', function(){
469
- $cell.find('.range').val( this.value );
470
- updateUiRange();
471
473
  });
472
474
 
473
- });
474
-
475
- // return the hidden input so the filter widget has a reference to it
476
- return $input;
477
- },
478
-
479
- /*************************\
480
- jQuery UI Datepicker compare (1 input)
481
- \*************************/
482
- uiDateCompare: function($cell, indx, defDate) {
483
- var o = $.extend({
484
- // filter formatter options
485
- cellText : '',
486
- compare : '',
487
- endOfDay : true,
488
- // include ANY jQuery UI spinner options below
489
-
490
- defaultDate : '',
491
-
492
- changeMonth : true,
493
- changeYear : true,
494
- numberOfMonths : 1
495
- }, defDate),
496
-
497
- $date,
498
- c = $cell.closest('table')[0].config,
499
- // make sure we're using parsed dates in the search
500
- $hdr = $cell.closest('thead').find('th[data-column=' + indx + ']').addClass('filter-parsed'),
501
- // Add a hidden input to hold the range values
502
- $input = $('<input class="dateCompare" type="hidden">')
503
- .appendTo($cell)
504
- // hidden filter update namespace trigger by filter widget
505
- .bind('change' + c.namespace + 'filter', function(){
506
- var v = this.value;
507
- if (v) {
508
- o.onClose(v);
475
+ // return the hidden input so the filter widget has a reference to it
476
+ return $input;
477
+ },
478
+
479
+ /*************************\
480
+ jQuery UI Datepicker compare (1 input)
481
+ \*************************/
482
+ uiDateCompare: function($cell, indx, defDate) {
483
+ var o = $.extend({
484
+ // filter formatter options
485
+ cellText : '',
486
+ compare : '',
487
+ endOfDay : true,
488
+ // include ANY jQuery UI spinner options below
489
+
490
+ defaultDate : '',
491
+
492
+ changeMonth : true,
493
+ changeYear : true,
494
+ numberOfMonths : 1
495
+ }, defDate),
496
+
497
+ $date,
498
+ c = $cell.closest('table')[0].config,
499
+ // make sure we're using parsed dates in the search
500
+ $hdr = $cell.closest('thead').find('th[data-column=' + indx + ']').addClass('filter-parsed'),
501
+ // Add a hidden input to hold the range values
502
+ $input = $('<input class="dateCompare" type="hidden">')
503
+ .appendTo($cell)
504
+ // hidden filter update namespace trigger by filter widget
505
+ .bind('change' + c.namespace + 'filter', function(){
506
+ var v = this.value;
507
+ if (v) {
508
+ o.onClose(v);
509
+ }
510
+ }),
511
+ t, $shcell = [],
512
+
513
+ // this function updates the hidden input
514
+ date1Compare = function(notrigger) {
515
+ var date, query,
516
+ getdate = $date.datepicker('getDate') || '',
517
+ compare = ($.isArray(o.compare) ? $cell.find(compareSelect).val() || o.compare[ o.selected || 0] : o.compare) || '',
518
+ searchType = c.$table[0].hasInitialized ? o.delayed || '' : true;
519
+ $date.datepicker('setDate', (getdate === '' ? '' : getdate) || null);
520
+ if (getdate === '') { notrigger = false; }
521
+ date = $date.datepicker('getDate');
522
+ query = date ? ( o.endOfDay && /<=/.test(compare) ? date.setHours(23, 59, 59) : date.getTime() ) || '' : '';
523
+ if (date && o.endOfDay && compare === '=') {
524
+ compare = '';
525
+ query += ' - ' + date.setHours(23, 59, 59);
526
+ notrigger = false;
509
527
  }
510
- }),
511
- t, $shcell = [],
512
-
513
- // this function updates the hidden input
514
- date1Compare = function(notrigger) {
515
- var date, query,
516
- getdate = $date.datepicker('getDate') || '',
517
- compare = ($.isArray(o.compare) ? $cell.find(compareSelect).val() || o.compare[ o.selected || 0] : o.compare) || '',
518
- searchType = c.$table[0].hasInitialized ? o.delayed || '': true;
519
- $date.datepicker('setDate', (getdate === '' ? '' : getdate) || null);
520
- if (getdate === '') { notrigger = false; }
521
- date = $date.datepicker('getDate');
522
- query = date ? ( o.endOfDay && /<=/.test(compare) ? date.setHours(23, 59, 59) : date.getTime() ) || '' : '';
523
- if (date && o.endOfDay && compare === '=') {
524
- compare = '';
525
- query += ' - ' + date.setHours(23, 59, 59);
526
- notrigger = false;
527
- }
528
- $cell.find('.dateCompare')
529
- // add equal to the beginning, so we filter exact numbers
530
- .val(compare + query)
531
- .trigger( notrigger ? '' : 'search', searchType ).end();
532
- // update sticky header cell
533
- if ($shcell.length) {
534
- $shcell
535
- .find('.dateCompare').val(compare + query).end()
536
- .find(compareSelect).val(compare);
537
- }
538
- };
539
-
540
- // Add date range picker
541
- t = '<input type="text" class="date date' + indx + '" placeholder="' +
542
- ($hdr.data('placeholder') || $hdr.attr('data-placeholder') || c.widgetOptions.filter_placeholder.search || '') + '" />';
543
- $date = $(t).appendTo($cell);
544
-
545
- // add callbacks; preserve added callbacks
546
- o.oldonClose = o.onClose;
547
-
548
- o.onClose = function( selectedDate, ui ) {
549
- date1Compare();
550
- if (typeof o.oldonClose === 'function') { o.oldonClose(selectedDate, ui); }
551
- };
552
- $date.datepicker(o);
553
-
554
- // on reset
555
- c.$table.bind('filterReset', function(){
556
- if ($.isArray(o.compare)) {
557
- $cell.add($shcell).find(compareSelect).val( o.compare[ o.selected || 0 ] );
558
- }
559
- $cell.add($shcell).find('.date').val(o.defaultDate).datepicker('setDate', o.defaultDate || null);
560
- setTimeout(function(){
561
- date1Compare();
562
- }, 0);
563
- });
564
-
565
- // update date compare from hidden input, in case of saved filters
566
- c.$table.bind('filterFomatterUpdate', function(){
567
- var num, v = $input.val();
568
- if (/\s+-\s+/.test(v)) {
569
- // date range found; assume an exact match on one day
570
- $cell.find(compareSelect).val('=');
571
- num = v.split(/\s+-\s+/)[0];
572
- $date.datepicker( 'setDate', num || null );
573
- } else {
574
- num = (tsff.updateCompare($cell, $input, o)[1]).toString() || '';
575
- // differeniate 1388556000000 from 1/1/2014 using \d{5} regex
576
- num = num !== '' ? /\d{5}/g.test(num) ? new Date(Number(num)) : num || '' : '';
577
- }
578
- $cell.add($shcell).find('.date').datepicker( 'setDate', num || null );
579
- setTimeout(function(){
580
- date1Compare(true);
581
- ts.filter.formatterUpdated($cell, indx);
582
- }, 0);
583
- });
528
+ $cell.find('.dateCompare')
529
+ // add equal to the beginning, so we filter exact numbers
530
+ .val(compare + query)
531
+ .trigger( notrigger ? '' : 'search', searchType ).end();
532
+ // update sticky header cell
533
+ if ($shcell.length) {
534
+ $shcell
535
+ .find('.dateCompare').val(compare + query).end()
536
+ .find(compareSelect).val(compare);
537
+ }
538
+ };
539
+
540
+ // Add date range picker
541
+ t = '<input type="text" class="date date' + indx + '" placeholder="' +
542
+ ($hdr.data('placeholder') || $hdr.attr('data-placeholder') || c.widgetOptions.filter_placeholder.search || '') + '" />';
543
+ $date = $(t).appendTo($cell);
544
+
545
+ // add callbacks; preserve added callbacks
546
+ o.oldonClose = o.onClose;
584
547
 
585
- if (o.compare) {
586
- // add compare select
587
- tsff.addCompare($cell, indx, o);
588
- $cell.find(compareSelect).bind('change', function(){
548
+ o.onClose = function( selectedDate, ui ) {
589
549
  date1Compare();
550
+ if (typeof o.oldonClose === 'function') { o.oldonClose(selectedDate, ui); }
551
+ };
552
+ $date.datepicker(o);
553
+
554
+ // on reset
555
+ c.$table.bind('filterReset', function(){
556
+ if ($.isArray(o.compare)) {
557
+ $cell.add($shcell).find(compareSelect).val( o.compare[ o.selected || 0 ] );
558
+ }
559
+ $cell.add($shcell).find('.date').val(o.defaultDate).datepicker('setDate', o.defaultDate || null);
560
+ setTimeout(function(){
561
+ date1Compare();
562
+ }, 0);
590
563
  });
591
- }
592
564
 
593
- // has sticky headers?
594
- c.$table.bind('stickyHeadersInit', function(){
595
- $shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
596
-
597
- // add a jQuery datepicker!
598
- $shcell
599
- .append(t)
600
- .find('.date')
601
- .datepicker(o);
565
+ // update date compare from hidden input, in case of saved filters
566
+ c.$table.bind('filterFomatterUpdate', function(){
567
+ var num, v = $input.val();
568
+ if (/\s+-\s+/.test(v)) {
569
+ // date range found; assume an exact match on one day
570
+ $cell.find(compareSelect).val('=');
571
+ num = v.split(/\s+-\s+/)[0];
572
+ $date.datepicker( 'setDate', num || null );
573
+ } else {
574
+ num = (tsff.updateCompare($cell, $input, o)[1]).toString() || '';
575
+ // differeniate 1388556000000 from 1/1/2014 using \d{5} regex
576
+ num = num !== '' ? /\d{5}/g.test(num) ? new Date(Number(num)) : num || '' : '';
577
+ }
578
+ $cell.add($shcell).find('.date').datepicker( 'setDate', num || null );
579
+ setTimeout(function(){
580
+ date1Compare(true);
581
+ ts.filter.formatterUpdated($cell, indx);
582
+ }, 0);
583
+ });
602
584
 
603
585
  if (o.compare) {
604
586
  // add compare select
605
- tsff.addCompare($shcell, indx, o);
606
- $shcell.find(compareSelect).bind('change', function(){
607
- $cell.find(compareSelect).val( $(this).val() );
587
+ tsff.addCompare($cell, indx, o);
588
+ $cell.find(compareSelect).bind('change', function(){
608
589
  date1Compare();
609
590
  });
610
591
  }
611
592
 
612
- });
613
-
614
- // return the hidden input so the filter widget has a reference to it
615
- return $input.val( o.defaultDate ? o.defaultDate : '' );
616
- },
617
-
618
- /*************************\
619
- jQuery UI Datepicker (2 inputs)
620
- \*************************/
621
- uiDatepicker: function($cell, indx, defDate) {
622
- var o = $.extend({
623
- // filter formatter options
624
- endOfDay : true,
625
- textFrom : 'from',
626
- textTo : 'to',
627
- from : '', // defaultDate "from" input
628
- to : '', // defaultDate "to" input
629
- // include ANY jQuery UI spinner options below
630
- changeMonth : true,
631
- changeYear : true,
632
- numberOfMonths : 1
633
- }, defDate),
634
- t, closeDate, $shcell = [],
635
- c = $cell.closest('table')[0].config,
636
- validDate = function(d){
637
- return d instanceof Date && isFinite(d);
638
- },
639
- // Add a hidden input to hold the range values
640
- $input = $('<input class="dateRange" type="hidden">')
641
- .appendTo($cell)
642
- // hidden filter update namespace trigger by filter widget
643
- .bind('change' + c.namespace + 'filter', function(){
644
- var v = this.value;
645
- if (v.match(' - ')) {
646
- v = v.split(' - ');
647
- $cell.find('.dateTo').val(v[1]);
648
- closeDate(v[0]);
649
- } else if (v.match('>=')) {
650
- closeDate( v.replace('>=', '') );
651
- } else if (v.match('<=')) {
652
- closeDate( v.replace('<=', '') );
593
+ // has sticky headers?
594
+ c.$table.bind('stickyHeadersInit', function(){
595
+ $shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
596
+
597
+ // add a jQuery datepicker!
598
+ $shcell
599
+ .append(t)
600
+ .find('.date')
601
+ .datepicker(o);
602
+
603
+ if (o.compare) {
604
+ // add compare select
605
+ tsff.addCompare($shcell, indx, o);
606
+ $shcell.find(compareSelect).bind('change', function(){
607
+ $cell.find(compareSelect).val( $(this).val() );
608
+ date1Compare();
609
+ });
653
610
  }
654
- }),
655
-
656
- // make sure we're using parsed dates in the search
657
- $hdr = $cell.closest('thead').find('th[data-column=' + indx + ']').addClass('filter-parsed');
658
- // Add date range picker
659
- t = '<label>' + o.textFrom + '</label><input type="text" class="dateFrom" placeholder="' +
660
- ($hdr.data('placeholderFrom') || $hdr.attr('data-placeholder-from') || c.widgetOptions.filter_placeholder.from || '') + '" />' +
661
- '<label>' + o.textTo + '</label><input type="text" class="dateTo" placeholder="' +
662
- ($hdr.data('placeholderTo') || $hdr.attr('data-placeholder-to') || c.widgetOptions.filter_placeholder.to || '') + '" />';
663
- $(t).appendTo($cell);
664
-
665
- // add callbacks; preserve added callbacks
666
- o.oldonClose = o.onClose;
667
-
668
- closeDate = o.onClose = function( selectedDate, ui ) {
669
- var range,
670
- from = $cell.find('.dateFrom').datepicker('getDate'),
671
- to = $cell.find('.dateTo').datepicker('getDate');
672
- from = validDate(from) ? from.getTime() : '';
673
- to = validDate(to) ? ( o.endOfDay ? to.setHours(23, 59, 59) : to.getTime() ) || '' : '';
674
- range = from ? ( to ? from + ' - ' + to : '>=' + from ) : (to ? '<=' + to : '');
675
- $cell.add( $shcell )
676
- .find('.dateRange').val(range)
677
- .trigger('search');
678
- // date picker needs date objects
679
- from = from ? new Date(from) : '';
680
- to = to ? new Date(to) : '';
681
-
682
- if (/<=/.test(range)) {
683
- $cell.add( $shcell )
684
- .find('.dateFrom').datepicker('option', 'maxDate', to || null ).end()
685
- .find('.dateTo').datepicker('option', 'minDate', null).datepicker('setDate', to || null);
686
- } else if (/>=/.test(range)) {
687
- $cell.add( $shcell )
688
- .find('.dateFrom').datepicker('option', 'maxDate', null).datepicker('setDate', from || null).end()
689
- .find('.dateTo').datepicker('option', 'minDate', from || null );
690
- } else {
691
- $cell.add( $shcell )
692
- .find('.dateFrom').datepicker('option', 'maxDate', null).datepicker('setDate', from || null ).end()
693
- .find('.dateTo').datepicker('option', 'minDate', null).datepicker('setDate', to || null);
694
- }
695
611
 
696
- if (typeof o.oldonClose === 'function') { o.oldonClose(selectedDate, ui); }
697
- };
612
+ });
698
613
 
699
- o.defaultDate = o.from || '';
700
- $cell.find('.dateFrom').datepicker(o);
701
- o.defaultDate = o.to || '+7d'; // set to date +7 days from today (if not defined)
702
- $cell.find('.dateTo').datepicker(o);
614
+ // return the hidden input so the filter widget has a reference to it
615
+ return $input.val( o.defaultDate ? o.defaultDate : '' );
616
+ },
703
617
 
704
- // update date compare from hidden input, in case of saved filters
705
- c.$table.bind('filterFomatterUpdate', function(){
706
- var val = $input.val() || '',
707
- from = '',
708
- to = '';
709
- // date range
710
- if (/\s+-\s+/.test(val)){
711
- val = val.split(/\s+-\s+/) || [];
712
- from = val[0] || '';
713
- to = val[1] || '';
714
- } else if (/>=/.test(val)) {
715
- // greater than date (to date empty)
716
- from = val.replace(/>=/, '') || '';
717
- } else if (/<=/.test(val)) {
718
- // less than date (from date empty)
719
- to = val.replace(/<=/, '') || '';
720
- }
618
+ /*************************\
619
+ jQuery UI Datepicker (2 inputs)
620
+ \*************************/
621
+ uiDatepicker: function($cell, indx, defDate) {
622
+ var o = $.extend({
623
+ // filter formatter options
624
+ endOfDay : true,
625
+ textFrom : 'from',
626
+ textTo : 'to',
627
+ from : '', // defaultDate 'from' input
628
+ to : '', // defaultDate 'to' input
629
+ // include ANY jQuery UI spinner options below
630
+ changeMonth : true,
631
+ changeYear : true,
632
+ numberOfMonths : 1
633
+ }, defDate),
634
+ t, closeDate, $shcell = [],
635
+ c = $cell.closest('table')[0].config,
636
+ validDate = function(d){
637
+ return d instanceof Date && isFinite(d);
638
+ },
639
+ // Add a hidden input to hold the range values
640
+ $input = $('<input class="dateRange" type="hidden">')
641
+ .appendTo($cell)
642
+ // hidden filter update namespace trigger by filter widget
643
+ .bind('change' + c.namespace + 'filter', function(){
644
+ var v = this.value;
645
+ if (v.match(' - ')) {
646
+ v = v.split(' - ');
647
+ $cell.find('.dateTo').val(v[1]);
648
+ closeDate(v[0]);
649
+ } else if (v.match('>=')) {
650
+ closeDate( v.replace('>=', '') );
651
+ } else if (v.match('<=')) {
652
+ closeDate( v.replace('<=', '') );
653
+ }
654
+ }),
655
+
656
+ // make sure we're using parsed dates in the search
657
+ $hdr = $cell.closest('thead').find('th[data-column=' + indx + ']').addClass('filter-parsed');
658
+ // Add date range picker
659
+ t = '<label>' + o.textFrom + '</label><input type="text" class="dateFrom" placeholder="' +
660
+ ($hdr.data('placeholderFrom') || $hdr.attr('data-placeholder-from') || c.widgetOptions.filter_placeholder.from || '') + '" />' +
661
+ '<label>' + o.textTo + '</label><input type="text" class="dateTo" placeholder="' +
662
+ ($hdr.data('placeholderTo') || $hdr.attr('data-placeholder-to') || c.widgetOptions.filter_placeholder.to || '') + '" />';
663
+ $(t).appendTo($cell);
664
+
665
+ // add callbacks; preserve added callbacks
666
+ o.oldonClose = o.onClose;
667
+
668
+ closeDate = o.onClose = function( selectedDate, ui ) {
669
+ var range,
670
+ from = $cell.find('.dateFrom').datepicker('getDate'),
671
+ to = $cell.find('.dateTo').datepicker('getDate');
672
+ from = validDate(from) ? from.getTime() : '';
673
+ to = validDate(to) ? ( o.endOfDay ? to.setHours(23, 59, 59) : to.getTime() ) || '' : '';
674
+ range = from ? ( to ? from + ' - ' + to : '>=' + from ) : (to ? '<=' + to : '');
675
+ $cell.add( $shcell )
676
+ .find('.dateRange').val(range)
677
+ .trigger('search');
678
+ // date picker needs date objects
679
+ from = from ? new Date(from) : '';
680
+ to = to ? new Date(to) : '';
681
+
682
+ if (/<=/.test(range)) {
683
+ $cell.add( $shcell )
684
+ .find('.dateFrom').datepicker('option', 'maxDate', to || null ).end()
685
+ .find('.dateTo').datepicker('option', 'minDate', null).datepicker('setDate', to || null);
686
+ } else if (/>=/.test(range)) {
687
+ $cell.add( $shcell )
688
+ .find('.dateFrom').datepicker('option', 'maxDate', null).datepicker('setDate', from || null).end()
689
+ .find('.dateTo').datepicker('option', 'minDate', from || null );
690
+ } else {
691
+ $cell.add( $shcell )
692
+ .find('.dateFrom').datepicker('option', 'maxDate', null).datepicker('setDate', from || null ).end()
693
+ .find('.dateTo').datepicker('option', 'minDate', null).datepicker('setDate', to || null);
694
+ }
721
695
 
722
- // differeniate 1388556000000 from 1/1/2014 using \d{5} regex
723
- from = from !== '' ? /\d{5}/g.test(from) ? new Date(Number(from)) : from || '' : '';
724
- to = to !== '' ? /\d{5}/g.test(to) ? new Date(Number(to)) : to || '' : '';
696
+ if (typeof o.oldonClose === 'function') { o.oldonClose(selectedDate, ui); }
697
+ };
725
698
 
726
- $cell.add($shcell).find('.dateFrom').datepicker('setDate', from || null);
727
- $cell.add($shcell).find('.dateTo').datepicker('setDate', to || null);
728
- // give datepicker time to process
729
- setTimeout(function(){
730
- closeDate();
731
- ts.filter.formatterUpdated($cell, indx);
732
- }, 0);
733
- });
699
+ o.defaultDate = o.from || '';
700
+ $cell.find('.dateFrom').datepicker(o);
701
+ o.defaultDate = o.to || '+7d'; // set to date +7 days from today (if not defined)
702
+ $cell.find('.dateTo').datepicker(o);
703
+
704
+ // update date compare from hidden input, in case of saved filters
705
+ c.$table.bind('filterFomatterUpdate', function(){
706
+ var val = $input.val() || '',
707
+ from = '',
708
+ to = '';
709
+ // date range
710
+ if (/\s+-\s+/.test(val)){
711
+ val = val.split(/\s+-\s+/) || [];
712
+ from = val[0] || '';
713
+ to = val[1] || '';
714
+ } else if (/>=/.test(val)) {
715
+ // greater than date (to date empty)
716
+ from = val.replace(/>=/, '') || '';
717
+ } else if (/<=/.test(val)) {
718
+ // less than date (from date empty)
719
+ to = val.replace(/<=/, '') || '';
720
+ }
734
721
 
735
- // has sticky headers?
736
- c.$table.bind('stickyHeadersInit', function(){
737
- $shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
738
- $shcell.append(t);
722
+ // differeniate 1388556000000 from 1/1/2014 using \d{5} regex
723
+ from = from !== '' ? /\d{5}/g.test(from) ? new Date(Number(from)) : from || '' : '';
724
+ to = to !== '' ? /\d{5}/g.test(to) ? new Date(Number(to)) : to || '' : '';
725
+
726
+ $cell.add($shcell).find('.dateFrom').datepicker('setDate', from || null);
727
+ $cell.add($shcell).find('.dateTo').datepicker('setDate', to || null);
728
+ // give datepicker time to process
729
+ setTimeout(function(){
730
+ closeDate();
731
+ ts.filter.formatterUpdated($cell, indx);
732
+ }, 0);
733
+ });
739
734
 
740
- // add a jQuery datepicker!
741
- o.defaultDate = o.from || '';
742
- $shcell.find('.dateFrom').datepicker(o);
735
+ // has sticky headers?
736
+ c.$table.bind('stickyHeadersInit', function(){
737
+ $shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
738
+ $shcell.append(t);
743
739
 
744
- o.defaultDate = o.to || '+7d';
745
- $shcell.find('.dateTo').datepicker(o);
740
+ // add a jQuery datepicker!
741
+ o.defaultDate = o.from || '';
742
+ $shcell.find('.dateFrom').datepicker(o);
746
743
 
747
- });
744
+ o.defaultDate = o.to || '+7d';
745
+ $shcell.find('.dateTo').datepicker(o);
748
746
 
749
- // on reset
750
- $cell.closest('table').bind('filterReset', function(){
751
- $cell.add($shcell).find('.dateFrom').val('').datepicker('setDate', o.from || null );
752
- $cell.add($shcell).find('.dateTo').val('').datepicker('setDate', o.to || null );
753
- setTimeout(function(){
754
- closeDate();
755
- }, 0);
756
- });
747
+ });
748
+
749
+ // on reset
750
+ $cell.closest('table').bind('filterReset', function(){
751
+ $cell.add($shcell).find('.dateFrom').val('').datepicker('setDate', o.from || null );
752
+ $cell.add($shcell).find('.dateTo').val('').datepicker('setDate', o.to || null );
753
+ setTimeout(function(){
754
+ closeDate();
755
+ }, 0);
756
+ });
757
757
 
758
- // return the hidden input so the filter widget has a reference to it
759
- return $input.val( o.from ? ( o.to ? o.from + ' - ' + o.to : '>=' + o.from ) : (o.to ? '<=' + o.to : '') );
760
- }
758
+ // return the hidden input so the filter widget has a reference to it
759
+ return $input.val( o.from ? ( o.to ? o.from + ' - ' + o.to : '>=' + o.from ) : (o.to ? '<=' + o.to : '') );
760
+ }
761
761
 
762
- });
762
+ });
763
763
 
764
764
  })(jQuery);