source: trunk/web/addons/job_monarch/lib/extjs/source/data/SortTypes.js @ 619

Last change on this file since 619 was 619, checked in by ramonb, 15 years ago

lib/:

  • added new AJAX dependancies: ExtJS, pChart, Lightbox2
File size: 2.3 KB
Line 
1/*
2 * Ext JS Library 2.2.1
3 * Copyright(c) 2006-2009, Ext JS, LLC.
4 * licensing@extjs.com
5 *
6 * http://extjs.com/license
7 */
8
9
10/**
11 * @class Ext.data.SortTypes
12 * @singleton
13 * Defines the default sorting (casting?) comparison functions used when sorting data.
14 */
15Ext.data.SortTypes = {
16    /**
17     * Default sort that does nothing
18     * @param {Mixed} s The value being converted
19     * @return {Mixed} The comparison value
20     */
21    none : function(s){
22        return s;
23    },
24   
25    /**
26     * The regular expression used to strip tags
27     * @type {RegExp}
28     * @property
29     */
30    stripTagsRE : /<\/?[^>]+>/gi,
31   
32    /**
33     * Strips all HTML tags to sort on text only
34     * @param {Mixed} s The value being converted
35     * @return {String} The comparison value
36     */
37    asText : function(s){
38        return String(s).replace(this.stripTagsRE, "");
39    },
40   
41    /**
42     * Strips all HTML tags to sort on text only - Case insensitive
43     * @param {Mixed} s The value being converted
44     * @return {String} The comparison value
45     */
46    asUCText : function(s){
47        return String(s).toUpperCase().replace(this.stripTagsRE, "");
48    },
49   
50    /**
51     * Case insensitive string
52     * @param {Mixed} s The value being converted
53     * @return {String} The comparison value
54     */
55    asUCString : function(s) {
56        return String(s).toUpperCase();
57    },
58   
59    /**
60     * Date sorting
61     * @param {Mixed} s The value being converted
62     * @return {Number} The comparison value
63     */
64    asDate : function(s) {
65        if(!s){
66            return 0;
67        }
68        if(Ext.isDate(s)){
69            return s.getTime();
70        }
71        return Date.parse(String(s));
72    },
73   
74    /**
75     * Float sorting
76     * @param {Mixed} s The value being converted
77     * @return {Float} The comparison value
78     */
79    asFloat : function(s) {
80        var val = parseFloat(String(s).replace(/,/g, ""));
81        if(isNaN(val)) val = 0;
82        return val;
83    },
84   
85    /**
86     * Integer sorting
87     * @param {Mixed} s The value being converted
88     * @return {Number} The comparison value
89     */
90    asInt : function(s) {
91        var val = parseInt(String(s).replace(/,/g, ""));
92        if(isNaN(val)) val = 0;
93        return val;
94    }
95};
Note: See TracBrowser for help on using the repository browser.