speed : 0.2,
startnumber : 0,
currentNumber : 0,
+ decimal : 0,
digits : false, // array...
ulWidth : 0,
initEvents : function ()
{
- var startNum = ""+ this.startnumber;
+
+
+ var startNum = (1.0*this.startnumber).toFixed(this.decimal);
+ //Roo.log("STARTNUmber: " + startNum);
for (i=startNum.length-1; i>=0; i=i-1)
{
+ if (startNum[i] == '.') {
+ this.addSeparator('.');
+ continue;
+ }
this.addDigit(startNum[i]);
}
this.currentNumber = this.startnumber;
addDigit : function (num)
{
+
+ //Roo.log("Add digit "+ num);
// Add separator after every 3rd digit
- if (this.digits.length % 3 == 0 && this.digits.length != 0)
- {
- this.addSeparator();
+ if (this.decimal == 0 && this.digits.length % 3 == 0 && this.digits.length != 0) {
+ this.addSeparator(',');
}
digit.el.remove();
// Remove separators
- if (this.digits.length % 3 == 0)
+ if (this.decimal == 0 & this.digits.length % 3 == 0)
{
var comma = this.el.select('li.comma:first-child');
this.ulWidth = this.ulWidth - comma.getWidth(true);
this.el.set( { 'min-width' : this.ulWidth});
},
- addSeparator : function (num)
+ addSeparator : function (str)
{
- var comma = this.el.insertHtml('afterBegin','<li class="comma">,</li>',true);
+ var comma = this.el.insertHtml('afterBegin','<li class="comma">'+str+'</li>',true);
// Update width
updateTo : function (num)
{
- var numStr = parseInt(num).toString();
+ var numStr = (1.0*num).toFixed(this.decimal);
this.currentNumber = num;
+
+ var dl = this.digits.length + (this.decimal > 0 ? 1 : 0);
// Change the number of digits displayed if needed
- if (numStr.length != this.digits.length)
+ if (numStr.length != dl)
{
- var diff = numStr.length - this.digits.length;
+ var diff = numStr.length - dl;
+ //Roo.log("DIFF LEN=" +diff);
if (diff > 0)
{
for (i=0; i<diff; i=i+1) {
}
// Change all digit values
- for (i=0; i<numStr.length; i=i+1)
+
+ for (i=0, n=0; i<numStr.length; i=i+1)
{
- this.digits[i].flipTo(numStr[numStr.length - 1 - i]);
+ if (numStr[numStr.length - 1 - i] == '.') {
+ continue;
+ }
+ //Roo.log("UPDATE DIGIT=" + i + " to " + numStr[numStr.length - 1 - i]);
+ this.digits[n++].flipTo(numStr[numStr.length - 1 - i]);
}
}
getAutoCreate : function(){
+ //Roo.log("render with cn=" + this.currentNumber);
return {
tag: 'li',
cn : [
{
cls : 'flipper_top flipper_top2 flipper_top_back',
cn : [
- { tag: 'span', html: this.currentNumber },
+ { tag: 'span', html: ""+this.currentNumber },
{ cls : 'rings' }
]
{
cls : 'flipper_top flipper_top_front',
cn : [
- { tag: 'span', html: this.currentNumber },
+ { tag: 'span', html: ""+this.currentNumber },
{ cls : 'rings' }
]
{
cls : 'flipper_bottom flipper_bottom1 flipper_bottom_back',
cn : [
- { tag: 'span', html: this.currentNumber },
+ { tag: 'span', html: ""+this.currentNumber },
{ cls : 'rings' }
]
},
{
cls : 'flipper_bottom flipper_bottom_front',
cn : [
- { tag: 'span', html: this.currentNumber },
+ { tag: 'span', html: ""+this.currentNumber },
{ cls : 'rings' }
]
},