ux/FlipCounter.js
[roojs1] / ux / FlipCounter.js
index feb0e33..405d5b4 100644 (file)
@@ -35,6 +35,8 @@ Roo.extend(Roo.ux.FlipCounter, Roo.bootstrap.Component, {
     
     speed : 0.2,
     startnumber : 0,
+    currentNumber : 0,
+    decimal : 0,
     
     digits : false, // array...
     ulWidth : 0,
@@ -51,24 +53,27 @@ Roo.extend(Roo.ux.FlipCounter, Roo.bootstrap.Component, {
         
     initEvents : function ()
     { 
-        var startNum = ""+ this.startnumber;
+        var startNum = (1.0*this.startnumber).toFixed(this.decimal);
         
         for (i=startNum.length-1; i>=0; i=i-1)
         {
+            if (startNum[i] == '.') {
+                this.addSeparator('.');
+            }
             this.addDigit(startNum[i]);
         }
+        this.currentNumber = this.startnumber;
     },
     
     addDigit : function (num)
     {
         // Add separator after every 3rd digit
-        if (this.digits.length % 3 == 0 && this.digits.length != 0)
+        /*if (this.digits.length % 3 == 0 && this.digits.length != 0)
         {
-            this.addSeparator();
+            this.addSeparator(',');
         }
-        
-         
-        
+        */
+          
         
         var digit = new Roo.ux.FlipCounter.Digit({ manager : this, currentNumber : num });
         digit.manager = this;
@@ -92,20 +97,20 @@ Roo.extend(Roo.ux.FlipCounter, Roo.bootstrap.Component, {
         digit.el.remove();
         
         // Remove separators
-        if (this.digits.length % 3 == 0)
-        {
-            var comma = this.el.select('li.comma:first-child');
-            this.ulWidth = this.ulWidth - comma.getWidth(true);
-            comma.remove();
-        }
+       // if (this.digits.length % 3 == 0)
+      //  {
+          //  var comma = this.el.select('li.comma:first-child');
+          //  this.ulWidth = this.ulWidth - comma.getWidth(true);
+          //  comma.remove();
+        //}
         
         // Update width to current
         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
         
@@ -117,6 +122,7 @@ Roo.extend(Roo.ux.FlipCounter, Roo.bootstrap.Component, {
     {
         var numStr = parseInt(num).toString();
         
+        this.currentNumber = num;
         // Change the number of digits displayed if needed
         if (numStr.length != this.digits.length)
         {