-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parsers: globalization tweaks & new parser
Make month & weekday Globalize ready. globalization parser now caches the Globalize object in a "Globalize" option Add "weekday-index" parser Update demos
- Loading branch information
Showing
9 changed files
with
288 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
/*! Parser: Month - updated 10/26/2014 (v2.18.0) */ | ||
/*! Parser: Month - updated 11/2/2015 (v2.24.1) */ | ||
/* Demo: http://jsfiddle.net/Mottie/abkNM/4169/ */ | ||
/*jshint jquery:true */ | ||
!function(a){"use strict";var b=a.tablesorter;b.dates=a.extend({},b.dates,{ | ||
// *** modify this array to match the desired language *** | ||
monthCased:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}),b.dates.monthLower=b.dates.monthCased.join(",").toLocaleLowerCase().split(","),b.addParser({id:"month",is:function(){return!1},format:function(c,d){if(c){var e=-1,f=d.config,g=f.ignoreCase?c.toLocaleLowerCase():c; | ||
// return s (original string) if there isn't a match | ||
// (non-weekdays will sort separately and empty cells will sort as expected) | ||
return a.each(b.dates["month"+(f.ignoreCase?"Lower":"Cased")],function(a,b){return 0>e&&g.match(b)?(e=a,!1):void 0}),0>e?c:e}return c},type:"numeric"})}(jQuery); | ||
!function(a){"use strict";var b=a.tablesorter;b.dates=a.extend({},{ | ||
// 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 an object { 1: "Jan", 2: "Feb", 3: "Mar", ..., 12: "Dec" } | ||
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.dates),b.addParser({id:"month",is:function(){return!1},format:function(a,c,d,e){if(a){var f,g,h=c.config, | ||
// add options to 'config.globalize' for all columns --> globalize : { lang: 'en' } | ||
// or per column by using the column index --> globalize : { 0 : { lang: 'fr' } } | ||
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
/*! Parser: weekday - updated 10/26/2014 (v2.18.0) */ | ||
/*! Parser: weekday - updated 11/2/2015 (v2.24.1) */ | ||
/* Demo: http://jsfiddle.net/Mottie/abkNM/4169/ */ | ||
/*jshint jquery:true */ | ||
!function(a){"use strict";var b=a.tablesorter;b.dates=a.extend({},b.dates,{ | ||
// *** modify this array to change match the language *** | ||
weekdayCased:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]}),b.dates.weekdayLower=b.dates.weekdayCased.join(",").toLocaleLowerCase().split(","),b.addParser({id:"weekday",is:function(){return!1},format:function(c,d){if(c){var e=-1,f=d.config; | ||
// return s (original string) if there isn't a match | ||
// (non-weekdays will sort separately and empty cells will sort as expected) | ||
return c=f.ignoreCase?c.toLocaleLowerCase():c,a.each(b.dates["weekday"+(f.ignoreCase?"Lower":"Cased")],function(a,b){return 0>e&&c.match(b)?(e=a,!1):void 0}),0>e?c:e}return c},type:"numeric"})}(jQuery); | ||
!function(a){"use strict";var b=a.tablesorter;b.dates=a.extend(!0,{},{ | ||
// 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 | ||
// cross-reference of a date on which the week starts on a... | ||
// https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/weekData.json | ||
weekStartList:{sun:"1995",// Sun 1/1/1995 | ||
mon:"1996",// Mon 1/1/1996 | ||
fri:"1999",// Friday 1/1/1999 | ||
sat:"2000"}, | ||
// do not modify this array; it is used for cross referencing | ||
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, | ||
// add options to 'config.globalize' for all columns --> globalize : { lang: 'en' } | ||
// or per column by using the column index --> globalize : { 0 : { lang: 'fr' } } | ||
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"}), | ||
// useful when a group widget date column is set to "group-date-week" | ||
// and you want to only sort on the day of the week ignore the actual date, month and year | ||
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)) | ||
// use a specific date that started with that weekday so sorting is only going to be | ||
// based on the day of the week and not the date, month or year | ||
return new Date("1/"+(e.getDay()+1)+"/"+b.dates.weekStartList[d.weekStarts||"sun"])}return a},type:"numeric"})}(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.