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-top-bar'
56 cls : 'roo-navigation-bullets-bar',
60 cls : 'roo-navigation-bar'
67 cls : 'roo-navigation-bottom-bar'
77 initEvents: function()
82 onRender : function(ct, position)
84 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
86 if(this.bullets.length){
87 Roo.each(this.bullets, function(b){
94 addItem : function(cfg)
96 var item = new Roo.bootstrap.NavProgressItem(cfg);
98 item.parentId = this.id;
99 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
102 var top = new Roo.bootstrap.Element({
104 cls : 'roo-navigation-bar-text',
105 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
108 var bottom = new Roo.bootstrap.Element({
110 cls : 'roo-navigation-bar-text',
111 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
114 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
115 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
118 item.bottomEl = bottom;
121 this.barItems.push(item);
126 getActive : function()
130 Roo.each(this.barItems, function(v){
144 setActiveItem : function(item)
148 Roo.each(this.barItems, function(v){
149 if (v.rid == item.rid) {
159 item.setActive(true);
161 this.fireEvent('changed', this, item, prev);
164 getBarItem: function(rid)
168 Roo.each(this.barItems, function(e) {
180 indexOfItem : function(item)
184 Roo.each(this.barItems, function(v, i){
186 if (v.rid != item.rid) {
197 setActiveNext : function()
199 var i = this.indexOfItem(this.getActive());
201 if (i > this.barItems.length) {
205 this.setActiveItem(this.barItems[i+1]);
208 setActivePrev : function()
210 var i = this.indexOfItem(this.getActive());
216 this.setActiveItem(this.barItems[i-1]);
221 if(!this.barItems.length){
225 var width = 100 / this.barItems.length;
227 Roo.each(this.barItems, function(i){
228 i.el.setStyle('width', width + '%');
229 i.topEl.el.setStyle('width', width + '%');
230 i.bottomEl.el.setStyle('width', width + '%');