123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- /*
- * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
- *
- * http://extjs.com/license
- */
- /**
- * @class Ext.data.SortTypes
- * @singleton Defines the default sorting (casting?) comparison functions used
- * when sorting data.
- */
- Ext.data.SortTypes = {
- /**
- * Default sort that does nothing
- *
- * @param {Mixed}
- * s The value being converted
- * @return {Mixed} The comparison value
- */
- none : function(s) {
- return s;
- },
- /**
- * The regular expression used to strip tags
- *
- * @type {RegExp}
- * @property
- */
- stripTagsRE : /<\/?[^>]+>/gi,
- /**
- * Strips all HTML tags to sort on text only
- *
- * @param {Mixed}
- * s The value being converted
- * @return {String} The comparison value
- */
- asText : function(s) {
- return String(s).replace(this.stripTagsRE, "");
- },
- /**
- * Strips all HTML tags to sort on text only - Case insensitive
- *
- * @param {Mixed}
- * s The value being converted
- * @return {String} The comparison value
- */
- asUCText : function(s) {
- return String(s).toUpperCase().replace(this.stripTagsRE, "");
- },
- /**
- * Case insensitive string
- *
- * @param {Mixed}
- * s The value being converted
- * @return {String} The comparison value
- */
- asUCString : function(s) {
- return String(s).toUpperCase();
- },
- /**
- * Date sorting
- *
- * @param {Mixed}
- * s The value being converted
- * @return {Number} The comparison value
- */
- asDate : function(s) {
- if (!s) {
- return 0;
- }
- if (s instanceof Date) {
- return s.getTime();
- }
- return Date.parse(String(s));
- },
- /**
- * Float sorting
- *
- * @param {Mixed}
- * s The value being converted
- * @return {Float} The comparison value
- */
- asFloat : function(s) {
- var val = parseFloat(String(s).replace(/,/g, ""));
- if (isNaN(val))
- val = 0;
- return val;
- },
- /**
- * Integer sorting
- *
- * @param {Mixed}
- * s The value being converted
- * @return {Number} The comparison value
- */
- asInt : function(s) {
- var val = parseInt(String(s).replace(/,/g, ""));
- if (isNaN(val))
- val = 0;
- return val;
- }
- };
|