aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCa-Phun Ung <pazu2k@gmail.com>2008-08-19 17:03:59 +0000
committerCa-Phun Ung <pazu2k@gmail.com>2008-08-19 17:03:59 +0000
commit68f18e1c2dcfdc1386420e3335af7f99e7f2d205 (patch)
treef4a9d4381bc82cd16a0f6657ec6b9733fc39b10c
parentc0147da718694cb5b571d2b2c4c206a1cd26012f (diff)
downloadjquery-ui-68f18e1c2dcfdc1386420e3335af7f99e7f2d205.tar.gz
jquery-ui-68f18e1c2dcfdc1386420e3335af7f99e7f2d205.zip
spinner: fixed rounding error when stepping=0.3
-rw-r--r--ui/ui.spinner.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/ui/ui.spinner.js b/ui/ui.spinner.js
index 1c39a4923..7ab42b9cd 100644
--- a/ui/ui.spinner.js
+++ b/ui/ui.spinner.js
@@ -16,7 +16,7 @@ $.widget('ui.spinner', {
_init: function() {
// check for decimals in steppinng and set _decimals as internal (needs cleaning up)
- var decimals = 0;
+ this._decimals = 0;
if (this.options.stepping.toString().indexOf('.') != -1) {
var s = this.options.stepping.toString();
this._decimals = s.slice(s.indexOf('.')+1, s.length).length;
@@ -267,11 +267,12 @@ $.extend($.ui.spinner, {
return (num !== Math.abs(num) ? '-' : '') + sym + this.round(Math.abs(num), 2);
},
round: function(num, dec) {
+ var s = Math.round(parseFloat(num)*Math.pow(10, dec)) / Math.pow(10, dec); // round off weird decimals
if (dec > 0) {
- var s = num + ((num.toString().indexOf('.') == -1) ? '.' : '') + '0000000001';
+ s = s + ((s.toString().indexOf('.') == -1) ? '.' : '') + '0000000001';
s = s.substr(0, s.indexOf('.')+1+dec);
} else {
- var s = Math.round(num);
+ var s = Math.round(s);
}
return s;
}