Roo/bootstrap/TabGroup.js
authorAlan Knowles <alan@roojs.com>
Tue, 19 Apr 2016 08:59:49 +0000 (16:59 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 19 Apr 2016 08:59:49 +0000 (16:59 +0800)
Roo/bootstrap/TabGroup.js

index acadcdd..e30e0e7 100644 (file)
@@ -11,7 +11,7 @@
  * Bootstrap Column class
  * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
  * @cfg {Boolean} carousel true to make the group behave like a carousel
- * @cfg {Number} bullets show the panel pointer.. default 0
+ * @cfg {Boolean} bullets show bullets for the panels
  * @cfg {Boolean} autoslide (true|false) auto slide .. default false
  * @cfg {Boolean} slideOnTouch (true|false) slide on touch .. default false
  * @cfg {Number} timer auto slide timer .. default 0 millisecond
@@ -56,23 +56,23 @@ Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column,  {
                cls : 'carousel-inner'
             }];
         
-            if(this.bullets > 0 && !Roo.isTouch){
+            if(this.bullets  && !Roo.isTouch){
                 
                 var bullets = {
                     cls : 'carousel-bullets',
                     cn : []
                 };
-                
+               
                 if(this.bullets_cls){
                     bullets.cls = bullets.cls + ' ' + this.bullets_cls;
                 }
-                
+                 /*
                 for (var i = 0; i < this.bullets; i++){
                     bullets.cn.push({
                         cls : 'bullet bullet-' + i
                     });
                 }
-                
+                */
                 bullets.cn.push({
                     cls : 'clear'
                 });
@@ -88,9 +88,7 @@ Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column,  {
     {
         Roo.log('-------- init events on tab group ---------');
         
-        if(this.bullets > 0 && !Roo.isTouch){
-            this.initBullet();
-        }
+        
         
         Roo.log(this);
         
@@ -130,6 +128,7 @@ Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column,  {
     {
         this.tabs.push( item);
         item.navId = this.navId; // not really needed..
+        this.addBullet();
     
     },
     
@@ -264,38 +263,36 @@ Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column,  {
         this.showPanel(this.tabs[i-1]);
     },
     
-    initBullet : function()
+    
+    addBullet: function()
     {
-        if(Roo.isTouch){
+        if(!this.bullets || Roo.isTouch){
             return;
         }
+        var ctr = this.el.select('.carousel-bullets',true).first();
+        var i = this.el.select('.carousel-bullets .bullet',true).length + 1;
+        var bullet = ctr.createChild({
+            cls : 'bullet bullet-' + i
+        },ctr.dom.lastChild);
         
-        var _this = this;
-        
-        for (var i = 0; i < this.bullets; i++){
-            var bullet = this.el.select('.bullet-' + i, true).first();
+        bullet.on('click', (function(e, el, o, ii, t){
 
-            if(!bullet){
-                continue;
-            }
-
-            bullet.on('click', (function(e, el, o, ii, t){
-
-                e.preventDefault();
+            e.preventDefault();
 
-                _this.showPanel(ii);
+            _this.showPanel(ii);
 
-                if(_this.autoslide && _this.slideFn){
-                    clearInterval(_this.slideFn);
-                    _this.slideFn = window.setInterval(function() {
-                        _this.showPanelNext();
-                    }, _this.timer);
-                }
+            if(_this.autoslide && _this.slideFn){
+                clearInterval(_this.slideFn);
+                _this.slideFn = window.setInterval(function() {
+                    _this.showPanelNext();
+                }, _this.timer);
+            }
 
-            }).createDelegate(this, [i, bullet], true));
-        }
+        }).createDelegate(this, [i, bullet], true));
+                
+        
     },
-    
+     
     setActiveBullet : function(i)
     {
         if(Roo.isTouch){