updated digit & currency parsers, added missing sortBegin - found via unit testing

This commit is contained in:
Mottie 2013-05-08 08:06:02 -05:00
parent 075635c097
commit 64428b68e3

View File

@ -255,7 +255,7 @@
v = parsers[j].format(t, table, c[0].cells[j], j);
cols.push(v);
if ((parsers[j].type || '').toLowerCase() === "numeric") {
colMax[j] = Math.max(Math.abs(v), colMax[j] || 0); // determine column max value (ignore sign)
colMax[j] = Math.max(Math.abs(v) || 0, colMax[j] || 0); // determine column max value (ignore sign)
}
}
cols.push(tc.cache[k].normalized.length); // add position for rowCache
@ -690,7 +690,7 @@
.bind('selectstart', false)
.css({
'user-select': 'none',
'MozUserSelect': 'none'
'MozUserSelect': 'none' // not needed for jQuery 1.8+
});
}
// apply easy methods that trigger bound events
@ -769,6 +769,7 @@
updateHeaderSortCount(table, list);
// set css for headers
setHeadersCss(table);
$this.trigger("sortBegin", this);
// sort the table and append it to the dom
multisort(table);
appendToTable(table, init);
@ -1293,7 +1294,8 @@
return ts.isDigit(s);
},
format: function(s, table) {
return s ? ts.formatFloat(s.replace(/[^\w,. \-()]/g, ""), table) : s;
var n = ts.formatFloat((s || '').replace(/[^\w,. \-()]/g, ""), table);
return s && typeof n === 'number' ? n : s ? $.trim( s && table.config.ignoreCase ? s.toLocaleLowerCase() : s ) : s;
},
type: "numeric"
});
@ -1304,7 +1306,8 @@
return (/^\(?\d+[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]|[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]\d+\)?$/).test((s || '').replace(/[,. ]/g,'')); // £$€¤¥¢
},
format: function(s, table) {
return s ? ts.formatFloat(s.replace(/[^\w,. \-()]/g, ""), table) : s;
var n = ts.formatFloat((s || '').replace(/[^\w,. \-()]/g, ""), table);
return s && typeof n === 'number' ? n : s ? $.trim( s && table.config.ignoreCase ? s.toLocaleLowerCase() : s ) : s;
},
type: "numeric"
});