9 * @class Roo.bootstrap.NavProgressBar
10 * @extends Roo.bootstrap.Component
11 * Bootstrap NavProgressBar class
14 * Create a new nav progress bar
15 * @param {Object} config The config object
18 Roo.bootstrap.NavProgressBar = function(config){
19 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
21 this.bullets = this.bullets || [];
23 // Roo.bootstrap.NavProgressBar.register(this);
27 * Fires when the active item changes
28 * @param {Roo.bootstrap.NavProgressBar} this
29 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
30 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
37 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
42 getAutoCreate : function()
44 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
48 cls : 'roo-navigation-bar-group',
52 cls : 'roo-navigation-bar-top'
56 cls : 'roo-navigation-bar',
60 cls : 'roo-navigation-bar-list'
67 cls : 'roo-navigation-bar-bottom'
77 initEvents: function()
81 Roo.log(this.bullets);
82 Roo.log('run init???');
85 onRender : function(ct, position)
88 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
90 if(this.bullets.length){
91 Roo.each(this.bullets, function(b){
98 addItem : function(cfg)
100 var item = new Roo.bootstrap.NavProgressItem(cfg);
102 item.parentId = this.id;
103 item.render(this.el.select('.roo-navigation-bar-list', true).first(), null);
106 var top = new Roo.bootstrap.Element({
108 cls : 'roo-navigation-bar-text',
109 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
112 var bottom = new Roo.bootstrap.Element({
114 cls : 'roo-navigation-bar-text',
115 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
118 top.onRender(this.el.select('.roo-navigation-bar-top', true).first(), null);
119 bottom.onRender(this.el.select('.roo-navigation-bar-bottom', true).first(), null);
122 item.bottomEl = bottom;
125 this.barItems.push(item);
130 getActive : function()
134 Roo.each(this.barItems, function(v){
148 setActiveItem : function(item)
152 Roo.each(this.barItems, function(v){
153 if (v.rid == item.rid) {
163 item.setActive(true);
165 this.fireEvent('changed', this, item, prev);
168 getBarItem: function(rid)
172 Roo.each(this.barItems, function(e) {
184 indexOfItem : function(item)
188 Roo.each(this.barItems, function(v, i){
190 if (v.rid != item.rid) {
201 setActiveNext : function()
203 var i = this.indexOfItem(this.getActive());
205 if (i > this.barItems.length) {
209 this.setActiveItem(this.barItems[i+1]);
212 setActivePrev : function()
214 var i = this.indexOfItem(this.getActive());
220 this.setActiveItem(this.barItems[i-1]);
225 if(!this.barItems.length){
229 var width = 100 / this.barItems.length;
231 Roo.each(this.barItems, function(i){
232 i.el.setStyle('width', width + '%');
233 i.topEl.el.setStyle('width', width + '%');
234 i.bottomEl.el.setStyle('width', width + '%');