jquery-tablesorter 1.18.5 → 1.19.0
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 +4 -4
- data/README.md +1 -1
- data/lib/jquery-tablesorter/version.rb +1 -1
- data/vendor/assets/javascripts/jquery-tablesorter/addons/pager/jquery.tablesorter.pager.js +68 -46
- data/vendor/assets/javascripts/jquery-tablesorter/extras/jquery.dragtable.mod.js +3 -3
- data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.combined.js +2383 -2100
- data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.js +2298 -2039
- data/vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.widgets.js +90 -66
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-month.js +45 -20
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-date-weekday.js +78 -20
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-globalize.js +37 -15
- data/vendor/assets/javascripts/jquery-tablesorter/parsers/parser-input-select.js +4 -4
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-chart.js +2 -2
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-columnSelector.js +122 -30
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-editable.js +8 -6
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter.js +79 -58
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-grouping.js +209 -128
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-headerTitles.js +5 -4
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-lazyload.js +367 -0
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-math.js +81 -35
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-output.js +3 -3
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-pager.js +79 -53
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-print.js +25 -14
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-saveSort.js +5 -2
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-scroller.js +11 -7
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-sort2Hash.js +149 -50
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-sortTbodies.js +7 -7
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-staticRow.js +2 -2
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-stickyHeaders.js +2 -2
- data/vendor/assets/javascripts/jquery-tablesorter/widgets/widget-view.js +192 -0
- metadata +4 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*** This file is dynamically generated ***
|
|
2
2
|
█████▄ ▄████▄ █████▄ ▄████▄ ██████ ███████▄ ▄████▄ █████▄ ██ ██████ ██ ██
|
|
3
|
-
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
|
4
|
-
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀
|
|
3
|
+
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▄▄ ██▄▄██
|
|
4
|
+
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀▀▀██
|
|
5
5
|
█████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀
|
|
6
6
|
*/
|
|
7
|
-
/*! tablesorter (FORK) - updated
|
|
7
|
+
/*! tablesorter (FORK) - updated 11-02-2015 (v2.24.2)*/
|
|
8
8
|
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
|
|
9
9
|
(function(factory) {
|
|
10
10
|
if (typeof define === 'function' && define.amd) {
|
|
@@ -372,7 +372,7 @@
|
|
|
372
372
|
|
|
373
373
|
})(jQuery);
|
|
374
374
|
|
|
375
|
-
/*! Widget: filter - updated 10/
|
|
375
|
+
/*! Widget: filter - updated 10/31/2015 (v2.24.0) *//*
|
|
376
376
|
* Requires tablesorter v2.8+ and jQuery 1.7+
|
|
377
377
|
* by Rob Garrison
|
|
378
378
|
*/
|
|
@@ -941,8 +941,9 @@
|
|
|
941
941
|
// $cell parameter, but not the config, is passed to the filter_formatters,
|
|
942
942
|
// so we have to work with it instead
|
|
943
943
|
formatterUpdated: function( $cell, column ) {
|
|
944
|
-
|
|
945
|
-
|
|
944
|
+
// prevent error if $cell is undefined - see #1056
|
|
945
|
+
var wo = $cell && $cell.closest( 'table' )[0].config.widgetOptions;
|
|
946
|
+
if ( wo && !wo.filter_initialized ) {
|
|
946
947
|
// add updates by column since this function
|
|
947
948
|
// may be called numerous times before initialization
|
|
948
949
|
wo.filter_formatterInit[ column ] = 1;
|
|
@@ -979,6 +980,16 @@
|
|
|
979
980
|
}
|
|
980
981
|
}
|
|
981
982
|
},
|
|
983
|
+
// encode or decode filters for storage; see #1026
|
|
984
|
+
processFilters: function( filters, encode ) {
|
|
985
|
+
var indx,
|
|
986
|
+
mode = encode ? encodeURIComponent : decodeURIComponent,
|
|
987
|
+
len = filters.length;
|
|
988
|
+
for ( indx = 0; indx < len; indx++ ) {
|
|
989
|
+
filters[ indx ] = mode( filters[ indx ] );
|
|
990
|
+
}
|
|
991
|
+
return filters;
|
|
992
|
+
},
|
|
982
993
|
setDefaults: function( table, c, wo ) {
|
|
983
994
|
var isArray, saved, indx, col, $filters,
|
|
984
995
|
// get current ( default ) filters
|
|
@@ -988,7 +999,7 @@
|
|
|
988
999
|
isArray = $.isArray( saved );
|
|
989
1000
|
// make sure we're not just getting an empty array
|
|
990
1001
|
if ( !( isArray && saved.join( '' ) === '' || !isArray ) ) {
|
|
991
|
-
filters = saved;
|
|
1002
|
+
filters = tsf.processFilters( saved );
|
|
992
1003
|
}
|
|
993
1004
|
}
|
|
994
1005
|
// if no filters saved, then check default settings
|
|
@@ -1011,71 +1022,81 @@
|
|
|
1011
1022
|
return parsed ? c.parsers[column].format( filter, c.table, [], column ) : filter;
|
|
1012
1023
|
},
|
|
1013
1024
|
buildRow: function( table, c, wo ) {
|
|
1014
|
-
var col, column, $header, makeSelect, disabled, name, ffxn, tmp,
|
|
1025
|
+
var $filter, col, column, $header, makeSelect, disabled, name, ffxn, tmp,
|
|
1015
1026
|
// c.columns defined in computeThIndexes()
|
|
1016
1027
|
cellFilter = wo.filter_cellFilter,
|
|
1017
1028
|
columns = c.columns,
|
|
1018
1029
|
arry = $.isArray( cellFilter ),
|
|
1019
1030
|
buildFilter = '<tr role="row" class="' + tscss.filterRow + ' ' + c.cssIgnoreRow + '">';
|
|
1020
1031
|
for ( column = 0; column < columns; column++ ) {
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1032
|
+
if ( c.$headerIndexed[ column ].length ) {
|
|
1033
|
+
buildFilter += '<td data-column="' + column + '"';
|
|
1034
|
+
// account for entire column set with colspan. See #1047
|
|
1035
|
+
tmp = c.$headerIndexed[ column ] && c.$headerIndexed[ column ][0].colSpan || 0;
|
|
1036
|
+
if ( tmp > 1 ) {
|
|
1037
|
+
buildFilter += ' colspan="' + tmp + '"';
|
|
1038
|
+
}
|
|
1039
|
+
if ( arry ) {
|
|
1040
|
+
buildFilter += ( cellFilter[ column ] ? ' class="' + cellFilter[ column ] + '"' : '' );
|
|
1041
|
+
} else {
|
|
1042
|
+
buildFilter += ( cellFilter !== '' ? ' class="' + cellFilter + '"' : '' );
|
|
1043
|
+
}
|
|
1044
|
+
buildFilter += '></td>';
|
|
1026
1045
|
}
|
|
1027
|
-
buildFilter += '></td>';
|
|
1028
1046
|
}
|
|
1029
1047
|
c.$filters = $( buildFilter += '</tr>' )
|
|
1030
1048
|
.appendTo( c.$table.children( 'thead' ).eq( 0 ) )
|
|
1031
|
-
.
|
|
1049
|
+
.children( 'td' );
|
|
1032
1050
|
// build each filter input
|
|
1033
1051
|
for ( column = 0; column < columns; column++ ) {
|
|
1034
1052
|
disabled = false;
|
|
1035
1053
|
// assuming last cell of a column is the main column
|
|
1036
1054
|
$header = c.$headerIndexed[ column ];
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
ts.
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
wo.
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
+
if ( $header && $header.length ) {
|
|
1056
|
+
$filter = c.$filters.filter( '[data-column="' + column + '"]' );
|
|
1057
|
+
ffxn = ts.getColumnData( table, wo.filter_functions, column );
|
|
1058
|
+
makeSelect = ( wo.filter_functions && ffxn && typeof ffxn !== 'function' ) ||
|
|
1059
|
+
$header.hasClass( 'filter-select' );
|
|
1060
|
+
// get data from jQuery data, metadata, headers option or header class name
|
|
1061
|
+
col = ts.getColumnData( table, c.headers, column );
|
|
1062
|
+
disabled = ts.getData( $header[0], col, 'filter' ) === 'false' ||
|
|
1063
|
+
ts.getData( $header[0], col, 'parser' ) === 'false';
|
|
1064
|
+
|
|
1065
|
+
if ( makeSelect ) {
|
|
1066
|
+
buildFilter = $( '<select>' ).appendTo( $filter );
|
|
1067
|
+
} else {
|
|
1068
|
+
ffxn = ts.getColumnData( table, wo.filter_formatter, column );
|
|
1069
|
+
if ( ffxn ) {
|
|
1070
|
+
wo.filter_formatterCount++;
|
|
1071
|
+
buildFilter = ffxn( $filter, column );
|
|
1072
|
+
// no element returned, so lets go find it
|
|
1073
|
+
if ( buildFilter && buildFilter.length === 0 ) {
|
|
1074
|
+
buildFilter = $filter.children( 'input' );
|
|
1075
|
+
}
|
|
1076
|
+
// element not in DOM, so lets attach it
|
|
1077
|
+
if ( buildFilter && ( buildFilter.parent().length === 0 ||
|
|
1078
|
+
( buildFilter.parent().length && buildFilter.parent()[0] !== $filter[0] ) ) ) {
|
|
1079
|
+
$filter.append( buildFilter );
|
|
1080
|
+
}
|
|
1081
|
+
} else {
|
|
1082
|
+
buildFilter = $( '<input type="search">' ).appendTo( $filter );
|
|
1055
1083
|
}
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1084
|
+
if ( buildFilter ) {
|
|
1085
|
+
tmp = $header.data( 'placeholder' ) ||
|
|
1086
|
+
$header.attr( 'data-placeholder' ) ||
|
|
1087
|
+
wo.filter_placeholder.search || '';
|
|
1088
|
+
buildFilter.attr( 'placeholder', tmp );
|
|
1060
1089
|
}
|
|
1061
|
-
} else {
|
|
1062
|
-
buildFilter = $( '<input type="search">' ).appendTo( c.$filters.eq( column ) );
|
|
1063
1090
|
}
|
|
1064
1091
|
if ( buildFilter ) {
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
wo.
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
name = ( $.isArray( wo.filter_cssFilter ) ?
|
|
1074
|
-
( typeof wo.filter_cssFilter[column] !== 'undefined' ? wo.filter_cssFilter[column] || '' : '' ) :
|
|
1075
|
-
wo.filter_cssFilter ) || '';
|
|
1076
|
-
buildFilter.addClass( tscss.filter + ' ' + name ).attr( 'data-column', column );
|
|
1077
|
-
if ( disabled ) {
|
|
1078
|
-
buildFilter.attr( 'placeholder', '' ).addClass( tscss.filterDisabled )[0].disabled = true;
|
|
1092
|
+
// add filter class name
|
|
1093
|
+
name = ( $.isArray( wo.filter_cssFilter ) ?
|
|
1094
|
+
( typeof wo.filter_cssFilter[column] !== 'undefined' ? wo.filter_cssFilter[column] || '' : '' ) :
|
|
1095
|
+
wo.filter_cssFilter ) || '';
|
|
1096
|
+
buildFilter.addClass( tscss.filter + ' ' + name ).attr( 'data-column', column );
|
|
1097
|
+
if ( disabled ) {
|
|
1098
|
+
buildFilter.attr( 'placeholder', '' ).addClass( tscss.filterDisabled )[0].disabled = true;
|
|
1099
|
+
}
|
|
1079
1100
|
}
|
|
1080
1101
|
}
|
|
1081
1102
|
}
|
|
@@ -1165,9 +1186,9 @@
|
|
|
1165
1186
|
if ( $.isEmptyObject( c.cache ) ) {
|
|
1166
1187
|
// update cache if delayInit set & pager has initialized ( after user initiates a search )
|
|
1167
1188
|
if ( c.delayInit && c.pager && c.pager.initialized ) {
|
|
1168
|
-
|
|
1189
|
+
ts.updateCache( c, function() {
|
|
1169
1190
|
tsf.checkFilters( table, false, skipFirst );
|
|
1170
|
-
}
|
|
1191
|
+
});
|
|
1171
1192
|
}
|
|
1172
1193
|
return;
|
|
1173
1194
|
}
|
|
@@ -1205,10 +1226,10 @@
|
|
|
1205
1226
|
return false;
|
|
1206
1227
|
}
|
|
1207
1228
|
},
|
|
1208
|
-
hideFilters: function( c ) {
|
|
1209
|
-
var timer
|
|
1210
|
-
|
|
1211
|
-
|
|
1229
|
+
hideFilters: function( c, $table ) {
|
|
1230
|
+
var timer,
|
|
1231
|
+
$row = ( $table || c.$table ).find( '.' + tscss.filterRow ).addClass( tscss.filterRowHide );
|
|
1232
|
+
$row
|
|
1212
1233
|
.bind( 'mouseenter mouseleave', function( e ) {
|
|
1213
1234
|
// save event object - http://bugs.jquery.com/ticket/12140
|
|
1214
1235
|
var event = e,
|
|
@@ -1625,7 +1646,7 @@
|
|
|
1625
1646
|
// ( '> -10' => '> -100' will ignore hidden rows )
|
|
1626
1647
|
!( regex.isNeg1.test( val ) || regex.isNeg2.test( val ) ) &&
|
|
1627
1648
|
// if filtering using a select without a 'filter-match' class ( exact match ) - fixes #593
|
|
1628
|
-
!( val !== '' && c.$filters && c.$filters.
|
|
1649
|
+
!( val !== '' && c.$filters && c.$filters.filter( '[data-column="' + indx + '"]' ).find( 'select' ).length &&
|
|
1629
1650
|
!c.$headerIndexed[indx].hasClass( 'filter-match' ) );
|
|
1630
1651
|
}
|
|
1631
1652
|
}
|
|
@@ -1732,7 +1753,7 @@
|
|
|
1732
1753
|
c.lastSearch = storedFilters;
|
|
1733
1754
|
c.$table.data( 'lastSearch', storedFilters );
|
|
1734
1755
|
if ( wo.filter_saveFilters && ts.storage ) {
|
|
1735
|
-
ts.storage( table, 'tablesorter-filters', storedFilters );
|
|
1756
|
+
ts.storage( table, 'tablesorter-filters', tsf.processFilters( storedFilters, true ) );
|
|
1736
1757
|
}
|
|
1737
1758
|
if ( c.debug ) {
|
|
1738
1759
|
console.log( 'Completed filter widget search' + ts.benchmark(time) );
|
|
@@ -1741,7 +1762,7 @@
|
|
|
1741
1762
|
c.$table.trigger( 'filterEnd', c );
|
|
1742
1763
|
}
|
|
1743
1764
|
setTimeout( function() {
|
|
1744
|
-
|
|
1765
|
+
ts.applyWidget( c.table ); // make sure zebra widget is applied
|
|
1745
1766
|
}, 0 );
|
|
1746
1767
|
},
|
|
1747
1768
|
getOptionSource: function( table, column, onlyAvail ) {
|
|
@@ -2073,7 +2094,7 @@
|
|
|
2073
2094
|
|
|
2074
2095
|
})( jQuery );
|
|
2075
2096
|
|
|
2076
|
-
/*! Widget: stickyHeaders - updated
|
|
2097
|
+
/*! Widget: stickyHeaders - updated 10/31/2015 (v2.24.0) *//*
|
|
2077
2098
|
* Requires tablesorter v2.8+ and jQuery 1.4.3+
|
|
2078
2099
|
* by Rob Garrison
|
|
2079
2100
|
*/
|
|
@@ -2337,7 +2358,7 @@
|
|
|
2337
2358
|
ts.filter.bindSearch( $table, $stickyCells.find('.' + ts.css.filter) );
|
|
2338
2359
|
// support hideFilters
|
|
2339
2360
|
if (wo.filter_hideFilters) {
|
|
2340
|
-
ts.filter.hideFilters($stickyTable
|
|
2361
|
+
ts.filter.hideFilters(c, $stickyTable);
|
|
2341
2362
|
}
|
|
2342
2363
|
}
|
|
2343
2364
|
|
|
@@ -2757,7 +2778,10 @@
|
|
|
2757
2778
|
|
|
2758
2779
|
})( jQuery, window );
|
|
2759
2780
|
|
|
2760
|
-
/*! Widget: saveSort
|
|
2781
|
+
/*! Widget: saveSort - updated 10/31/2015 (v2.24.0) *//*
|
|
2782
|
+
* Requires tablesorter v2.16+
|
|
2783
|
+
* by Rob Garrison
|
|
2784
|
+
*/
|
|
2761
2785
|
;(function ($) {
|
|
2762
2786
|
'use strict';
|
|
2763
2787
|
var ts = $.tablesorter || {};
|
|
@@ -2813,7 +2837,7 @@
|
|
|
2813
2837
|
c.sortList = sortList;
|
|
2814
2838
|
} else if (table.hasInitialized && sortList && sortList.length > 0) {
|
|
2815
2839
|
// update sort change
|
|
2816
|
-
|
|
2840
|
+
ts.sortOn( c, sortList );
|
|
2817
2841
|
}
|
|
2818
2842
|
}
|
|
2819
2843
|
},
|
|
@@ -1,36 +1,61 @@
|
|
|
1
|
-
/*! Parser: Month - updated
|
|
1
|
+
/*! Parser: Month - updated 11/2/2015 (v2.24.1) */
|
|
2
2
|
/* Demo: http://jsfiddle.net/Mottie/abkNM/4169/ */
|
|
3
3
|
/*jshint jquery:true */
|
|
4
4
|
;(function($){
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
7
7
|
var ts = $.tablesorter;
|
|
8
|
-
ts.dates = $.extend({},
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
ts.dates = $.extend( {}, {
|
|
9
|
+
// See http://mottie.github.io/tablesorter/docs/example-widget-grouping.html
|
|
10
|
+
// for details on how to use CLDR data for a locale to add data for this parser
|
|
11
|
+
// CLDR returns an object { 1: "Jan", 2: "Feb", 3: "Mar", ..., 12: "Dec" }
|
|
12
|
+
months : {
|
|
13
|
+
'en' : {
|
|
14
|
+
1 : 'Jan',
|
|
15
|
+
2 : 'Feb',
|
|
16
|
+
3 : 'Mar',
|
|
17
|
+
4 : 'Apr',
|
|
18
|
+
5 : 'May',
|
|
19
|
+
6 : 'Jun',
|
|
20
|
+
7 : 'Jul',
|
|
21
|
+
8 : 'Aug',
|
|
22
|
+
9 : 'Sep',
|
|
23
|
+
10: 'Oct',
|
|
24
|
+
11: 'Nov',
|
|
25
|
+
12: 'Dec'
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}, ts.dates );
|
|
13
29
|
|
|
14
30
|
ts.addParser({
|
|
15
31
|
id: 'month',
|
|
16
|
-
is: function(){
|
|
32
|
+
is: function() {
|
|
17
33
|
return false;
|
|
18
34
|
},
|
|
19
|
-
format: function(
|
|
20
|
-
if (
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
35
|
+
format: function( str, table, cell, cellIndex ) {
|
|
36
|
+
if ( str ) {
|
|
37
|
+
var m, month,
|
|
38
|
+
c = table.config,
|
|
39
|
+
// add options to 'config.globalize' for all columns --> globalize : { lang: 'en' }
|
|
40
|
+
// or per column by using the column index --> globalize : { 0 : { lang: 'fr' } }
|
|
41
|
+
options = c.globalize && ( c.globalize[ cellIndex ] || c.globalize ) || {},
|
|
42
|
+
months = ts.dates.months[ options.lang || 'en' ];
|
|
43
|
+
if ( c.ignoreCase ) {
|
|
44
|
+
str = str.toLowerCase();
|
|
45
|
+
}
|
|
46
|
+
for ( month in months ) {
|
|
47
|
+
if ( typeof month === 'string' ) {
|
|
48
|
+
m = months[ month ];
|
|
49
|
+
if ( c.ignoreCase ) {
|
|
50
|
+
m = m.toLowerCase();
|
|
51
|
+
}
|
|
52
|
+
if ( str.match( m ) ) {
|
|
53
|
+
return parseInt( month, 10 );
|
|
54
|
+
}
|
|
27
55
|
}
|
|
28
|
-
}
|
|
29
|
-
// return s (original string) if there isn't a match
|
|
30
|
-
// (non-weekdays will sort separately and empty cells will sort as expected)
|
|
31
|
-
return j < 0 ? s : j;
|
|
56
|
+
}
|
|
32
57
|
}
|
|
33
|
-
return
|
|
58
|
+
return str;
|
|
34
59
|
},
|
|
35
60
|
type: 'numeric'
|
|
36
61
|
});
|
|
@@ -1,36 +1,94 @@
|
|
|
1
|
-
/*! Parser: weekday - updated
|
|
1
|
+
/*! Parser: weekday - updated 11/2/2015 (v2.24.1) */
|
|
2
2
|
/* Demo: http://jsfiddle.net/Mottie/abkNM/4169/ */
|
|
3
3
|
/*jshint jquery:true */
|
|
4
4
|
;(function($){
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
7
7
|
var ts = $.tablesorter;
|
|
8
|
-
ts.dates = $.extend({},
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
ts.dates = $.extend( true, {}, {
|
|
9
|
+
// See http://mottie.github.io/tablesorter/docs/example-widget-grouping.html
|
|
10
|
+
// for details on how to use CLDR data for a locale to add data for this parser
|
|
11
|
+
// CLDR returns { sun: "Sun", mon: "Mon", tue: "Tue", wed: "Wed", thu: "Thu", ... }
|
|
12
|
+
weekdays : {
|
|
13
|
+
'en' : {
|
|
14
|
+
'sun' : 'Sun',
|
|
15
|
+
'mon' : 'Mon',
|
|
16
|
+
'tue' : 'Tue',
|
|
17
|
+
'wed' : 'Wed',
|
|
18
|
+
'thu' : 'Thu',
|
|
19
|
+
'fri' : 'Fri',
|
|
20
|
+
'sat' : 'Sat'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
// set table.config.weekStarts to change weekday start date for your locale
|
|
25
|
+
// cross-reference of a date on which the week starts on a...
|
|
26
|
+
// https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/weekData.json
|
|
27
|
+
weekStartList : {
|
|
28
|
+
'sun' : '1995', // Sun 1/1/1995
|
|
29
|
+
'mon' : '1996', // Mon 1/1/1996
|
|
30
|
+
'fri' : '1999', // Friday 1/1/1999
|
|
31
|
+
'sat' : '2000' // Sat 1/1/2000
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
// do not modify this array; it is used for cross referencing
|
|
35
|
+
weekdaysXref : [ 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat' ]
|
|
36
|
+
|
|
37
|
+
}, ts.dates );
|
|
13
38
|
|
|
14
39
|
ts.addParser({
|
|
15
40
|
id: 'weekday',
|
|
16
|
-
is: function(){
|
|
41
|
+
is: function() {
|
|
17
42
|
return false;
|
|
18
43
|
},
|
|
19
|
-
format: function(
|
|
20
|
-
if (
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
44
|
+
format: function( str, table, cell, cellIndex ) {
|
|
45
|
+
if ( str ) {
|
|
46
|
+
var d, day, num,
|
|
47
|
+
c = table.config,
|
|
48
|
+
// add options to 'config.globalize' for all columns --> globalize : { lang: 'en' }
|
|
49
|
+
// or per column by using the column index --> globalize : { 0 : { lang: 'fr' } }
|
|
50
|
+
options = c.globalize && ( c.globalize[ cellIndex ] || c.globalize ) || {},
|
|
51
|
+
days = ts.dates.weekdays[ options.lang || 'en' ],
|
|
52
|
+
xref = ts.dates.weekdaysXref;
|
|
53
|
+
if ( c.ignoreCase ) {
|
|
54
|
+
str = str.toLowerCase();
|
|
55
|
+
}
|
|
56
|
+
for ( day in days ) {
|
|
57
|
+
if ( typeof day === 'string' ) {
|
|
58
|
+
d = days[ day ];
|
|
59
|
+
if ( c.ignoreCase ) {
|
|
60
|
+
d = d.toLowerCase();
|
|
61
|
+
}
|
|
62
|
+
if ( str.match( d ) ) {
|
|
63
|
+
num = $.inArray( day, xref );
|
|
64
|
+
return num > -1 ? num : str;
|
|
65
|
+
}
|
|
27
66
|
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return str;
|
|
70
|
+
},
|
|
71
|
+
type: 'numeric'
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// useful when a group widget date column is set to "group-date-week"
|
|
75
|
+
// and you want to only sort on the day of the week ignore the actual date, month and year
|
|
76
|
+
ts.addParser({
|
|
77
|
+
id: 'weekday-index',
|
|
78
|
+
is: function() {
|
|
79
|
+
return false;
|
|
80
|
+
},
|
|
81
|
+
format: function( str, table ) {
|
|
82
|
+
if ( str ) {
|
|
83
|
+
var c = table.config,
|
|
84
|
+
date = new Date( str );
|
|
85
|
+
if ( date instanceof Date && isFinite( date ) ) {
|
|
86
|
+
// use a specific date that started with that weekday so sorting is only going to be
|
|
87
|
+
// based on the day of the week and not the date, month or year
|
|
88
|
+
return new Date( '1/' + ( date.getDay() + 1 ) + '/' + ts.dates.weekStartList[ c.weekStarts || 'sun' ] );
|
|
89
|
+
}
|
|
32
90
|
}
|
|
33
|
-
return
|
|
91
|
+
return str;
|
|
34
92
|
},
|
|
35
93
|
type: 'numeric'
|
|
36
94
|
});
|