ux/FlipCounter.js
[roojs1] / ux / FlipCounter.js
index 3de3389..d450ccb 100644 (file)
@@ -10,19 +10,20 @@ Roo.ux.FlipCounter = function(options)
         /**
          * @event flip
          * When a box is flipped
-         * @param {Roo.ux.FlipCounter} pane
+         * @param {Roo.ux.FlipCounter} counter
          */
         "flip" : true,
         /**
-         * @event activatepane
-         * When a pane is activated
-         * @param {Roo.bootstrap.dash.TabPane} pane
+         * @event resize
+         * When a box is resized
+         * @param {Roo.ux.FlipCounter} counter
          */
         "resize" : true
         
          
     });
-     
+    this.digits = new Array();
+       
     //this.init();
 
 
@@ -31,52 +32,39 @@ Roo.ux.FlipCounter = function(options)
 Roo.extend(Roo.ux.FlipCounter, Roo.bootstrap.Component, {
     
     speed : 0.2,
+    startnumber : 0,
     
+    digits : false, // array...
     
-
-;(function ( $, window, document, undefined ) {
     
-    // Create the defaults once
-    var pluginName = 'flipCounter',
-        defaults = {
-            speed: 0.2,
-            onFlip: function() {},
-            onResize: function() {}
+    getAutoCreate : function(){
+        
+        return {
+            tag: 'ul',
+            cls: 'flipcounter',
+            
         };
-
-    // Constructor
-    function FlipCounter( element, options ) {
-        this.el = $(element);
-        this.options = $.extend({}, defaults, options);
-        this._defaults = defaults;
-        this._name = pluginName;
-        this.init();
-    }
-
-    FlipCounter.prototype.init = function () {
-        var elem = this.el;
-        var startNum = elem.html();
-        if (startNum === "") startNum = "0";
-        elem.html('<ul class="flipcounter"></ul>');
+    },
         
-        this.ul = elem.children('ul');
+    init : function ()
+    { 
+        var startNum = ""+ this.startnumber;
         this.ulWidth = 0;
-        this.digits = new Array();
         
         for (i=startNum.length-1; i>=0; i=i-1)
         {
             this.addDigit(startNum[i]);
         }
-    };
+    },
     
-    FlipCounter.prototype.addDigit = function (num) {
+    addDigit : function (num) {
         // Add separator after every 3rd digit
         if (this.digits.length % 3 == 0 && this.digits.length != 0)
         {
             this.addSeparator();
         }
         
-        this.ul.prepend('<li>\
+        this.el.insertHtml('afterBegin', '<li>\
             <div class="numberwrap">\
                 <div class="flipper_top flipper_top1"></div>\
                 <div class="flipper_top flipper_top2 flipper_top_back">\
@@ -101,8 +89,8 @@ Roo.extend(Roo.ux.FlipCounter, Roo.bootstrap.Component, {
             </div>\
         </li>');
         
-        var li = this.ul.find('li:first-child');
-        var digit = new Digit(li, num);
+        var li = this.el.select('li'.true).first();
+        var digit = new Roo.ux.FlipCounter.Digit(li, num);
         digit.manager = this;
         this.digits.push(digit);