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()
79 this.topEl = this.el.select('.roo-navigation-bar-top', true).first();
80 this.iconEl = this.el.select('.roo-navigation-bar', true).first();
81 this.bottomEl = this.el.select('.roo-navigation-bar-bottom', true).first();
85 onRender : function(ct, position)
87 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
89 if(this.bullets.length){
90 Roo.each(this.bullets, function(b){
97 addItem : function(cfg)
99 var item = new Roo.bootstrap.NavProgressItem(cfg);
101 item.parentId = this.id;
102 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
105 var html = new Roo.bootstrap.Element({
107 cls : 'roo-navigation-bar-text',
111 var pos = (['top', 'bottom'].indexOf(cfg.position) !== -1) ? cfg.position : 'bottom';
113 html.onRender(this.el.select('.roo-navigation-bar-' + pos, true).first(), null);
116 this.barItems.push(item);
118 this.formatBullets();
123 getActive : function()
127 Roo.each(this.barItems, function(v){
141 setActiveItem : function(item)
145 Roo.each(this.barItems, function(v){
146 if (v.rid == item.rid) {
156 item.setActive(true);
158 this.fireEvent('changed', this, item, prev);
161 getBarItem: function(rid)
165 Roo.each(this.barItems, function(e) {
177 indexOfItem : function(item)
181 Roo.each(this.barItems, function(v, i){
183 if (v.rid != item.rid) {
194 setActiveNext : function()
196 var i = this.indexOfItem(this.getActive());
198 if (i > this.barItems.length) {
202 this.setActiveItem(this.barItems[i+1]);
205 setActivePrev : function()
207 var i = this.indexOfItem(this.getActive());
213 this.setActiveItem(this.barItems[i-1]);
216 formatBullets : function()
218 if(!this.barItems.length){
222 var width = 100 / this.barItems.length;
224 Roo.each(this.topEl.select('.roo-navigation-bar-text', true).elements, function(el){
225 el.setStyle('width', width + '%');
228 Roo.each(this.bottomEl.select('.roo-navigation-bar-text', true).elements, function(el){
229 el.setStyle('width', width + '%');
232 Roo.each(this.iconEl.select('.roo-navigation-bar-item', true).elements, function(el){
233 el.setStyle('width', width + '%');