Debian Codegraph @

js/parsers/parser-date-month.js

raw symbols SCIP
1 /*! Parser: Month - updated 11/22/2015 (v2.24.6) */
2 /* Demo: http://jsfiddle.net/Mottie/abkNM/4169/ */
3 /*jshint jquery:true */
4 ;(function($) {
5 'use strict';
6
7 var ts = $.tablesorter;
8
9 if ( !ts.dates ) { ts.dates = {}; }
10 if ( !ts.dates.months ) { ts.dates.months = {}; }
11 ts.dates.months.en = {
12 // See http://mottie.github.io/tablesorter/docs/example-widget-grouping.html
13 // for details on how to use CLDR data for a locale to add data for this parser
14 // CLDR returns an object { 1: "Jan", 2: "Feb", 3: "Mar", ..., 12: "Dec" }
15 1 : 'Jan',
16 2 : 'Feb',
17 3 : 'Mar',
18 4 : 'Apr',
19 5 : 'May',
20 6 : 'Jun',
21 7 : 'Jul',
22 8 : 'Aug',
23 9 : 'Sep',
24 10: 'Oct',
25 11: 'Nov',
26 12: 'Dec'
27 };
28
29 ts.addParser({
30 id: 'month',
31 is: function() {
32 return false;
33 },
34 format: function( str, table, cell, cellIndex ) {
35 if ( str ) {
36 var m, month,
37 c = table.config,
38 // add options to 'config.globalize' for all columns --> globalize : { lang: 'en' }
39 // or per column by using the column index --> globalize : { 0 : { lang: 'fr' } }
40 options = c.globalize && ( c.globalize[ cellIndex ] || c.globalize ) || {},
41 months = ts.dates.months[ options.lang || 'en' ];
42 if ( c.ignoreCase ) {
43 str = str.toLowerCase();
44 }
45 for ( month in months ) {
46 if ( typeof month === 'string' ) {
47 m = months[ month ];
48 if ( c.ignoreCase ) {
49 m = m.toLowerCase();
50 }
51 if ( str.match( m ) ) {
52 return parseInt( month, 10 );
53 }
54 }
55 }
56 }
57 return str;
58 },
59 type: 'numeric'
60 });
61
62 })(jQuery);