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-bottom'
70 initEvents: function()
72 this.topEl = this.el.select('.roo-navigation-bar-top', true).first();
73 this.iconEl = this.el.select('.roo-navigation-bar', true).first();
74 this.bottomEl = this.el.select('.roo-navigation-bar-bottom', true).first();
78 onRender : function(ct, position)
80 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
82 if(this.bullets.length){
83 Roo.each(this.bullets, function(b){
90 addItem : function(cfg)
92 var item = new Roo.bootstrap.NavProgressItem(cfg);
94 item.parentId = this.id;
95 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
98 var html = new Roo.bootstrap.Element({
100 cls : 'roo-navigation-bar-text',
104 var pos = (['top', 'bottom'].indexOf(cfg.position) == -1) ? cfg.position : 'bottom';
106 html.onRender(this.el.select('.roo-navigation-bar-' + pos, true).first(), null);
109 this.barItems.push(item);
111 this.formatBullets();
116 getActive : function()
120 Roo.each(this.barItems, function(v){
134 setActiveItem : function(item)
138 Roo.each(this.barItems, function(v){
139 if (v.rid == item.rid) {
149 item.setActive(true);
151 this.fireEvent('changed', this, item, prev);
154 getBarItem: function(rid)
158 Roo.each(this.barItems, function(e) {
170 indexOfItem : function(item)
174 Roo.each(this.barItems, function(v, i){
176 if (v.rid != item.rid) {
187 setActiveNext : function()
189 var i = this.indexOfItem(this.getActive());
191 if (i > this.barItems.length) {
195 this.setActiveItem(this.barItems[i+1]);
198 setActivePrev : function()
200 var i = this.indexOfItem(this.getActive());
206 this.setActiveItem(this.barItems[i-1]);
209 formatBullets : function()
211 if(!this.barItems.length){
215 var width = 100 / this.barItems.length;
217 Roo.each(this.barItems, function(i){
218 i.el.setStyle('width', width + '%');