Roo/bootstrap/NavProgressBar.js
[roojs1] / Roo / bootstrap / NavProgressBar.js
1 /*
2  * - LGPL
3  *
4  * nav progress bar
5  * 
6  */
7
8 /**
9  * @class Roo.bootstrap.NavProgressBar
10  * @extends Roo.bootstrap.Component
11  * Bootstrap NavProgressBar class
12  * 
13  * @constructor
14  * Create a new nav progress bar
15  * @param {Object} config The config object
16  */
17
18 Roo.bootstrap.NavProgressBar = function(config){
19     Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
20
21     this.bullets = this.bullets || [];
22    
23 //    Roo.bootstrap.NavProgressBar.register(this);
24      this.addEvents({
25         /**
26              * @event changed
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 
31          */
32         'changed': true
33      });
34     
35 };
36
37 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component,  {
38     
39     bullets : [],
40     barItems : [],
41     
42     
43     getAutoCreate : function()
44     {
45         var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
46         
47         cfg = {
48             tag : 'ul',
49             cls: 'roo-navigation-bar' 
50         }
51         
52         return cfg;
53         
54     },
55     
56     onRender : function(ct, position) 
57     {
58         Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
59         
60         if(this.bullets.length){
61             Roo.each(this.bullets, function(b){
62                this.addItem(b);
63             }, this);
64         }
65         
66     },
67     
68     initEvents: function() 
69     {
70         
71     },
72     
73     addItem : function(cfg)
74     {
75         var item = new Roo.bootstrap.NavProgressItem(cfg);
76         
77         item.parentId = this.id;
78         item.onRender(this.el, null);
79         
80         this.barItems.push(item);
81         
82         this.formatBullets();
83         
84         return item;
85     },
86     
87     formatBullets : function()
88     {
89         Roo.log(this.barItems);
90     }
91 //    
92 //    
93 //    /**
94 //    * sets the active Navigation item
95 //    * @param {Roo.bootstrap.NavProgressItem} the new current navitem
96 //    */
97 //    setActiveItem : function(item)
98 //    {
99 //        var prev = false;
100 //        Roo.each(this.items, function(v){
101 //            if (v == item) {
102 //                return ;
103 //            }
104 //            if (v.isActive()) {
105 //                v.setActive(false, true);
106 //                prev = v;
107 //                
108 //            }
109 //            
110 //        });
111 //
112 //        item.setActive(true, true);
113 //        this.fireEvent('changed', this, item, prev);
114 //    },
115 //    
116 //    /**
117 //    * gets the active Navigation item
118 //    * @return {Roo.bootstrap.NavProgressItem} the current navitem
119 //    */
120 //    getActive : function()
121 //    {
122 //        var active = false;
123 //        
124 //        Roo.each(this.items, function(v){
125 //            
126 //            if (!v.isActive()) {
127 //                return;
128 //            }
129 //            
130 //            active = v;
131 //            return false;
132 //            
133 //        });
134 //        
135 //        return active;
136 //    },
137 //    
138 //    indexOfNav : function(item)
139 //    {
140 //        var index = false;
141 //        
142 //        Roo.each(this.items, function(v,i){
143 //            
144 //            if (v != item) {
145 //                return;
146 //            }
147 //            
148 //            index = i;
149 //            return false
150 //        });
151 //        
152 //        return index;
153 //    },
154 //    
155     /**
156     * adds a Navigation item
157     * @param {Roo.bootstrap.NavProgressItem} the NavProgressItem to add
158     */
159     
160 //    
161 //    /**
162 //    * register a Navigation item
163 //    * @param {Roo.bootstrap.NavItem} the navitem to add
164 //    */
165 //    register : function(item)
166 //    {
167 //        this.items.push(item);
168 //        item.navId = this.navId;
169 //    
170 //    },
171 //    
172 //    /**
173 //    * clear all the Navigation item
174 //    */
175 //   
176 //    clearAll : function()
177 //    {
178 //        this.items = [];
179 //        this.el.dom.innerHTML = '';
180 //    },
181 //    
182 //    getNavItem: function(tabId)
183 //    {
184 //        var ret = false;
185 //        Roo.each(this.items, function(e) {
186 //            if (e.tabId == tabId) {
187 //               ret =  e;
188 //               return false;
189 //            }
190 //            return true;
191 //            
192 //        });
193 //        return ret;
194 //    },
195 //    
196 //    setActiveNext : function()
197 //    {
198 //        var i = this.indexOfNav(this.getActive());
199 //        
200 //        if (i > this.items.length) {
201 //            return;
202 //        }
203 //        
204 //        this.setActiveItem(this.items[i+1]);
205 //    },
206 //    
207 //    setActivePrev : function()
208 //    {
209 //        var i = this.indexOfNav(this.getActive());
210 //        
211 //        if (i  < 1) {
212 //            return;
213 //        }
214 //        
215 //        this.setActiveItem(this.items[i-1]);
216 //    },
217 //    
218 //    clearWasActive : function(except) {
219 //        Roo.each(this.items, function(e) {
220 //            if (e.tabId != except.tabId && e.was_active) {
221 //               e.was_active = false;
222 //               return false;
223 //            }
224 //            return true;
225 //            
226 //        });
227 //    },
228 //    
229 //    getWasActive : function ()
230 //    {
231 //        var r = false;
232 //        Roo.each(this.items, function(e) {
233 //            if (e.was_active) {
234 //               r = e;
235 //               return false;
236 //            }
237 //            return true;
238 //            
239 //        });
240 //        return r;
241 //    }
242     
243     
244 });
245
246 // 
247 //Roo.apply(Roo.bootstrap.NavProgressBar, {
248 //    
249 //    groups: {},
250 //     /**
251 //    * register a Navigation Group
252 //    * @param {Roo.bootstrap.NavGroup} the navgroup to add
253 //    */
254 //    register : function(bar)
255 //    {
256 //        this.groups[bar.navId] = bar;
257 //      
258 //    },
259 //    /**
260 //    * fetch a Navigation Bar based on the navigation ID
261 //    * @param {string} the nav bar to add
262 //    * @returns {Roo.bootstrap.NavProgressBar} the nav bar
263 //    */
264 //    get: function(navId) 
265 //    {
266 //        if (typeof(this.groups[navId]) == 'undefined') {
267 //            return false;
268 //        }
269 //        
270 //        return this.groups[navId] ;
271 //    }
272 //    
273 //});
274
275