Parsers: don't use $.extend for simple additions

This commit is contained in:
Rob Garrison 2015-11-22 21:21:50 -06:00
parent a5d7b34fd4
commit a85a2a5a66
8 changed files with 75 additions and 77 deletions

View File

@ -1,2 +1,2 @@
/*! Parser: Month - updated 11/2/2015 (v2.24.1) */ /*! Parser: Month - updated 11/22/2015 (v2.24.6) */
!function(a){"use strict";var b=a.tablesorter;b.dates.months=a.extend({},{en:{1:"Jan",2:"Feb",3:"Mar",4:"Apr",5:"May",6:"Jun",7:"Jul",8:"Aug",9:"Sep",10:"Oct",11:"Nov",12:"Dec"}},b.dates.months),b.addParser({id:"month",is:function(){return!1},format:function(a,c,d,e){if(a){var f,g,h=c.config,i=h.globalize&&(h.globalize[e]||h.globalize)||{},j=b.dates.months[i.lang||"en"];h.ignoreCase&&(a=a.toLowerCase());for(g in j)if("string"==typeof g&&(f=j[g],h.ignoreCase&&(f=f.toLowerCase()),a.match(f)))return parseInt(g,10)}return a},type:"numeric"})}(jQuery); !function(a){"use strict";var b=a.tablesorter;b.dates||(b.dates={}),b.dates.months||(b.dates.months={}),b.dates.months.en={1:"Jan",2:"Feb",3:"Mar",4:"Apr",5:"May",6:"Jun",7:"Jul",8:"Aug",9:"Sep",10:"Oct",11:"Nov",12:"Dec"},b.addParser({id:"month",is:function(){return!1},format:function(a,c,d,e){if(a){var f,g,h=c.config,i=h.globalize&&(h.globalize[e]||h.globalize)||{},j=b.dates.months[i.lang||"en"];h.ignoreCase&&(a=a.toLowerCase());for(g in j)if("string"==typeof g&&(f=j[g],h.ignoreCase&&(f=f.toLowerCase()),a.match(f)))return parseInt(g,10)}return a},type:"numeric"})}(jQuery);

View File

@ -1,5 +1,5 @@
/*! Parser: date ranges - updated 2/23/2015 (v2.21.0) */ /*! Parser: date ranges -updated 11/22/2015 (v2.24.6) */
!function(a){"use strict";var b,c=a.tablesorter,d={mdy:/(\d{1,2}[-\s]\d{1,2}[-\s]\d{4}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/gi,dmy:/(\d{1,2}[-\s]\d{1,2}[-\s]\d{4}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/gi,dmyreplace:/(\d{1,2})[-\s](\d{1,2})[-\s](\d{4})/,ymd:/(\d{4}[-\s]\d{1,2}[-\s]\d{1,2}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/gi,ymdreplace:/(\d{4})[-\s](\d{1,2})[-\s](\d{1,2})/,overall_dMMMyyyy:/(\d{1,2}\s+\w+\s+\d{4}(\s+\d{1,2}:\d{2}(:\d{2})?(\s\w+)?)?)/g,matches_dMMMyyyy:/(\d{1,2})\s+(\w+)\s+(\d{4})/};/*! date-range MMDDYYYY */ !function(a){"use strict";var b,c=a.tablesorter,d={mdy:/(\d{1,2}[-\s]\d{1,2}[-\s]\d{4}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/gi,dmy:/(\d{1,2}[-\s]\d{1,2}[-\s]\d{4}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/gi,dmyreplace:/(\d{1,2})[-\s](\d{1,2})[-\s](\d{4})/,ymd:/(\d{4}[-\s]\d{1,2}[-\s]\d{1,2}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/gi,ymdreplace:/(\d{4})[-\s](\d{1,2})[-\s](\d{1,2})/,overall_dMMMyyyy:/(\d{1,2}\s+\w+\s+\d{4}(\s+\d{1,2}:\d{2}(:\d{2})?(\s\w+)?)?)/g,matches_dMMMyyyy:/(\d{1,2})\s+(\w+)\s+(\d{4})/};/*! date-range MMDDYYYY */
a.tablesorter.addParser({id:"date-range-mdy",is:function(){return!1},format:function(a){var b,c,e,f,g=[];if(c=a.replace(/\s+/g," ").replace(/[\/\-.,]/g,"-").match(d.mdy),f=c&&c.length){for(e=0;f>e;e++)b=new Date(c[e]),g.push(b instanceof Date&&isFinite(b)?b.getTime():c[e]);return g.sort().join(" - ")}return a},type:"text"}),/*! date-range DDMMYYYY */ a.tablesorter.addParser({id:"date-range-mdy",is:function(){return!1},format:function(a){var b,c,e,f,g=[];if(c=a.replace(/\s+/g," ").replace(/[\/\-.,]/g,"-").match(d.mdy),f=c&&c.length){for(e=0;f>e;e++)b=new Date(c[e]),g.push(b instanceof Date&&isFinite(b)?b.getTime():c[e]);return g.sort().join(" - ")}return a},type:"text"}),/*! date-range DDMMYYYY */
a.tablesorter.addParser({id:"date-range-dmy",is:function(){return!1},format:function(a){var b,c,e,f,g=[];if(c=a.replace(/\s+/g," ").replace(/[\/\-.,]/g,"-").match(d.dmy),f=c&&c.length){for(e=0;f>e;e++)b=new Date((""+c[e]).replace(d.dmyreplace,"$2/$1/$3")),g.push(b instanceof Date&&isFinite(b)?b.getTime():c[e]);return g.sort().join(" - ")}return a},type:"text"}),/*! date-range DDMMYYYY */ a.tablesorter.addParser({id:"date-range-dmy",is:function(){return!1},format:function(a){var b,c,e,f,g=[];if(c=a.replace(/\s+/g," ").replace(/[\/\-.,]/g,"-").match(d.dmy),f=c&&c.length){for(e=0;f>e;e++)b=new Date((""+c[e]).replace(d.dmyreplace,"$2/$1/$3")),g.push(b instanceof Date&&isFinite(b)?b.getTime():c[e]);return g.sort().join(" - ")}return a},type:"text"}),/*! date-range DDMMYYYY */
a.tablesorter.addParser({id:"date-range-ymd",is:function(){return!1},format:function(a){var b,c,e,f,g=[];if(c=a.replace(/\s+/g," ").replace(/[\/\-.,]/g,"-").match(d.ymd),f=c&&c.length){for(e=0;f>e;e++)b=new Date((""+c[e]).replace(d.ymdreplace,"$2/$3/$1")),g.push(b instanceof Date&&isFinite(b)?b.getTime():c[e]);return g.sort().join(" - ")}return a},type:"text"}),c.dates.months=a.extend({},{en:{1:"Jan",2:"Feb",3:"Mar",4:"Apr",5:"May",6:"Jun",7:"Jul",8:"Aug",9:"Sep",10:"Oct",11:"Nov",12:"Dec"}},c.dates.months),b=function(a,b,d){var e,f,g=b.globalize&&(b.globalize[d]||b.globalize)||{},h=c.dates.months[g.lang||"en"];b.ignoreCase&&(a=a.toLowerCase());for(f in h)if("string"==typeof f&&(e=h[f],b.ignoreCase&&(e=e.toLowerCase()),a.match(e)))return parseInt(f,10);return a},c.addParser({id:"date-range-dMMMyyyy",is:function(){return!1},format:function(a,e,f,g){var h,i,j,k,l=[],m=a.replace(/\s+/g," ").match(d.overall_dMMMyyyy),n=m&&m.length;if(n){for(k=0;n>k;k++)h="",j=m[k].match(d.matches_dMMMyyyy),j&&j.length>=4&&(j.shift(),i=b(j[1],e.config,g),isNaN(i)||(m[k]=m[k].replace(j[1],i)),h=new Date((""+m[k]).replace(c.regex.shortDateXXY,"$3/$2/$1"))),l.push(h instanceof Date&&isFinite(h)?h.getTime():m[k]);return l.sort().join(" - ")}return a},type:"text"})}(jQuery); a.tablesorter.addParser({id:"date-range-ymd",is:function(){return!1},format:function(a){var b,c,e,f,g=[];if(c=a.replace(/\s+/g," ").replace(/[\/\-.,]/g,"-").match(d.ymd),f=c&&c.length){for(e=0;f>e;e++)b=new Date((""+c[e]).replace(d.ymdreplace,"$2/$3/$1")),g.push(b instanceof Date&&isFinite(b)?b.getTime():c[e]);return g.sort().join(" - ")}return a},type:"text"}),c.dates||(c.dates={}),c.dates.months||(c.dates.months={}),c.dates.months.en={1:"Jan",2:"Feb",3:"Mar",4:"Apr",5:"May",6:"Jun",7:"Jul",8:"Aug",9:"Sep",10:"Oct",11:"Nov",12:"Dec"},b=function(a,b,d){var e,f,g=b.globalize&&(b.globalize[d]||b.globalize)||{},h=c.dates.months[g.lang||"en"];b.ignoreCase&&(a=a.toLowerCase());for(f in h)if("string"==typeof f&&(e=h[f],b.ignoreCase&&(e=e.toLowerCase()),a.match(e)))return parseInt(f,10);return a},c.addParser({id:"date-range-dMMMyyyy",is:function(){return!1},format:function(a,e,f,g){var h,i,j,k,l=[],m=a.replace(/\s+/g," ").match(d.overall_dMMMyyyy),n=m&&m.length;if(n){for(k=0;n>k;k++)h="",j=m[k].match(d.matches_dMMMyyyy),j&&j.length>=4&&(j.shift(),i=b(j[1],e.config,g),isNaN(i)||(m[k]=m[k].replace(j[1],i)),h=new Date((""+m[k]).replace(c.regex.shortDateXXY,"$3/$2/$1"))),l.push(h instanceof Date&&isFinite(h)?h.getTime():m[k]);return l.sort().join(" - ")}return a},type:"text"})}(jQuery);

View File

@ -1,2 +1,2 @@
/*! Parser: two digit year - updated 10/26/2014 (v2.18.0) */ /*! Parser: two digit year - updated 11/22/2015 (v2.24.6) */
!function(a){"use strict";var b=50,c=a.tablesorter,d=(new Date).getFullYear();c.dates=a.extend({},c.dates,{regxxxxyy:/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{2})/,regyyxxxx:/(\d{2})[\/\s](\d{1,2})[\/\s](\d{1,2})/}),c.formatDate=function(a,c,e,f){if(a){var g,h,i=a.replace(/\s+/g," ").replace(/[-.,]/g,"/").replace(c,e),j=new Date(i);if(j instanceof Date&&isFinite(j)){for(g=j.getFullYear(),h=f&&f.config.dateRange||b;d-g>h;)g+=100;return j.setFullYear(g)}}return a},a.tablesorter.addParser({id:"ddmmyy",is:function(){return!1},format:function(a,b){return c.formatDate(a,c.dates.regxxxxyy,"$2/$1/19$3",b)},type:"numeric"}),a.tablesorter.addParser({id:"mmddyy",is:function(){return!1},format:function(a,b){return c.formatDate(a,c.dates.regxxxxyy,"$1/$2/19$3",b)},type:"numeric"}),a.tablesorter.addParser({id:"yymmdd",is:function(){return!1},format:function(a,b){return c.formatDate(a,c.dates.regyyxxxx,"$2/$3/19$1",b)},type:"numeric"})}(jQuery); !function(a){"use strict";var b=50,c=a.tablesorter,d=(new Date).getFullYear();c.dates||(c.dates={}),c.dates.regxxxxyy=/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{2})/,c.dates.regyyxxxx=/(\d{2})[\/\s](\d{1,2})[\/\s](\d{1,2})/,c.formatDate=function(a,c,e,f){if(a){var g,h,i=a.replace(/\s+/g," ").replace(/[-.,]/g,"/").replace(c,e),j=new Date(i);if(j instanceof Date&&isFinite(j)){for(g=j.getFullYear(),h=f&&f.config.dateRange||b;d-g>h;)g+=100;return j.setFullYear(g)}}return a},a.tablesorter.addParser({id:"ddmmyy",is:function(){return!1},format:function(a,b){return c.formatDate(a,c.dates.regxxxxyy,"$2/$1/19$3",b)},type:"numeric"}),a.tablesorter.addParser({id:"mmddyy",is:function(){return!1},format:function(a,b){return c.formatDate(a,c.dates.regxxxxyy,"$1/$2/19$3",b)},type:"numeric"}),a.tablesorter.addParser({id:"yymmdd",is:function(){return!1},format:function(a,b){return c.formatDate(a,c.dates.regyyxxxx,"$2/$3/19$1",b)},type:"numeric"})}(jQuery);

View File

@ -1,2 +1,2 @@
/*! Parser: weekday - updated 11/2/2015 (v2.24.1) */ /*! Parser: weekday - updated 11/22/2015 (v2.24.6) */
!function(a){"use strict";var b=a.tablesorter;b.dates=a.extend(!0,{},{weekdays:{en:{sun:"Sun",mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat"}},weekStartList:{sun:"1995",mon:"1996",fri:"1999",sat:"2000"},weekdaysXref:["sun","mon","tue","wed","thu","fri","sat"]},b.dates),b.addParser({id:"weekday",is:function(){return!1},format:function(c,d,e,f){if(c){var g,h,i,j=d.config,k=j.globalize&&(j.globalize[f]||j.globalize)||{},l=b.dates.weekdays[k.lang||"en"],m=b.dates.weekdaysXref;j.ignoreCase&&(c=c.toLowerCase());for(h in l)if("string"==typeof h&&(g=l[h],j.ignoreCase&&(g=g.toLowerCase()),c.match(g)))return i=a.inArray(h,m),i>-1?i:c}return c},type:"numeric"}),b.addParser({id:"weekday-index",is:function(){return!1},format:function(a,c){if(a){var d=c.config,e=new Date(a);if(e instanceof Date&&isFinite(e))return new Date("1/"+(e.getDay()+1)+"/"+b.dates.weekStartList[d.weekStarts||"sun"])}return a},type:"numeric"})}(jQuery); !function(a){"use strict";var b=a.tablesorter;b.dates||(b.dates={}),b.dates.weekdays||(b.dates.weekdays={}),b.dates.weekdays.en={sun:"Sun",mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat"},b.dates.weekStartList={sun:"1995",mon:"1996",fri:"1999",sat:"2000"},b.dates.weekdaysXref=["sun","mon","tue","wed","thu","fri","sat"],b.addParser({id:"weekday",is:function(){return!1},format:function(c,d,e,f){if(c){var g,h,i,j=d.config,k=j.globalize&&(j.globalize[f]||j.globalize)||{},l=b.dates.weekdays[k.lang||"en"],m=b.dates.weekdaysXref;j.ignoreCase&&(c=c.toLowerCase());for(h in l)if("string"==typeof h&&(g=l[h],j.ignoreCase&&(g=g.toLowerCase()),c.match(g)))return i=a.inArray(h,m),i>-1?i:c}return c},type:"numeric"}),b.addParser({id:"weekday-index",is:function(){return!1},format:function(a,c){if(a){var d=c.config,e=new Date(a);if(e instanceof Date&&isFinite(e))return new Date("1/"+(e.getDay()+1)+"/"+b.dates.weekStartList[d.weekStarts||"sun"])}return a},type:"numeric"})}(jQuery);

View File

@ -1,29 +1,30 @@
/*! Parser: Month - updated 11/2/2015 (v2.24.1) */ /*! Parser: Month - updated 11/22/2015 (v2.24.6) */
/* Demo: http://jsfiddle.net/Mottie/abkNM/4169/ */ /* Demo: http://jsfiddle.net/Mottie/abkNM/4169/ */
/*jshint jquery:true */ /*jshint jquery:true */
;(function($){ ;(function($){
'use strict'; 'use strict';
var ts = $.tablesorter; var ts = $.tablesorter;
ts.dates.months = $.extend( {}, {
if ( !ts.dates ) { ts.dates = {}; }
if ( !ts.dates.months ) { ts.dates.months = {}; }
ts.dates.months.en = {
// See http://mottie.github.io/tablesorter/docs/example-widget-grouping.html // See http://mottie.github.io/tablesorter/docs/example-widget-grouping.html
// for details on how to use CLDR data for a locale to add data for this parser // for details on how to use CLDR data for a locale to add data for this parser
// CLDR returns an object { 1: "Jan", 2: "Feb", 3: "Mar", ..., 12: "Dec" } // CLDR returns an object { 1: "Jan", 2: "Feb", 3: "Mar", ..., 12: "Dec" }
'en' : { 1 : 'Jan',
1 : 'Jan', 2 : 'Feb',
2 : 'Feb', 3 : 'Mar',
3 : 'Mar', 4 : 'Apr',
4 : 'Apr', 5 : 'May',
5 : 'May', 6 : 'Jun',
6 : 'Jun', 7 : 'Jul',
7 : 'Jul', 8 : 'Aug',
8 : 'Aug', 9 : 'Sep',
9 : 'Sep', 10: 'Oct',
10: 'Oct', 11: 'Nov',
11: 'Nov', 12: 'Dec'
12: 'Dec' };
}
}, ts.dates.months );
ts.addParser({ ts.addParser({
id: 'month', id: 'month',

View File

@ -1,4 +1,4 @@
/*! Parser: date ranges - updated 2/23/2015 (v2.21.0) */ /*! Parser: date ranges -updated 11/22/2015 (v2.24.6) */
/* Include the 'widget-filter-type-insideRange.js' to filter ranges */ /* Include the 'widget-filter-type-insideRange.js' to filter ranges */
/*jshint jquery:true */ /*jshint jquery:true */
;(function($){ ;(function($){
@ -95,25 +95,25 @@
type: 'text' type: 'text'
}); });
ts.dates.months = $.extend( {}, { if ( !ts.dates ) { ts.dates = {}; }
if ( !ts.dates.months ) { ts.dates.months = {}; }
ts.dates.months.en = {
// See http://mottie.github.io/tablesorter/docs/example-widget-grouping.html // See http://mottie.github.io/tablesorter/docs/example-widget-grouping.html
// for details on how to use CLDR data for a locale to add data for this parser // for details on how to use CLDR data for a locale to add data for this parser
// CLDR returns an object { 1: "Jan", 2: "Feb", 3: "Mar", ..., 12: "Dec" } // CLDR returns an object { 1: "Jan", 2: "Feb", 3: "Mar", ..., 12: "Dec" }
'en' : { 1 : 'Jan',
1 : 'Jan', 2 : 'Feb',
2 : 'Feb', 3 : 'Mar',
3 : 'Mar', 4 : 'Apr',
4 : 'Apr', 5 : 'May',
5 : 'May', 6 : 'Jun',
6 : 'Jun', 7 : 'Jul',
7 : 'Jul', 8 : 'Aug',
8 : 'Aug', 9 : 'Sep',
9 : 'Sep', 10: 'Oct',
10: 'Oct', 11: 'Nov',
11: 'Nov', 12: 'Dec'
12: 'Dec' };
}
}, ts.dates.months );
getMonthVal = function( str, c, cellIndex ) { getMonthVal = function( str, c, cellIndex ) {
var m, month, var m, month,

View File

@ -1,4 +1,4 @@
/*! Parser: two digit year - updated 10/26/2014 (v2.18.0) */ /*! Parser: two digit year - updated 11/22/2015 (v2.24.6) */
/* Demo: http://mottie.github.io/tablesorter/docs/example-parsers-dates.html */ /* Demo: http://mottie.github.io/tablesorter/docs/example-parsers-dates.html */
/*jshint jquery:true */ /*jshint jquery:true */
;(function($){ ;(function($){
@ -13,10 +13,9 @@
ts = $.tablesorter, ts = $.tablesorter,
now = new Date().getFullYear(); now = new Date().getFullYear();
ts.dates = $.extend({}, ts.dates, { if ( !ts.dates ) { ts.dates = {}; }
regxxxxyy: /(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{2})/, ts.dates.regxxxxyy = /(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{2})/;
regyyxxxx: /(\d{2})[\/\s](\d{1,2})[\/\s](\d{1,2})/ ts.dates.regyyxxxx = /(\d{2})[\/\s](\d{1,2})[\/\s](\d{1,2})/;
});
ts.formatDate = function(s, regex, format, table){ ts.formatDate = function(s, regex, format, table){
if (s) { if (s) {

View File

@ -1,40 +1,38 @@
/*! Parser: weekday - updated 11/2/2015 (v2.24.1) */ /*! Parser: weekday - updated 11/22/2015 (v2.24.6) */
/* Demo: http://jsfiddle.net/Mottie/abkNM/4169/ */ /* Demo: http://jsfiddle.net/Mottie/abkNM/4169/ */
/*jshint jquery:true */ /*jshint jquery:true */
;(function($){ ;(function($){
'use strict'; 'use strict';
var ts = $.tablesorter; var ts = $.tablesorter;
ts.dates = $.extend( true, {}, {
// See http://mottie.github.io/tablesorter/docs/example-widget-grouping.html
// for details on how to use CLDR data for a locale to add data for this parser
// CLDR returns { sun: "Sun", mon: "Mon", tue: "Tue", wed: "Wed", thu: "Thu", ... }
weekdays : {
'en' : {
'sun' : 'Sun',
'mon' : 'Mon',
'tue' : 'Tue',
'wed' : 'Wed',
'thu' : 'Thu',
'fri' : 'Fri',
'sat' : 'Sat'
}
},
// set table.config.weekStarts to change weekday start date for your locale if ( !ts.dates ) { ts.dates = {}; }
// cross-reference of a date on which the week starts on a... if ( !ts.dates.weekdays ) { ts.dates.weekdays = {}; }
// https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/weekData.json // See http://mottie.github.io/tablesorter/docs/example-widget-grouping.html
weekStartList : { // for details on how to use CLDR data for a locale to add data for this parser
'sun' : '1995', // Sun 1/1/1995 // CLDR returns { sun: "Sun", mon: "Mon", tue: "Tue", wed: "Wed", thu: "Thu", ... }
'mon' : '1996', // Mon 1/1/1996 ts.dates.weekdays.en = {
'fri' : '1999', // Friday 1/1/1999 'sun' : 'Sun',
'sat' : '2000' // Sat 1/1/2000 'mon' : 'Mon',
}, 'tue' : 'Tue',
'wed' : 'Wed',
// do not modify this array; it is used for cross referencing 'thu' : 'Thu',
weekdaysXref : [ 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat' ] 'fri' : 'Fri',
'sat' : 'Sat'
}, ts.dates ); };
// set table.config.weekStarts to change weekday start date for your locale
// cross-reference of a date on which the week starts on a...
// https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/weekData.json
// locale agnostic
ts.dates.weekStartList = {
'sun' : '1995', // Sun 1/1/1995
'mon' : '1996', // Mon 1/1/1996
'fri' : '1999', // Friday 1/1/1999
'sat' : '2000' // Sat 1/1/2000
};
// do not modify this array; it is used for cross referencing weekdays
// locale agnostic
ts.dates.weekdaysXref = [ 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat' ];
ts.addParser({ ts.addParser({
id: 'weekday', id: 'weekday',