jquery-tablesorter 1.9.5 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,12 @@
1
- /*! Filter widget formatter functions - updated 11/9/2013 (v2.13.3)
2
- * requires: tableSorter 2.7.7+ and jQuery 1.4.3+
1
+ /*! Filter widget formatter functions - updated 2/19/2014 (v2.15)
2
+ * requires: tableSorter 2.15+ and jQuery 1.4.3+
3
3
  *
4
4
  * uiSpinner (jQuery UI spinner)
5
5
  * uiSlider (jQuery UI slider)
6
6
  * uiRange (jQuery UI range slider)
7
- * uiDateCompare (jQuery UI datepicker+compare selector; 1 input)
7
+ * uiDateCompare (jQuery UI datepicker; 1 input)
8
8
  * uiDatepicker (jQuery UI datepicker; 2 inputs, filter range)
9
- * html5Number (spinner+compare selector)
9
+ * html5Number (spinner)
10
10
  * html5Range (slider)
11
11
  * html5Color (color)
12
12
  */
@@ -14,24 +14,61 @@
14
14
  /*global jQuery: false */
15
15
  ;(function($){
16
16
  "use strict";
17
- $.tablesorter = $.tablesorter || {};
18
17
 
19
- $.tablesorter.filterFormatter = {
18
+ var ts = $.tablesorter || {},
19
+
20
+ // compare option selector class name (jQuery selector)
21
+ compareSelect = '.compare-select',
22
+
23
+ tsff = ts.filterFormatter = {
24
+
25
+ addCompare: function($cell, indx, options){
26
+ if (options.compare && $.isArray(options.compare) && options.compare.length > 1) {
27
+ var opt = '',
28
+ compareSelectClass = [ compareSelect.slice(1), ' ' + compareSelect.slice(1), '' ],
29
+ txt = options.cellText ? '<label class="' + compareSelectClass.join('-label') + indx + '">' + options.cellText + '</label>' : '';
30
+ $.each(options.compare, function(i, c){
31
+ opt += '<option ' + (options.selected === i ? 'selected' : '') + '>' + c + '</option>';
32
+ });
33
+ $cell
34
+ .wrapInner('<div class="' + compareSelectClass.join('-wrapper') + indx + '" />')
35
+ .prepend( txt + '<select class="' + compareSelectClass.join('') + indx + '" />' )
36
+ .find('select')
37
+ .append(opt);
38
+ }
39
+ },
40
+
41
+ updateCompare : function($cell, $input, o) {
42
+ var val = $input.val() || '',
43
+ num = val.replace(/\s*?[><=]\s*?/g, ''),
44
+ compare = val.match(/[><=]/g) || '';
45
+ if (o.compare) {
46
+ if ($.isArray(o.compare)){
47
+ compare = (compare || []).join('') || o.compare[o.selected || 0];
48
+ }
49
+ $cell.find(compareSelect).val( compare );
50
+ }
51
+ return [ val, num ];
52
+ },
20
53
 
21
54
  /**********************\
22
55
  jQuery UI Spinner
23
56
  \**********************/
24
57
  uiSpinner: function($cell, indx, spinnerDef) {
25
58
  var o = $.extend({
26
- min : 0,
27
- max : 100,
28
- step : 1,
29
- value : 1,
59
+ // filter formatter options
30
60
  delayed : true,
31
61
  addToggle : true,
32
- disabled : false,
33
62
  exactMatch : true,
34
- compare : ''
63
+ value : 1,
64
+ cellText : '',
65
+ compare : '',
66
+ // include ANY jQuery UI spinner options below
67
+ min : 0,
68
+ max : 100,
69
+ step : 1,
70
+ disabled : false
71
+
35
72
  }, spinnerDef ),
36
73
  // Add a hidden input to hold the range values
37
74
  $input = $('<input class="filter" type="hidden">')
@@ -44,22 +81,27 @@ $.tablesorter.filterFormatter = {
44
81
  c = $cell.closest('table')[0].config,
45
82
 
46
83
  // this function updates the hidden input and adds the current values to the header cell text
47
- updateSpinner = function(ui) {
84
+ updateSpinner = function(ui, notrigger) {
48
85
  var chkd = true, state,
49
86
  // ui is not undefined on create
50
- v = ui && ui.value && $.tablesorter.formatFloat((ui.value + '').replace(/[><=]/g,'')) || $cell.find('.spinner').val() || o.value;
87
+ v = ui && ui.value && ts.formatFloat((ui.value + '').replace(/[><=]/g,'')) ||
88
+ $cell.find('.spinner').val() || o.value,
89
+ compare = ($.isArray(o.compare) ? $cell.find(compareSelect).val() || o.compare[ o.selected || 0] : o.compare) || '',
90
+ searchType = ui && typeof ui.delayed === 'boolean' ? ui.delayed : c.$table[0].hasInitialized ? o.delayed : true;
51
91
  if (o.addToggle) {
52
92
  chkd = $cell.find('.toggle').is(':checked');
53
93
  }
54
94
  state = o.disabled || !chkd ? 'disable' : 'enable';
55
95
  $cell.find('.filter')
56
96
  // add equal to the beginning, so we filter exact numbers
57
- .val( chkd ? (o.compare ? o.compare : o.exactMatch ? '=' : '') + v : '' )
58
- .trigger('search', ui && typeof ui.delayed === 'boolean' ? ui.delayed : o.delayed).end()
97
+ .val( chkd ? (compare ? compare : o.exactMatch ? '=' : '') + v : '' )
98
+ .trigger( notrigger ? '' : 'search', searchType ).end()
59
99
  .find('.spinner').spinner(state).val(v);
60
100
  // update sticky header cell
61
101
  if ($shcell.length) {
62
- $shcell.find('.spinner').spinner(state).val(v);
102
+ $shcell
103
+ .find('.spinner').spinner(state).val(v).end()
104
+ .find(compareSelect).val( compare );
63
105
  if (o.addToggle) {
64
106
  $shcell.find('.toggle')[0].checked = chkd;
65
107
  }
@@ -78,7 +120,8 @@ $.tablesorter.filterFormatter = {
78
120
  if (typeof o.oldspin === 'function') { o.oldspin(event, ui); }
79
121
  };
80
122
  if (o.addToggle) {
81
- $('<div class="button"><input id="uispinnerbutton' + indx + '" type="checkbox" class="toggle" /><label for="uispinnerbutton' + indx + '"></label></div>')
123
+ $('<div class="button"><input id="uispinnerbutton' + indx + '" type="checkbox" class="toggle" />' +
124
+ '<label for="uispinnerbutton' + indx + '"></label></div>')
82
125
  .appendTo($cell)
83
126
  .find('.toggle')
84
127
  .bind('change', function(){
@@ -96,11 +139,27 @@ $.tablesorter.filterFormatter = {
96
139
  updateSpinner();
97
140
  });
98
141
 
142
+ // update spinner from hidden input, in case of saved filters
143
+ c.$table.bind('filterFomatterUpdate', function(){
144
+ var val = tsff.updateCompare($cell, $input, o)[0];
145
+ $cell.find('.spinner').val( val );
146
+ updateSpinner({ value: val }, true);
147
+ });
148
+
149
+ if (o.compare) {
150
+ // add compare select
151
+ tsff.addCompare($cell, indx, o);
152
+ $cell.find(compareSelect).bind('change', function(){
153
+ updateSpinner();
154
+ });
155
+ }
156
+
99
157
  // has sticky headers?
100
158
  c.$table.bind('stickyHeadersInit', function(){
101
159
  $shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
102
160
  if (o.addToggle) {
103
- $('<div class="button"><input id="stickyuispinnerbutton' + indx + '" type="checkbox" class="toggle" /><label for="stickyuispinnerbutton' + indx + '"></label></div>')
161
+ $('<div class="button"><input id="stickyuispinnerbutton' + indx + '" type="checkbox" class="toggle" />' +
162
+ '<label for="stickyuispinnerbutton' + indx + '"></label></div>')
104
163
  .appendTo($shcell)
105
164
  .find('.toggle')
106
165
  .bind('change', function(){
@@ -117,15 +176,31 @@ $.tablesorter.filterFormatter = {
117
176
  $cell.find('.spinner').val( this.value );
118
177
  updateSpinner();
119
178
  });
179
+
180
+ if (o.compare) {
181
+ // add compare select
182
+ tsff.addCompare($shcell, indx, o);
183
+ $shcell.find(compareSelect).bind('change', function(){
184
+ $cell.find(compareSelect).val( $(this).val() );
185
+ updateSpinner();
186
+ });
187
+ }
188
+
120
189
  });
121
190
 
122
191
  // on reset
123
192
  c.$table.bind('filterReset', function(){
193
+ if ($.isArray(o.compare)) {
194
+ $cell.add($shcell).find(compareSelect).val( o.compare[ o.selected || 0 ] );
195
+ }
124
196
  // turn off the toggle checkbox
125
197
  if (o.addToggle) {
126
198
  $cell.find('.toggle')[0].checked = false;
127
199
  }
128
- updateSpinner();
200
+ $cell.find('.spinner').spinner('value', o.value);
201
+ setTimeout(function(){
202
+ updateSpinner();
203
+ }, 0);
129
204
  });
130
205
 
131
206
  updateSpinner();
@@ -137,16 +212,20 @@ $.tablesorter.filterFormatter = {
137
212
  \**********************/
138
213
  uiSlider: function($cell, indx, sliderDef) {
139
214
  var o = $.extend({
140
- value : 0,
141
- min : 0,
142
- max : 100,
143
- step : 1,
144
- range : "min",
215
+ // filter formatter options
145
216
  delayed : true,
146
217
  valueToHeader : false,
147
218
  exactMatch : true,
219
+ cellText : '',
148
220
  compare : '',
149
- allText : 'all'
221
+ allText : 'all',
222
+ // include ANY jQuery UI spinner options below
223
+ // except values, since this is a non-range setup
224
+ value : 0,
225
+ min : 0,
226
+ max : 100,
227
+ step : 1,
228
+ range : "min"
150
229
  }, sliderDef ),
151
230
  // Add a hidden input to hold the range values
152
231
  $input = $('<input class="filter" type="hidden">')
@@ -159,11 +238,13 @@ $.tablesorter.filterFormatter = {
159
238
  c = $cell.closest('table')[0].config,
160
239
 
161
240
  // this function updates the hidden input and adds the current values to the header cell text
162
- updateSlider = function(ui) {
241
+ updateSlider = function(ui, notrigger) {
163
242
  // ui is not undefined on create
164
- var v = typeof ui !== "undefined" ? $.tablesorter.formatFloat((ui.value + '').replace(/[><=]/g,'')) || o.min : o.value,
243
+ var v = typeof ui !== "undefined" ? ts.formatFloat((ui.value + '').replace(/[><=]/g,'')) || o.value : o.value,
165
244
  val = o.compare ? v : v === o.min ? o.allText : v,
166
- result = o.compare + val;
245
+ compare = ($.isArray(o.compare) ? $cell.find(compareSelect).val() || o.compare[ o.selected || 0] : o.compare) || '',
246
+ result = compare + val,
247
+ searchType = ui && typeof ui.delayed === 'boolean' ? ui.delayed : c.$table[0].hasInitialized ? o.delayed : true;
167
248
  if (o.valueToHeader) {
168
249
  // add range indication to the header cell above!
169
250
  $cell.closest('thead').find('th[data-column=' + indx + ']').find('.curvalue').html(' (' + result + ')');
@@ -174,14 +255,17 @@ $.tablesorter.filterFormatter = {
174
255
  // update the hidden input;
175
256
  // ****** ADD AN EQUAL SIGN TO THE BEGINNING! <- this makes the slide exactly match the number ******
176
257
  // when the value is at the minimum, clear the hidden input so all rows will be seen
258
+
177
259
  $cell.find('.filter')
178
- .val( ( o.compare ? o.compare + v : v === o.min ? '' : (o.exactMatch ? '=' : '') + v ) )
179
- .trigger('search', ui && typeof ui.delayed === 'boolean' ? ui.delayed : o.delayed).end()
260
+ .val( ( compare ? compare + v : v === o.min ? '' : (o.exactMatch ? '=' : '') + v ) )
261
+ .trigger( notrigger ? '' : 'search', searchType ).end()
180
262
  .find('.slider').slider('value', v);
181
263
 
182
264
  // update sticky header cell
183
265
  if ($shcell.length) {
184
- $shcell.find('.slider').slider('value', v);
266
+ $shcell
267
+ .find(compareSelect).val( compare ).end()
268
+ .find('.slider').slider('value', v);
185
269
  if (o.valueToHeader) {
186
270
  $shcell.closest('thead').find('th[data-column=' + indx + ']').find('.curvalue').html(' (' + result + ')');
187
271
  } else {
@@ -213,25 +297,53 @@ $.tablesorter.filterFormatter = {
213
297
  .appendTo($cell)
214
298
  .slider(o);
215
299
 
300
+ // update slider from hidden input, in case of saved filters
301
+ c.$table.bind('filterFomatterUpdate', function(){
302
+ var val = tsff.updateCompare($cell, $input, o)[0];
303
+ $cell.find('.slider').slider('value', val );
304
+ updateSlider({ value: val }, false);
305
+ });
306
+
307
+ if (o.compare) {
308
+ // add compare select
309
+ tsff.addCompare($cell, indx, o);
310
+ $cell.find(compareSelect).bind('change', function(){
311
+ updateSlider({ value: $cell.find('.slider').slider('value') });
312
+ });
313
+ }
314
+
216
315
  // on reset
217
316
  c.$table.bind('filterReset', function(){
218
- $cell.find('.slider').slider('value', o.value);
219
- updateSlider();
317
+ if ($.isArray(o.compare)) {
318
+ $cell.add($shcell).find(compareSelect).val( o.compare[ o.selected || 0 ] );
319
+ }
320
+ setTimeout(function(){
321
+ updateSlider({ value: o.value });
322
+ }, 0);
220
323
  });
221
324
 
222
325
  // has sticky headers?
223
326
  c.$table.bind('stickyHeadersInit', function(){
224
327
  $shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
225
328
 
226
- // add a jQuery UI slider!
227
- $('<div class="slider slider' + indx + '"/>')
228
- .val(o.value)
229
- .appendTo($shcell)
230
- .slider(o)
231
- .bind('change keyup', function(){
232
- $cell.find('.slider').val( this.value );
233
- updateSlider();
234
- });
329
+ // add a jQuery UI slider!
330
+ $('<div class="slider slider' + indx + '"/>')
331
+ .val(o.value)
332
+ .appendTo($shcell)
333
+ .slider(o)
334
+ .bind('change keyup', function(){
335
+ $cell.find('.slider').slider('value', this.value );
336
+ updateSlider();
337
+ });
338
+
339
+ if (o.compare) {
340
+ // add compare select
341
+ tsff.addCompare($shcell, indx, o);
342
+ $shcell.find(compareSelect).bind('change', function(){
343
+ $cell.find(compareSelect).val( $(this).val() );
344
+ updateSlider();
345
+ });
346
+ }
235
347
 
236
348
  });
237
349
 
@@ -243,34 +355,43 @@ $.tablesorter.filterFormatter = {
243
355
  \*************************/
244
356
  uiRange: function($cell, indx, rangeDef) {
245
357
  var o = $.extend({
358
+ // filter formatter options
359
+ delayed : true,
360
+ valueToHeader : false,
361
+ // include ANY jQuery UI spinner options below
362
+ // except value, since this one is range specific)
246
363
  values : [0, 100],
247
364
  min : 0,
248
365
  max : 100,
249
- range : true,
250
- delayed : true,
251
- valueToHeader : false
366
+ range : true
252
367
  }, rangeDef ),
253
368
  // Add a hidden input to hold the range values
254
369
  $input = $('<input class="filter" type="hidden">')
255
370
  .appendTo($cell)
256
371
  // hidden filter update (.tsfilter) namespace trigger by filter widget
257
372
  .bind('change.tsfilter', function(){
258
- var v = this.value.split(' - ');
259
- if (this.value === '') { v = [ o.min, o.max ]; }
260
- if (v && v[1]) {
261
- updateUiRange({ values: v, delay: false });
262
- }
373
+ getRange();
263
374
  }),
264
375
  $shcell = [],
265
376
  c = $cell.closest('table')[0].config,
266
377
 
378
+ getRange = function(){
379
+ var val = $input.val(),
380
+ v = val.split(' - ');
381
+ if (val === '') { v = [ o.min, o.max ]; }
382
+ if (v && v[1]) {
383
+ updateUiRange({ values: v, delay: false }, true);
384
+ }
385
+ },
386
+
267
387
  // this function updates the hidden input and adds the current values to the header cell text
268
- updateUiRange = function(ui) {
388
+ updateUiRange = function(ui, notrigger) {
269
389
  // ui.values are undefined for some reason on create
270
390
  var val = ui && ui.values || o.values,
271
391
  result = val[0] + ' - ' + val[1],
272
392
  // make range an empty string if entire range is covered so the filter row will hide (if set)
273
- range = val[0] === o.min && val[1] === o.max ? '' : result;
393
+ range = val[0] === o.min && val[1] === o.max ? '' : result,
394
+ searchType = ui && typeof ui.delayed === 'boolean' ? ui.delayed : c.$table[0].hasInitialized ? o.delayed : true;
274
395
  if (o.valueToHeader) {
275
396
  // add range indication to the header cell above (if not using the css method)!
276
397
  $cell.closest('thead').find('th[data-column=' + indx + ']').find('.currange').html(' (' + result + ')');
@@ -283,7 +404,7 @@ $.tablesorter.filterFormatter = {
283
404
  }
284
405
  // update the hidden input
285
406
  $cell.find('.filter').val(range)
286
- .trigger('search', ui && typeof ui.delayed === 'boolean' ? ui.delayed : o.delayed).end()
407
+ .trigger(notrigger ? '' : 'search', searchType).end()
287
408
  .find('.range').slider('values', val);
288
409
  // update sticky header cell
289
410
  if ($shcell.length) {
@@ -322,10 +443,17 @@ $.tablesorter.filterFormatter = {
322
443
  .appendTo($cell)
323
444
  .slider(o);
324
445
 
446
+ // update slider from hidden input, in case of saved filters
447
+ c.$table.bind('filterFomatterUpdate', function(){
448
+ getRange();
449
+ });
450
+
325
451
  // on reset
326
452
  c.$table.bind('filterReset', function(){
327
453
  $cell.find('.range').slider('values', o.values);
328
- updateUiRange();
454
+ setTimeout(function(){
455
+ updateUiRange();
456
+ }, 0);
329
457
  });
330
458
 
331
459
  // has sticky headers?
@@ -353,15 +481,22 @@ $.tablesorter.filterFormatter = {
353
481
  \*************************/
354
482
  uiDateCompare: function($cell, indx, defDate) {
355
483
  var o = $.extend({
356
- defaultDate : '',
484
+ // filter formatter options
357
485
  cellText : '',
486
+ compare : '',
487
+ endOfDay : true,
488
+ // include ANY jQuery UI spinner options below
489
+
490
+ defaultDate : '', // ******************************** FIX THIS *******************************************
491
+
358
492
  changeMonth : true,
359
493
  changeYear : true,
360
- numberOfMonths : 1,
361
- compare : '',
362
- compareOptions : false
494
+ numberOfMonths : 1
363
495
  }, defDate),
364
- $hdr = $cell.closest('thead').find('th[data-column=' + indx + ']'),
496
+
497
+ $date,
498
+ // make sure we're using parsed dates in the search
499
+ $hdr = $cell.closest('thead').find('th[data-column=' + indx + ']').addClass('filter-parsed'),
365
500
  // Add a hidden input to hold the range values
366
501
  $input = $('<input class="dateCompare" type="hidden">')
367
502
  .appendTo($cell)
@@ -372,103 +507,105 @@ $.tablesorter.filterFormatter = {
372
507
  o.onClose(v);
373
508
  }
374
509
  }),
375
- t, l, $shcell = [],
510
+ t, $shcell = [],
376
511
  c = $cell.closest('table')[0].config,
377
512
 
378
513
  // this function updates the hidden input
379
- updateCompare = function(v) {
380
- var date = new Date($cell.find('.date').datepicker('getDate')).getTime();
381
-
382
- $cell.find('.compare').val(v);
514
+ date1Compare = function(v, notrigger) {
515
+ var date, query,
516
+ getdate = v || $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 === '' ? o.defaultDate || '' : getdate);
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
+ }
383
528
  $cell.find('.dateCompare')
384
529
  // add equal to the beginning, so we filter exact numbers
385
- .val(v + date)
386
- .trigger('search', o.delayed).end();
530
+ .val(compare + query)
531
+ .trigger( notrigger ? '' : 'search', searchType ).end();
387
532
  // update sticky header cell
388
533
  if ($shcell.length) {
389
- $shcell.find('.compare').val(v);
534
+ $shcell
535
+ .find('.dateCompare').val(compare + query).end()
536
+ .find(compareSelect).val(compare);
390
537
  }
391
538
  };
392
539
 
393
- // make sure we're using parsed dates in the search
394
- $hdr.addClass('filter-parsed');
395
-
396
540
  // Add date range picker
397
- if (o.compareOptions) {
398
- l = '<select class="compare">';
399
- for(var myOption in o.compareOptions) {
400
- l += '<option value="' + myOption + '"';
401
- if (myOption === o.compare)
402
- l += ' selected="selected"';
403
- l += '>' + myOption + '</option>';
404
- }
405
- l += '</select>';
406
- $cell.append(l)
407
- .find('.compare')
408
- .bind('change', function(){
409
- updateCompare($(this).val());
410
- });
411
- } else if (o.cellText) {
412
- l = '<label>' + o.cellText + '</label>';
413
- $cell.append(l);
414
- }
415
-
416
- t = '<input type="text" class="date date' + indx +
417
- '" placeholder="' + ($hdr.data('placeholder') || $hdr.attr('data-placeholder') || '') + '" />';
418
- $(t).appendTo($cell);
541
+ t = '<input type="text" class="date date' + indx + '" placeholder="' +
542
+ ($hdr.data('placeholder') || $hdr.attr('data-placeholder') || '') + '" />';
543
+ $date = $(t).appendTo($cell);
419
544
 
420
545
  // add callbacks; preserve added callbacks
421
546
  o.oldonClose = o.onClose;
422
547
 
423
548
  o.onClose = function( selectedDate, ui ) {
424
- var date = new Date($cell.find('.date').datepicker('getDate')).getTime() || '';
425
- var compare = ( $cell.find('.compare').val() || o.compare);
426
- $cell
427
- // update hidden input
428
- .find('.dateCompare').val( compare + date )
429
- .trigger('search').end()
430
- .find('.date')
431
- .datepicker('setDate', selectedDate);
432
-
433
- // update sticky header cell
434
- if ($shcell.length) {
435
- $shcell.find('.date').datepicker('setDate', selectedDate);
436
- }
437
-
549
+ date1Compare();
438
550
  if (typeof o.oldonClose === 'function') { o.oldonClose(selectedDate, ui); }
439
551
  };
440
- $cell.find('.date').datepicker(o);
441
-
442
- if (o.filterDate) {
443
- $cell.find('.date').datepicker('setDate', o.filterDate);
444
- }
552
+ $date.datepicker(o);
445
553
 
446
554
  // on reset
447
555
  c.$table.bind('filterReset', function(){
448
- $cell.find('.date').val('').datepicker('option', 'currentText', '' );
449
- if ($shcell.length) {
450
- $shcell.find('.date').val('').datepicker('option', 'currentText', '' );
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', '');
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 = new Date ( Number( v.split(/\s+-\s+/)[0] ) );
572
+ $date.datepicker( 'setDate', num );
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 !== '' ? new Date( /\d{5}/g.test(num) ? Number(num) : num ) || '' : '';
451
577
  }
578
+ $cell.add($shcell).find('.date').datepicker( 'setDate', num );
579
+ date1Compare(num, true);
452
580
  });
453
581
 
582
+ if (o.compare) {
583
+ // add compare select
584
+ tsff.addCompare($cell, indx, o);
585
+ $cell.find(compareSelect).bind('change', function(){
586
+ date1Compare();
587
+ });
588
+ }
589
+
454
590
  // has sticky headers?
455
591
  c.$table.bind('stickyHeadersInit', function(){
456
592
  $shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
457
- if (o.compareOptions) {
458
- $shcell.append(l)
459
- .find('.compare')
460
- .bind('change', function(){
461
- updateCompare($(this).val());
462
- });
463
- } else if (o.cellText) {
464
- $shcell.append(l);
465
- }
466
593
 
467
594
  // add a jQuery datepicker!
468
595
  $shcell
469
596
  .append(t)
470
597
  .find('.date')
471
598
  .datepicker(o);
599
+
600
+ if (o.compare) {
601
+ // add compare select
602
+ tsff.addCompare($shcell, indx, o);
603
+ $shcell.find(compareSelect).bind('change', function(){
604
+ $cell.find(compareSelect).val( $(this).val() );
605
+ date1Compare();
606
+ });
607
+ }
608
+
472
609
  });
473
610
 
474
611
  // return the hidden input so the filter widget has a reference to it
@@ -480,10 +617,13 @@ $.tablesorter.filterFormatter = {
480
617
  \*************************/
481
618
  uiDatepicker: function($cell, indx, defDate) {
482
619
  var o = $.extend({
483
- from : '',
484
- to : '',
620
+ // filter formatter options
621
+ endOfDay : true,
485
622
  textFrom : 'from',
486
623
  textTo : 'to',
624
+ from : '', // defaultDate "from" input
625
+ to : '', // defaultDate "to" input
626
+ // include ANY jQuery UI spinner options below
487
627
  changeMonth : true,
488
628
  changeYear : true,
489
629
  numberOfMonths : 1
@@ -519,9 +659,11 @@ $.tablesorter.filterFormatter = {
519
659
  var localfrom = o.defaultDate = o.from || o.defaultDate;
520
660
 
521
661
  closeFrom = o.onClose = function( selectedDate, ui ) {
522
- var from = new Date( $cell.find('.dateFrom').datepicker('getDate') ).getTime() || '',
523
- to = new Date( $cell.find('.dateTo').datepicker('getDate') ).getTime() || '',
524
- range = from ? ( to ? from + ' - ' + to : '>=' + from ) : (to ? '<=' + to : '');
662
+ var range,
663
+ from = new Date( $cell.find('.dateFrom').datepicker('getDate') ).getTime() || '',
664
+ to = $cell.find('.dateTo').datepicker('getDate') || '';
665
+ to = to ? ( o.endOfDay ? to.setHours(23, 59, 59) : to.getTime() ) || '' : '';
666
+ range = from ? ( to ? from + ' - ' + to : '>=' + from ) : (to ? '<=' + to : '');
525
667
  $cell
526
668
  .find('.dateRange').val(range)
527
669
  .trigger('search').end()
@@ -541,9 +683,11 @@ $.tablesorter.filterFormatter = {
541
683
 
542
684
  o.defaultDate = o.to || '+7d'; // set to date +7 days from today (if not defined)
543
685
  closeTo = o.onClose = function( selectedDate, ui ) {
544
- var from = new Date( $cell.find('.dateFrom').datepicker('getDate') ).getTime() || '',
545
- to = new Date( $cell.find('.dateTo').datepicker('getDate') ).getTime() || '',
546
- range = from ? ( to ? from + ' - ' + to : '>=' + from ) : (to ? '<=' + to : '');
686
+ var range,
687
+ from = new Date( $cell.find('.dateFrom').datepicker('getDate') ).getTime() || '',
688
+ to = $cell.find('.dateTo').datepicker('getDate') || '';
689
+ to = to ? ( o.endOfDay ? to.setHours(23, 59, 59) : to.getTime() ) || '' : '';
690
+ range = from ? ( to ? from + ' - ' + to : '>=' + from ) : (to ? '<=' + to : '');
547
691
  $cell
548
692
  .find('.dateRange').val(range)
549
693
  .trigger('search').end()
@@ -560,6 +704,29 @@ $.tablesorter.filterFormatter = {
560
704
  };
561
705
  $cell.find('.dateTo').datepicker(o);
562
706
 
707
+ // update date compare from hidden input, in case of saved filters
708
+ c.$table.bind('filterFomatterUpdate', function(){
709
+ var val = $input.val() || '',
710
+ from = '',
711
+ to = '';
712
+
713
+ // date range
714
+ if (/\s+-\s+/.test(val)){
715
+ val = val.split(/\s+-\s+/) || [];
716
+ from = val[0] || '';
717
+ to = val[1] || '';
718
+ } else if (/>=/.test(val)) {
719
+ // greater than date (to date empty)
720
+ from = new Date(Number( val.replace(/>=/, '') )) || '';
721
+ } else if (/<=/.test(val)) {
722
+ // less than date (from date empty)
723
+ to = new Date(Number( val.replace(/<=/, '') )) || '';
724
+ }
725
+ $cell.add($shcell).find('.dateFrom').datepicker('setDate', from);
726
+ $cell.add($shcell).find('.dateTo').datepicker('setDate', to);
727
+ closeTo(to);
728
+ });
729
+
563
730
  // has sticky headers?
564
731
  c.$table.bind('stickyHeadersInit', function(){
565
732
  $shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
@@ -576,10 +743,8 @@ $.tablesorter.filterFormatter = {
576
743
 
577
744
  // on reset
578
745
  $cell.closest('table').bind('filterReset', function(){
579
- $cell.find('.dateFrom, .dateTo').val('').datepicker('option', 'currentText', '' );
580
- if ($shcell.length) {
581
- $shcell.find('.dateFrom, .dateTo').val('').datepicker('option', 'currentText', '' );
582
- }
746
+ $cell.add($shcell).find('.dateFrom').val('').datepicker('setDate', o.from );
747
+ $cell.add($shcell).find('.dateTo').val('').datepicker('setDate', o.to );
583
748
  });
584
749
 
585
750
  // return the hidden input so the filter widget has a reference to it
@@ -597,41 +762,30 @@ $.tablesorter.filterFormatter = {
597
762
  step : 1,
598
763
  delayed : true,
599
764
  disabled : false,
600
- addToggle : true,
601
- exactMatch : true,
765
+ addToggle : false,
766
+ exactMatch : false,
767
+ cellText : '',
602
768
  compare : '',
603
- compareOptions : false,
604
769
  skipTest: false
605
770
  }, def5Num),
606
771
 
772
+ $input,
607
773
  // test browser for HTML5 range support
608
774
  $number = $('<input type="number" style="visibility:hidden;" value="test">').appendTo($cell),
609
775
  // test if HTML5 number is supported - from Modernizr
610
776
  numberSupported = o.skipTest || $number.attr('type') === 'number' && $number.val() !== 'test',
611
- l, $shcell = [],
777
+ $shcell = [],
612
778
  c = $cell.closest('table')[0].config,
613
779
 
614
- updateCompare = function(v) {
615
- var number = $cell.find('.number').val();
616
-
617
- $cell.find('.compare').val(v);
618
- $cell.find('input[type=hidden]')
619
- // add equal to the beginning, so we filter exact numbers
620
- .val(v + number)
621
- .trigger('search', o.delayed).end();
622
- // update sticky header cell
623
- if ($shcell.length) {
624
- $shcell.find('.compare').val(v);
625
- }
626
- },
627
-
628
- updateNumber = function(v, delayed){
629
- var chkd = o.addToggle ? $cell.find('.toggle').is(':checked') : true;
630
- var compare = ( $cell.find('.compare').val() || o.compare);
631
- $cell.find('input[type=hidden]')
780
+ updateNumber = function(delayed, notrigger){
781
+ var chkd = o.addToggle ? $cell.find('.toggle').is(':checked') : true,
782
+ v = $cell.find('.number').val(),
783
+ compare = ($.isArray(o.compare) ? $cell.find(compareSelect).val() || o.compare[ o.selected || 0] : o.compare) || '',
784
+ searchType = c.$table[0].hasInitialized ? (delayed ? delayed : o.delayed) : true;
785
+ $input
632
786
  // add equal to the beginning, so we filter exact numbers
633
787
  .val( !o.addToggle || chkd ? (compare ? compare : o.exactMatch ? '=' : '') + v : '' )
634
- .trigger('search', delayed ? delayed : o.delayed).end()
788
+ .trigger( notrigger ? '' : 'search', searchType ).end()
635
789
  .find('.number').val(v);
636
790
  if ($cell.find('.number').length) {
637
791
  $cell.find('.number')[0].disabled = (o.disabled || !chkd);
@@ -639,6 +793,7 @@ $.tablesorter.filterFormatter = {
639
793
  // update sticky header cell
640
794
  if ($shcell.length) {
641
795
  $shcell.find('.number').val(v)[0].disabled = (o.disabled || !chkd);
796
+ $shcell.find(compareSelect).val(compare);
642
797
  if (o.addToggle) {
643
798
  $shcell.find('.toggle')[0].checked = chkd;
644
799
  }
@@ -647,41 +802,23 @@ $.tablesorter.filterFormatter = {
647
802
  $number.remove();
648
803
 
649
804
  if (numberSupported) {
650
- l = o.addToggle ? '<div class="button"><input id="html5button' + indx + '" type="checkbox" class="toggle" /><label for="html5button' + indx + '"></label></div>' : '';
651
- }
652
-
653
- if (o.compareOptions) {
654
- l = '<select class="compare">';
655
- for(var myOption in o.compareOptions) {
656
- l += '<option value="' + myOption + '"';
657
- if (myOption === o.compare)
658
- l += ' selected="selected"';
659
- l += '>' + myOption + '</option>';
660
- }
661
- l += '</select>';
662
- $cell.append(l)
663
- .find('.compare')
664
- .bind('change', function(){
665
- updateCompare($(this).val());
666
- });
667
- } else {
668
- if (l)
669
- $cell.append(l);
670
- }
671
-
672
- if (numberSupported) {
673
- t = '<input class="number" type="number" min="' + o.min + '" max="' + o.max + '" value="' +
805
+ t = o.addToggle ? '<div class="button"><input id="html5button' + indx + '" type="checkbox" class="toggle" />' +
806
+ '<label for="html5button' + indx + '"></label></div>' : '';
807
+ t += '<input class="number" type="number" min="' + o.min + '" max="' + o.max + '" value="' +
674
808
  o.value + '" step="' + o.step + '" />';
675
809
  // add HTML5 number (spinner)
676
810
  $cell
677
811
  .append(t + '<input type="hidden" />')
678
812
  .find('.toggle, .number').bind('change', function(){
679
- updateNumber( $cell.find('.number').val() );
813
+ updateNumber();
680
814
  })
681
815
  .closest('thead').find('th[data-column=' + indx + ']')
682
816
  .addClass('filter-parsed') // get exact numbers from column
683
817
  // on reset
684
818
  .closest('table').bind('filterReset', function(){
819
+ if ($.isArray(o.compare)) {
820
+ $cell.add($shcell).find(compareSelect).val( o.compare[ o.selected || 0 ] );
821
+ }
685
822
  // turn off the toggle checkbox
686
823
  if (o.addToggle) {
687
824
  $cell.find('.toggle')[0].checked = false;
@@ -689,38 +826,54 @@ $.tablesorter.filterFormatter = {
689
826
  $shcell.find('.toggle')[0].checked = false;
690
827
  }
691
828
  }
692
- updateNumber( $cell.find('.number').val() );
829
+ $cell.find('.number').val( o.value );
830
+ setTimeout(function(){
831
+ updateNumber();
832
+ }, 0);
693
833
  });
834
+ $input = $cell.find('input[type=hidden]').bind('change', function(){
835
+ $cell.find('.number').val( this.value );
836
+ updateNumber();
837
+ });
694
838
 
695
- // hidden filter update (.tsfilter) namespace trigger by filter widget
696
- // FIXME TheSin, Not sure why but this breaks updates
697
- // Commenting out till it's fixed.
698
- //$cell.find('input[type=hidden]').bind('change.tsfilter', function(){
699
- // updateNumber( this.value );
700
- //});
839
+ // update slider from hidden input, in case of saved filters
840
+ c.$table.bind('filterFomatterUpdate', function(){
841
+ var val = tsff.updateCompare($cell, $input, o)[0] || o.value;
842
+ $cell.find('.number').val( ((val || '') + '').replace(/[><=]/g,'') );
843
+ updateNumber(false, true);
844
+ });
845
+
846
+ if (o.compare) {
847
+ // add compare select
848
+ tsff.addCompare($cell, indx, o);
849
+ $cell.find(compareSelect).bind('change', function(){
850
+ updateNumber();
851
+ });
852
+ }
701
853
 
702
854
  // has sticky headers?
703
855
  c.$table.bind('stickyHeadersInit', function(){
704
856
  $shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
705
- if (o.compareOptions) {
706
- $shcell.append(l)
707
- .find('.compare')
708
- .bind('change', function(){
709
- updateCompare($(this).val());
710
- });
711
- } else {
712
- $shcell.append(l);
713
- }
714
-
715
857
  $shcell
716
858
  .append(t)
717
859
  .find('.toggle, .number').bind('change', function(){
718
- updateNumber( $shcell.find('.number').val() );
860
+ $cell.find('.number').val( $(this).val() );
861
+ updateNumber();
719
862
  });
720
- updateNumber( $cell.find('.number').val() );
863
+
864
+ if (o.compare) {
865
+ // add compare select
866
+ tsff.addCompare($shcell, indx, o);
867
+ $shcell.find(compareSelect).bind('change', function(){
868
+ $cell.find(compareSelect).val( $(this).val() );
869
+ updateNumber();
870
+ });
871
+ }
872
+
873
+ updateNumber();
721
874
  });
722
875
 
723
- updateNumber( $cell.find('.number').val() );
876
+ updateNumber();
724
877
 
725
878
  }
726
879
 
@@ -739,11 +892,13 @@ $.tablesorter.filterFormatter = {
739
892
  delayed : true,
740
893
  valueToHeader : true,
741
894
  exactMatch : true,
895
+ cellText : '',
742
896
  compare : '',
743
897
  allText : 'all',
744
898
  skipTest : false
745
899
  }, def5Range),
746
900
 
901
+ $input,
747
902
  // test browser for HTML5 range support
748
903
  $range = $('<input type="range" style="visibility:hidden;" value="test">').appendTo($cell),
749
904
  // test if HTML5 range is supported - from Modernizr (but I left out the method to detect in Safari 2-4)
@@ -752,21 +907,26 @@ $.tablesorter.filterFormatter = {
752
907
  $shcell = [],
753
908
  c = $cell.closest('table')[0].config,
754
909
 
755
- updateRange = function(v, delayed){
910
+ updateRange = function(v, delayed, notrigger){
756
911
  /*jshint eqeqeq:false */
757
- v = (v + '').replace(/[<>=]/g,'') || o.min; // hidden input changes may include compare symbols
758
- var t = ' (' + (o.compare ? o.compare + v : v == o.min ? o.allText : v) + ')';
912
+ // hidden input changes may include compare symbols
913
+ v = ( typeof v === "undefined" ? $input.val() : v ).toString().replace(/[<>=]/g,'') || o.value;
914
+ var compare = ($.isArray(o.compare) ? $cell.find(compareSelect).val() || o.compare[ o.selected || 0] : o.compare) || '',
915
+ t = ' (' + (compare ? compare + v : v == o.min ? o.allText : v) + ')',
916
+ searchType = c.$table[0].hasInitialized ? (delayed ? delayed : o.delayed) : true;
759
917
  $cell.find('input[type=hidden]')
760
918
  // add equal to the beginning, so we filter exact numbers
761
- .val( ( o.compare ? o.compare + v : ( v == o.min ? '' : ( o.exactMatch ? '=' : '' ) + v ) ) )
919
+ .val( ( compare ? compare + v : ( v == o.min ? '' : ( o.exactMatch ? '=' : '' ) + v ) ) )
762
920
  //( val == o.min ? '' : val + (o.exactMatch ? '=' : ''))
763
- .trigger('search', delayed ? delayed : o.delayed).end()
921
+ .trigger( notrigger ? '' : 'search', searchType ).end()
764
922
  .find('.range').val(v);
765
923
  // or add current value to the header cell, if desired
766
924
  $cell.closest('thead').find('th[data-column=' + indx + ']').find('.curvalue').html(t);
767
925
  // update sticky header cell
768
926
  if ($shcell.length) {
769
- $shcell.find('.range').val(v);
927
+ $shcell
928
+ .find('.range').val(v).end()
929
+ .find(compareSelect).val( compare );
770
930
  $shcell.closest('thead').find('th[data-column=' + indx + ']').find('.curvalue').html(t);
771
931
  }
772
932
  };
@@ -780,22 +940,37 @@ $.tablesorter.filterFormatter = {
780
940
  .addClass('filter-parsed') // get exact numbers from column
781
941
  // add span to header for the current slider value
782
942
  .find('.tablesorter-header-inner').append('<span class="curvalue" />');
783
-
784
- $cell.find('.range').bind('change', function(){
785
- updateRange( this.value );
786
- });
787
-
788
943
  // hidden filter update (.tsfilter) namespace trigger by filter widget
789
- $cell.find('input[type=hidden]').bind('change.tsfilter', function(){
944
+ $input = $cell.find('input[type=hidden]').bind('change.tsfilter', function(){
790
945
  /*jshint eqeqeq:false */
791
- var v = this.value;
946
+ var v = this.value,
947
+ compare = ($.isArray(o.compare) ? $cell.find(compareSelect).val() || o.compare[ o.selected || 0] : o.compare) || '';
792
948
  if (v !== this.lastValue) {
793
- this.lastValue = ( o.compare ? o.compare + v : ( v == o.min ? '' : ( o.exactMatch ? '=' : '' ) + v ) );
949
+ this.lastValue = ( compare ? compare + v : ( v == o.min ? '' : ( o.exactMatch ? '=' : '' ) + v ) );
794
950
  this.value = this.lastValue;
795
951
  updateRange( v );
796
952
  }
797
953
  });
798
954
 
955
+ $cell.find('.range').bind('change', function(){
956
+ updateRange( this.value );
957
+ });
958
+
959
+ // update spinner from hidden input, in case of saved filters
960
+ c.$table.bind('filterFomatterUpdate', function(){
961
+ var val = tsff.updateCompare($cell, $input, o)[0];
962
+ $cell.find('.range').val( val );
963
+ updateRange(val, false, true);
964
+ });
965
+
966
+ if (o.compare) {
967
+ // add compare select
968
+ tsff.addCompare($cell, indx, o);
969
+ $cell.find(compareSelect).bind('change', function(){
970
+ updateRange();
971
+ });
972
+ }
973
+
799
974
  // has sticky headers?
800
975
  c.$table.bind('stickyHeadersInit', function(){
801
976
  $shcell = c.widgetOptions.$sticky.find('.tablesorter-filter-row').children().eq(indx).empty();
@@ -804,16 +979,29 @@ $.tablesorter.filterFormatter = {
804
979
  .find('.range').bind('change', function(){
805
980
  updateRange( $shcell.find('.range').val() );
806
981
  });
807
- updateRange( $cell.find('.range').val() );
982
+ updateRange();
983
+
984
+ if (o.compare) {
985
+ // add compare select
986
+ tsff.addCompare($shcell, indx, o);
987
+ $shcell.find(compareSelect).bind('change', function(){
988
+ $cell.find(compareSelect).val( $(this).val() );
989
+ updateRange();
990
+ });
991
+ }
992
+
808
993
  });
809
994
 
810
995
  // on reset
811
996
  $cell.closest('table').bind('filterReset', function(){
812
- // just turn off the colorpicker
813
- updateRange(o.value);
997
+ if ($.isArray(o.compare)) {
998
+ $cell.add($shcell).find(compareSelect).val( o.compare[ o.selected || 0 ] );
999
+ }
1000
+ setTimeout(function(){
1001
+ updateRange(o.value, false, true);
1002
+ }, 0);
814
1003
  });
815
-
816
- updateRange( $cell.find('.range').val() );
1004
+ updateRange();
817
1005
 
818
1006
  }
819
1007
 
@@ -832,6 +1020,7 @@ $.tablesorter.filterFormatter = {
832
1020
  valueToHeader : false,
833
1021
  skipTest : false
834
1022
  }, defColor),
1023
+ $input,
835
1024
  // Add a hidden input to hold the range values
836
1025
  $color = $('<input type="color" style="visibility:hidden;" value="test">').appendTo($cell),
837
1026
  // test if HTML5 color is supported - from Modernizr
@@ -839,8 +1028,8 @@ $.tablesorter.filterFormatter = {
839
1028
  $shcell = [],
840
1029
  c = $cell.closest('table')[0].config,
841
1030
 
842
- updateColor = function(v){
843
- v = v || o.value;
1031
+ updateColor = function(v, notrigger){
1032
+ v = ( typeof v === "undefined" ? $input.val() : v ).toString().replace('=','') || o.value;
844
1033
  var chkd = true,
845
1034
  t = ' (' + v + ')';
846
1035
  if (o.addToggle) {
@@ -850,9 +1039,9 @@ $.tablesorter.filterFormatter = {
850
1039
  $cell.find('.colorpicker').val(v)[0].disabled = (o.disabled || !chkd);
851
1040
  }
852
1041
 
853
- $cell.find('input[type=hidden]')
1042
+ $input
854
1043
  .val( chkd ? v + (o.exactMatch ? '=' : '') : '' )
855
- .trigger('search');
1044
+ .trigger( !c.$table[0].hasInitialized || notrigger ? '' : 'search' );
856
1045
  if (o.valueToHeader) {
857
1046
  // add current color to the header cell
858
1047
  $cell.closest('thead').find('th[data-column=' + indx + ']').find('.curcolor').html(t);
@@ -879,13 +1068,14 @@ $.tablesorter.filterFormatter = {
879
1068
  $color.remove();
880
1069
 
881
1070
  if (colorSupported) {
1071
+ t = '' + indx + Math.round(Math.random() * 100);
882
1072
  // add HTML5 color picker
883
- t = '<div class="color-controls-wrapper">';
884
- t += o.addToggle ? '<div class="button"><input id="colorbutton' + indx + '" type="checkbox" class="toggle" /><label for="colorbutton' + indx + '"></label></div>' : '';
885
- t += '<input type="hidden"><input class="colorpicker" type="color" />';
886
- t += (o.valueToHeader ? '' : '<span class="currentColor">(#000000)</span>') + '</div>';
1073
+ t = '<div class="color-controls-wrapper">' +
1074
+ (o.addToggle ? '<div class="button"><input id="colorbutton' + t + '" type="checkbox" class="toggle" /><label for="colorbutton' +
1075
+ t + '"></label></div>' : '') +
1076
+ '<input type="hidden"><input class="colorpicker" type="color" />' +
1077
+ (o.valueToHeader ? '' : '<span class="currentColor">(#000000)</span>') + '</div>';
887
1078
  $cell.html(t);
888
-
889
1079
  // add span to header for the current color value - only works if the line in the updateColor() function is also un-commented out
890
1080
  if (o.valueToHeader) {
891
1081
  $cell.closest('thead').find('th[data-column=' + indx + ']').find('.tablesorter-header-inner').append('<span class="curcolor" />');
@@ -896,15 +1086,27 @@ $.tablesorter.filterFormatter = {
896
1086
  });
897
1087
 
898
1088
  // hidden filter update (.tsfilter) namespace trigger by filter widget
899
- $cell.find('input[type=hidden]').bind('change.tsfilter', function(){
1089
+ $input = $cell.find('input[type=hidden]').bind('change.tsfilter', function(){
900
1090
  updateColor( this.value );
901
1091
  });
902
1092
 
1093
+ // update slider from hidden input, in case of saved filters
1094
+ c.$table.bind('filterFomatterUpdate', function(){
1095
+ updateColor( $input.val(), true );
1096
+ });
1097
+
903
1098
  // on reset
904
1099
  $cell.closest('table').bind('filterReset', function(){
905
1100
  // just turn off the colorpicker
906
- $cell.find('.toggle')[0].checked = false;
907
- updateColor( $cell.find('.colorpicker').val() );
1101
+ if (o.addToggle) {
1102
+ $cell.find('.toggle')[0].checked = false;
1103
+ }
1104
+ // delay needed because default color needs to be set in the filter
1105
+ // there is no compare option here, so if addToggle = false,
1106
+ // default color is #000000 (even with no value set)
1107
+ setTimeout(function(){
1108
+ updateColor();
1109
+ }, 0);
908
1110
  });
909
1111
 
910
1112
  // has sticky headers?