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){
96 addItem : function(cfg)
98 var item = new Roo.bootstrap.NavProgressItem(cfg);
100 item.parentId = this.id;
101 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
104 var top = new Roo.bootstrap.Element({
106 cls : 'roo-navigation-bar-text'
109 var bottom = new Roo.bootstrap.Element({
111 cls : 'roo-navigation-bar-text'
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);
117 var topText = new Roo.bootstrap.Element({
119 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
122 var bottomText = new Roo.bootstrap.Element({
124 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
127 topText.onRender(top.el, null);
128 bottomText.onRender(bottom.el, null);
131 item.bottomEl = bottom;
134 this.barItems.push(item);
139 getActive : function()
143 Roo.each(this.barItems, function(v){
157 setActiveItem : function(item)
161 Roo.each(this.barItems, function(v){
162 if (v.rid == item.rid) {
172 item.setActive(true);
174 this.fireEvent('changed', this, item, prev);
177 getBarItem: function(rid)
181 Roo.each(this.barItems, function(e) {
193 indexOfItem : function(item)
197 Roo.each(this.barItems, function(v, i){
199 if (v.rid != item.rid) {
210 setActiveNext : function()
212 var i = this.indexOfItem(this.getActive());
214 if (i > this.barItems.length) {
218 this.setActiveItem(this.barItems[i+1]);
221 setActivePrev : function()
223 var i = this.indexOfItem(this.getActive());
229 this.setActiveItem(this.barItems[i-1]);
234 if(!this.barItems.length){
238 var width = 100 / this.barItems.length;
240 Roo.each(this.barItems, function(i){
241 i.el.setStyle('width', width + '%');
242 i.topEl.el.setStyle('width', width + '%');
243 i.bottomEl.el.setStyle('width', width + '%');