sync
[roojs1] / Roo / bootstrap / NavProgressBar.js
index e923796..edd8d43 100644 (file)
@@ -11,7 +11,7 @@
  * Bootstrap NavProgressBar class
  * 
  * @constructor
- * Create a new nav progress bar
+ * Create a new nav progress bar - a bar indicating step along a process
  * @param {Object} config The config object
  */
 
@@ -35,7 +35,10 @@ Roo.bootstrap.NavProgressBar = function(config){
 };
 
 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component,  {
-    
+    /**
+     * @cfg {Roo.bootstrap.NavProgressItem} NavProgressBar:bullets[]
+     * Bullets for the Nav Progress bar for the toolbar
+     */
     bullets : [],
     barItems : [],
     
@@ -49,15 +52,22 @@ Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component,  {
             cn : [
                 {
                     tag : 'div',
-                    cls : 'roo-navigation-bar-top'
+                    cls : 'roo-navigation-top-bar'
                 },
                 {
-                    tag : 'ul',
-                    cls : 'roo-navigation-bar'
+                    tag : 'div',
+                    cls : 'roo-navigation-bullets-bar',
+                    cn : [
+                        {
+                            tag : 'ul',
+                            cls : 'roo-navigation-bar'
+                        }
+                    ]
                 },
+                
                 {
                     tag : 'div',
-                    cls : 'roo-navigation-bar-bottom'
+                    cls : 'roo-navigation-bottom-bar'
                 }
             ]
             
@@ -69,9 +79,6 @@ Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component,  {
     
     initEvents: function() 
     {
-        this.topEl = this.el.select('.roo-navigation-bar-top', true).first();
-        this.iconEl = this.el.select('.roo-navigation-bar', true).first();
-        this.bottomEl = this.el.select('.roo-navigation-bar-bottom', true).first();
         
     },
     
@@ -85,6 +92,8 @@ Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component,  {
             }, this);
         }
         
+        this.format();
+        
     },
     
     addItem : function(cfg)
@@ -95,28 +104,38 @@ Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component,  {
         item.render(this.el.select('.roo-navigation-bar', true).first(), null);
         
         if(cfg.html){
-            var html = new Roo.bootstrap.Element({
+            var top = new Roo.bootstrap.Element({
+                tag : 'div',
+                cls : 'roo-navigation-bar-text'
+            });
+            
+            var bottom = new Roo.bootstrap.Element({
                 tag : 'div',
-                cls : 'roo-navigation-bar-text',
-                html : cfg.html
+                cls : 'roo-navigation-bar-text'
             });
             
-            var pos = (typeof(cfg.position) != 'undefined' && ['top', 'bottom'].indexOf(cfg.position) == -1) ? cfg.position : 'bottom';
-            Roo.log(cfg);
-            Roo.log(['top', 'bottom'].indexOf(cfg.position));
-            Roo.log(pos);
+            top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
+            bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
             
-            Roo.log('.roo-navigation-bar-' + pos);
+            var topText = new Roo.bootstrap.Element({
+                tag : 'span',
+                html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
+            });
+            
+            var bottomText = new Roo.bootstrap.Element({
+                tag : 'span',
+                html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
+            });
             
-            Roo.log(this.el.select('.roo-navigation-bar-' + pos, true).first());
+            topText.onRender(top.el, null);
+            bottomText.onRender(bottom.el, null);
             
-            html.onRender(this.el.select('.roo-navigation-bar-' + pos, true).first(), null);
+            item.topEl = top;
+            item.bottomEl = bottom;
         }
         
         this.barItems.push(item);
         
-        this.formatBullets();
-        
         return item;
     },
     
@@ -213,17 +232,20 @@ Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component,  {
         this.setActiveItem(this.barItems[i-1]);
     },
     
-    formatBullets : function()
+    format : function()
     {
         if(!this.barItems.length){
             return;
         }
-        
+     
         var width = 100 / this.barItems.length;
         
         Roo.each(this.barItems, function(i){
             i.el.setStyle('width', width + '%');
+            i.topEl.el.setStyle('width', width + '%');
+            i.bottomEl.el.setStyle('width', width + '%');
         }, this);
+        
     }
     
 });