jquery-tablesorter 1.11.1 → 1.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d639b535865896da6a17f2df96f4e9f91955d3c
4
- data.tar.gz: 65db0875623d6c2dd8d394ca82f4b8a1ddbb6900
3
+ metadata.gz: f67ead0cc7ee473fc13eba000fc6fa881e1f5055
4
+ data.tar.gz: a35b216de9c3d6374d1e23fbcf902ed14ecc3530
5
5
  SHA512:
6
- metadata.gz: 607932c25ac349c0a182932789532f7967f7587a7a5bbac50321c8cf9da397f26dc22d2cf5dc4891a2d3daf4b5a40759da1e3af1fa743f20b86c142fd69808f4
7
- data.tar.gz: bafbde9cfdda3b9e8f9f086c2004f1f7310bf52aeaf9896d6c5cd2f3f6e0481f85bb11059e3e3729cc3e01593f3c6b3d00f0f5de3e25fa1e02d4263f6fb401bf
6
+ metadata.gz: 3ad77cc7413bd4780c15d580097503bc60844b9ab05cebe4a27ced3f8d4f387c27efcd09ef4160b8c818eda24a3729fee1d0dbe9fce28173c0fecd7fd322a5d0
7
+ data.tar.gz: 41a29044a40b804f5c2c18950a7855e3cb7f353df1333739f4d964dba51e1a26a67366b49b67c10a4b2d050557e3775d5db03817333acc97684e7525b1bcbd16
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Simple integration of jquery-tablesorter into the asset pipeline.
6
6
 
7
- Current tablesorter version: 2.16.2 (4/27/2014), [documentation]
7
+ Current tablesorter version: 2.16.3 (4/30/2014), [documentation]
8
8
 
9
9
  Any issue associate with the js/css files, please report to [Mottie's fork].
10
10
 
@@ -1,3 +1,3 @@
1
1
  module JqueryTablesorter
2
- VERSION = '1.11.1'
2
+ VERSION = '1.11.2'
3
3
  end
@@ -1,5 +1,5 @@
1
1
  /**!
2
- * TableSorter 2.16.2 - Client-side table sorting with ease!
2
+ * TableSorter 2.16.3 - Client-side table sorting with ease!
3
3
  * @requires jQuery v1.2.6+
4
4
  *
5
5
  * Copyright (c) 2007 Christian Bach
@@ -24,7 +24,7 @@
24
24
 
25
25
  var ts = this;
26
26
 
27
- ts.version = "2.16.2";
27
+ ts.version = "2.16.3";
28
28
 
29
29
  ts.parsers = [];
30
30
  ts.widgets = [];
@@ -219,7 +219,7 @@
219
219
  var c = table.config,
220
220
  // update table bodies in case we start with an empty table
221
221
  tb = c.$tbodies = c.$table.children('tbody:not(.' + c.cssInfoBlock + ')'),
222
- rows, list, l, i, h, ch, p, time,
222
+ rows, list, l, i, h, ch, p, time, indx,
223
223
  j = 0,
224
224
  parsersDebug = "",
225
225
  len = tb.length;
@@ -240,7 +240,9 @@
240
240
  h = c.$headers.filter(':not([colspan])');
241
241
  h = h.add( c.$headers.filter('[colspan="1"]') ) // ie8 fix
242
242
  .filter('[data-column="' + i + '"]:last');
243
- ch = c.headers[i];
243
+ // get headers option corrected index
244
+ indx = c.$headers.index(h);
245
+ ch = c.headers[indx];
244
246
  // get column parser
245
247
  p = ts.getParserById( ts.getData(h, ch, 'sorter') );
246
248
  // empty cells behaviour - keeping emptyToBottom for backwards compatibility
@@ -804,8 +806,8 @@
804
806
  $cell = $(cell),
805
807
  // update cache - format: function(s, table, cell, cellIndex)
806
808
  // no closest in jQuery v1.2.6 - tbdy = $tb.index( $(cell).closest('tbody') ),$row = $(cell).closest('tr');
807
- tbdy = $tb.index( $cell.parents('tbody').filter(':first') ),
808
- $row = $cell.parents('tr').filter(':first');
809
+ tbdy = $tb.index( $.fn.closest ? $cell.closest('tbody') : $cell.parents('tbody').filter(':first') ),
810
+ $row = $.fn.closest ? $cell.closest('tr') : $cell.parents('tr').filter(':first');
809
811
  cell = $cell[0]; // in case cell is a jQuery object
810
812
  // tbody may not exist if update is initialized while tbody is removed for processing
811
813
  if ($tb.length && tbdy >= 0) {
@@ -1019,9 +1021,7 @@
1019
1021
  setHeadersCss(table);
1020
1022
  if (c.initWidgets) {
1021
1023
  // apply widget format
1022
- setTimeout(function(){
1023
- ts.applyWidget(table, false);
1024
- }, 0);
1024
+ ts.applyWidget(table, false);
1025
1025
  }
1026
1026
  }
1027
1027
 
@@ -1030,7 +1030,13 @@
1030
1030
  $table
1031
1031
  .unbind('sortBegin' + c.namespace + ' sortEnd' + c.namespace)
1032
1032
  .bind('sortBegin' + c.namespace + ' sortEnd' + c.namespace, function(e) {
1033
- ts.isProcessing(table, e.type === 'sortBegin');
1033
+ clearTimeout(c.processTimer);
1034
+ ts.isProcessing(table);
1035
+ if (e.type === 'sortBegin') {
1036
+ c.processTimer = setTimeout(function(){
1037
+ ts.isProcessing(table, true);
1038
+ }, 500);
1039
+ }
1034
1040
  });
1035
1041
  }
1036
1042
 
@@ -1044,7 +1050,6 @@
1044
1050
  if (typeof c.initialized === 'function') { c.initialized(table); }
1045
1051
  };
1046
1052
 
1047
-
1048
1053
  // computeTableHeaderCellIndexes from:
1049
1054
  // http://www.javascripttoolbox.com/lib/table/examples.php
1050
1055
  // http://www.javascripttoolbox.com/temp/table_cellindex.html
@@ -1161,7 +1166,7 @@
1161
1166
  }
1162
1167
  if (c.delayInit && isEmptyObject(c.cache)) { buildCache(table); }
1163
1168
  // jQuery v1.2.6 doesn't have closest()
1164
- cell = /TH|TD/.test(this.tagName) ? this : $(this).parents('th, td')[0];
1169
+ cell = $.fn.closest ? $(this).closest('th, td')[0] : /TH|TD/.test(this.tagName) ? this : $(this).parents('th, td')[0];
1165
1170
  // reference original table headers and find the same cell
1166
1171
  cell = c.$headers[ $headers.index( cell ) ];
1167
1172
  if (!cell.sortDisabled) {
@@ -1238,6 +1243,8 @@
1238
1243
  };
1239
1244
 
1240
1245
  // Natural sort - https://github.com/overset/javascript-natural-sort (date sorting removed)
1246
+ // this function will only accept strings, or you'll see "TypeError: undefined is not a function"
1247
+ // I could add a = a.toString(); b = b.toString(); but it'll slow down the sort overall
1241
1248
  ts.sortNatural = function(a, b) {
1242
1249
  if (a === b) { return 0; }
1243
1250
  var xN, xD, yN, yD, xF, yF, i, mx,
@@ -1,4 +1,4 @@
1
- /*! Filter widget formatter functions - updated 4/22/2014 (v2.16.1-beta)
1
+ /*! Filter widget formatter functions - updated 4/30/2014 (v2.16.3)
2
2
  * requires: jQuery 1.7.2+, tableSorter 2.16+, filter widget 2.16+ and select2 v3.4.6+ plugin
3
3
  */
4
4
  /*jshint browser:true, jquery:true, unused:false */
@@ -17,6 +17,7 @@ ts.filterFormatter.select2 = function($cell, indx, select2Def) {
17
17
  // select2 filter formatter options
18
18
  cellText : '', // Text (wrapped in a label element)
19
19
  match : true, // adds "filter-match" to header
20
+ value : '',
20
21
  // include ANY select2 options below
21
22
  multiple : true,
22
23
  width : '100%'
@@ -31,21 +32,23 @@ ts.filterFormatter.select2 = function($cell, indx, select2Def) {
31
32
  // hidden filter update namespace trigger by filter widget
32
33
  .bind('change' + c.namespace + 'filter', function(){
33
34
  var val = this.value;
34
- val = val.replace(/[/()$]/g, '').split('|');
35
- updateSelect2(val);
35
+ val = val.replace(/[/()$^]/g, '').split('|');
36
+ $cell.find('.select2').select2('val', val);
37
+ updateSelect2();
36
38
  }),
37
39
  $header = c.$headers.filter('[data-column="' + indx + '"]:last'),
38
40
  onlyAvail = $header.hasClass(wo.filter_onlyAvail),
39
41
  $shcell = [],
40
- match = o.match ? '' : '$',
42
+ matchPrefix = o.match ? '' : '^',
43
+ matchSuffix = o.match ? '' : '$',
41
44
 
42
45
  // this function updates the hidden input and adds the current values to the header cell text
43
- updateSelect2 = function(v, notrigger) {
44
- v = typeof v === "undefined" || v === '' ? $cell.find('.select2').select2('val') || o.value || '' : v || '';
46
+ updateSelect2 = function() {
47
+ var v = $cell.find('.select2').select2('val') || o.value || '';
45
48
  $input
46
- // add equal to the beginning, so we filter exact numbers
47
- .val( $.isArray(v) && v.length ? '/(' + (v || []).join(match + '|') + match + ')/' : '' )
48
- .trigger( notrigger ? '' : 'search' ).end()
49
+ // add regex, so we filter exact numbers
50
+ .val( $.isArray(v) && v.length && v.join('') !== '' ? '/(' + matchPrefix + (v || []).join(matchSuffix + '|' + matchPrefix) + matchSuffix + ')/' : '' )
51
+ .trigger('search').end()
49
52
  .find('.select2').select2('val', v);
50
53
  // update sticky header cell
51
54
  if ($shcell.length) {
@@ -94,11 +97,11 @@ ts.filterFormatter.select2 = function($cell, indx, select2Def) {
94
97
 
95
98
  // update select2 from filter hidden input, in case of saved filters
96
99
  c.$table.bind('filterFomatterUpdate', function(){
97
- // value = '/(x$|y$)/' => 'x,y'
100
+ // value = '/(^x$|^y$)/' => 'x,y'
98
101
  var val = c.$table.data('lastSearch')[indx] || '';
99
- val = val.replace(/[/()$]/g, '').split('|');
102
+ val = val.replace(/[/()$^]/g, '').split('|');
100
103
  $cell.find('.select2').select2('val', val);
101
- updateSelect2(val, true);
104
+ updateSelect2();
102
105
  });
103
106
 
104
107
  // has sticky headers?
@@ -1,4 +1,4 @@
1
- /*! tableSorter 2.16+ widgets - updated 4/27/2014 (v2.16.2)
1
+ /*! tableSorter 2.16+ widgets - updated 4/30/2014 (v2.16.3)
2
2
  *
3
3
  * Column Styles
4
4
  * Column Filters
@@ -817,7 +817,7 @@ ts.filter = {
817
817
  },
818
818
  hideFilters: function(table, c) {
819
819
  var $filterRow, $filterRow2, timer;
820
- c.$table
820
+ $(table)
821
821
  .find('.' + ts.css.filterRow)
822
822
  .addClass('hideme')
823
823
  .bind('mouseenter mouseleave', function(e) {
@@ -846,7 +846,7 @@ ts.filter = {
846
846
  var event = e;
847
847
  timer = setTimeout(function() {
848
848
  // don't hide row if any filter has a value
849
- if (ts.getFilters(table).join('') === '') {
849
+ if (ts.getFilters(c.$table).join('') === '') {
850
850
  $filterRow2[ event.type === 'focus' ? 'removeClass' : 'addClass']('hideme');
851
851
  }
852
852
  }, 200);
@@ -854,7 +854,7 @@ ts.filter = {
854
854
  },
855
855
  findRows: function(table, filters, combinedFilters) {
856
856
  if (table.config.lastCombinedFilter === combinedFilters) { return; }
857
- var cached, len, $rows, cacheIndex, rowIndex, tbodyIndex, $tbody, $cells, columnIndex,
857
+ var cached, len, $rows, rowIndex, tbodyIndex, $tbody, $cells, columnIndex,
858
858
  childRow, childRowText, exact, iExact, iFilter, lastSearch, matches, result,
859
859
  notFiltered, searchFiltered, filterMatched, showRow, time,
860
860
  anyMatch, iAnyMatch, rowArray, rowText, iRowText, rowCache,
@@ -866,9 +866,10 @@ ts.filter = {
866
866
  anyMatchNotAllowedTypes = [ 'range', 'notMatch', 'operators' ],
867
867
  // parse columns after formatter, in case the class is added at that point
868
868
  parsed = c.$headers.map(function(columnIndex) {
869
- return c.parsers && c.parsers[columnIndex] && c.parsers[columnIndex].parsed || ( ts.getData ?
870
- ts.getData(c.$headers.filter('[data-column="' + columnIndex + '"]:last'), c.headers[columnIndex], 'filter') === 'parsed' :
871
- $(this).hasClass('filter-parsed') );
869
+ return c.parsers && c.parsers[columnIndex] && c.parsers[columnIndex].parsed ||
870
+ // getData won't return "parsed" if other "filter-" class names exist (e.g. <th class="filter-select filter-parsed">)
871
+ ts.getData && ts.getData(c.$headers.filter('[data-column="' + columnIndex + '"]:last'), c.headers[columnIndex], 'filter') === 'parsed' ||
872
+ $(this).hasClass('filter-parsed');
872
873
  }).get();
873
874
  if (c.debug) { time = new Date(); }
874
875
  for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
@@ -913,7 +914,6 @@ ts.filter = {
913
914
  iAnyMatch = anyMatch.toLowerCase();
914
915
  }
915
916
  // loop through the rows
916
- cacheIndex = 0;
917
917
  for (rowIndex = 0; rowIndex < len; rowIndex++) {
918
918
  childRow = $rows[rowIndex].className;
919
919
  // skip child rows & already filtered rows
@@ -932,7 +932,7 @@ ts.filter = {
932
932
  rowArray = $cells.map(function(i){
933
933
  var txt;
934
934
  if (parsed[i]) {
935
- txt = c.cache[tbodyIndex].normalized[cacheIndex][i];
935
+ txt = c.cache[tbodyIndex].normalized[rowIndex][i];
936
936
  } else {
937
937
  txt = wo.filter_ignoreCase ? $(this).text().toLowerCase() : $(this).text();
938
938
  if (c.sortLocaleCompare) {
@@ -943,7 +943,7 @@ ts.filter = {
943
943
  }).get();
944
944
  rowText = rowArray.join(' ');
945
945
  iRowText = rowText.toLowerCase();
946
- rowCache = c.cache[tbodyIndex].normalized[cacheIndex].slice(0,-1).join(' ');
946
+ rowCache = c.cache[tbodyIndex].normalized[rowIndex].slice(0,-1).join(' ');
947
947
  filterMatched = null;
948
948
  $.each(ts.filter.types, function(type, typeFunction) {
949
949
  if ($.inArray(type, anyMatchNotAllowedTypes) < 0) {
@@ -964,7 +964,7 @@ ts.filter = {
964
964
  for (columnIndex = 0; columnIndex < columns; columnIndex++) {
965
965
  // ignore if filter is empty or disabled
966
966
  if (filters[columnIndex]) {
967
- cached = c.cache[tbodyIndex].normalized[cacheIndex][columnIndex];
967
+ cached = c.cache[tbodyIndex].normalized[rowIndex][columnIndex];
968
968
  // check if column data should be from the cell or from parsed data
969
969
  if (wo.filter_useParsedData || parsed[columnIndex]) {
970
970
  exact = cached;
@@ -1020,7 +1020,6 @@ ts.filter = {
1020
1020
  if (childRow.length) {
1021
1021
  childRow.toggleClass(wo.filter_filteredRow, !showRow);
1022
1022
  }
1023
- cacheIndex++;
1024
1023
  }
1025
1024
  }
1026
1025
  ts.processTbody(table, $tbody, false);
@@ -1040,8 +1039,10 @@ ts.filter = {
1040
1039
  }, 0);
1041
1040
  },
1042
1041
  getOptionSource: function(table, column, onlyAvail) {
1043
- var c = table.config,
1042
+ var cts,
1043
+ c = table.config,
1044
1044
  wo = c.widgetOptions,
1045
+ parsed = [],
1045
1046
  arry = false,
1046
1047
  source = wo.filter_selectSource;
1047
1048
 
@@ -1064,7 +1065,43 @@ ts.filter = {
1064
1065
  arry = $.grep(arry, function(value, indx) {
1065
1066
  return $.inArray(value, arry) === indx;
1066
1067
  });
1067
- return (ts.sortNatural) ? arry.sort(function(a, b) { return ts.sortNatural(a, b); }) : arry.sort(true);
1068
+
1069
+ if (c.$headers.filter('[data-column="' + column + '"]:last').hasClass('filter-select-nosort')) {
1070
+ // unsorted select options
1071
+ return arry;
1072
+ } else {
1073
+ // parse select option values
1074
+ $.each(arry, function(i, v){
1075
+ // parse array data using set column parser; this DOES NOT pass the original
1076
+ // table cell to the parser format function
1077
+ parsed.push({ t : v, p : c.parsers && c.parsers[column].format( v, table, [], column ) || v });
1078
+ });
1079
+
1080
+ // sort parsed select options
1081
+ cts = c.textSorter || '';
1082
+ parsed.sort(function(a, b){
1083
+ // sortNatural breaks if you don't pass it strings
1084
+ var x = a.p.toString(), y = b.p.toString();
1085
+ if ($.isFunction(cts)) {
1086
+ // custom OVERALL text sorter
1087
+ return cts(x, y, true, column, table);
1088
+ } else if (typeof(cts) === 'object' && cts.hasOwnProperty(column)) {
1089
+ // custom text sorter for a SPECIFIC COLUMN
1090
+ return cts[column](x, y, true, column, table);
1091
+ } else if (ts.sortNatural) {
1092
+ // fall back to natural sort
1093
+ return ts.sortNatural(x, y);
1094
+ }
1095
+ // using an older version! do a basic sort
1096
+ return true;
1097
+ });
1098
+ // rebuild arry from sorted parsed data
1099
+ arry = [];
1100
+ $.each(parsed, function(i, v){
1101
+ arry.push(v.t);
1102
+ });
1103
+ return arry;
1104
+ }
1068
1105
  },
1069
1106
  getOptions: function(table, column, onlyAvail) {
1070
1107
  var rowIndex, tbodyIndex, len, row, cache, cell,
@@ -1282,10 +1319,7 @@ ts.addWidget({
1282
1319
  // some wibbly-wobbly... timey-wimey... stuff, to make columns line up in Firefox
1283
1320
  offset = nonwkie && $(this).attr('data-column') === ( '' + parseInt(c.columns/2, 10) ) ? 1 : 0;
1284
1321
  $(this)
1285
- .css({
1286
- width: $cell.width() - spacing,
1287
- height: $cell.height()
1288
- })
1322
+ .css({ width: $cell.width() - spacing })
1289
1323
  .find(innerHeader).width( $cell.find(innerHeader).width() - offset );
1290
1324
  });
1291
1325
  };
@@ -1364,6 +1398,10 @@ ts.addWidget({
1364
1398
  }
1365
1399
  });
1366
1400
  ts.filter.bindSearch( $table, $stickyCells.find('.' + ts.css.filter) );
1401
+ // support hideFilters
1402
+ if (wo.filter_hideFilters) {
1403
+ ts.filter.hideFilters($stickyTable, c);
1404
+ }
1367
1405
  }
1368
1406
 
1369
1407
  $table.trigger('stickyHeadersInit');
@@ -1477,7 +1515,7 @@ ts.addWidget({
1477
1515
  })
1478
1516
  .find('.' + ts.css.resizer + ',.' + ts.css.grip)
1479
1517
  .bind('mousedown', function(event) {
1480
- // save header cell and mouse position; closest() not supported by jQuery v1.2.6
1518
+ // save header cell and mouse position
1481
1519
  $target = $(event.target).closest('th');
1482
1520
  var $header = c.$headers.filter('[data-column="' + $target.attr('data-column') + '"]');
1483
1521
  if ($header.length > 1) { $target = $target.add($header); }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-tablesorter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.1
4
+ version: 1.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jun Lin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-28 00:00:00.000000000 Z
12
+ date: 2014-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties