aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorCa-Phun Ung <pazu2k@gmail.com>2008-10-03 04:08:08 +0000
committerCa-Phun Ung <pazu2k@gmail.com>2008-10-03 04:08:08 +0000
commitc80facd63cd36fcee2a22ec562e75a86c7649db5 (patch)
tree5c3442f8a3997a4711ab252cab4338863cbe5067 /ui
parent898c395227c195b9300e686765e230a21bf18618 (diff)
downloadjquery-ui-c80facd63cd36fcee2a22ec562e75a86c7649db5.tar.gz
jquery-ui-c80facd63cd36fcee2a22ec562e75a86c7649db5.zip
Spinner: further refactored number formatter. 3 lines!
Diffstat (limited to 'ui')
-rw-r--r--ui/ui.spinner.js15
1 files changed, 3 insertions, 12 deletions
diff --git a/ui/ui.spinner.js b/ui/ui.spinner.js
index a99735f15..d0069b177 100644
--- a/ui/ui.spinner.js
+++ b/ui/ui.spinner.js
@@ -399,18 +399,9 @@ $.extend($.ui.spinner, {
return (num !== Math.abs(num) ? '-' : '') + sym + this.number(Math.abs(num), 2);
},
number: function(num, dec) {
- num = isNaN(num) ? 0 : parseFloat(num,10).toFixed(dec);
-
- var regex = /(\d+)(\d{3})/,
- n = num.toString().split('.'),
- n1 = n[0],
- n2 = n.length > 1 ? '.' + n[1] : '';
-
- while (regex.test(n1)) {
- n1 = n1.replace(regex, '$1,$2');
- }
-
- return (n1 + n2);
+ var regex = /(\d+)(\d{3})/;
+ for (num = isNaN(num) ? 0 : parseFloat(num,10).toFixed(dec); regex.test(num); num=num.replace(regex, '$1,$2'));
+ return num;
}
}
});