2015-11-02 05:44:14 +00:00
|
|
|
/*! Parser: weekday - updated 11/2/2015 (v2.24.1) */
|
2015-10-31 15:08:21 +00:00
|
|
|
/* Demo: http://jsfiddle.net/Mottie/abkNM/4169/ */
|
|
|
|
/*jshint jquery:true */
|
2015-11-02 05:44:14 +00:00
|
|
|
!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);
|