Roo/bootstrap/NavProgressItem.js
[roojs1] / Roo / bootstrap / NavProgressItem.js
1 /*
2  * - LGPL
3  *
4  * Nav Progress Item
5  * 
6  */
7
8 /**
9  * @class Roo.bootstrap.NavProgressItem
10  * @extends Roo.bootstrap.Component
11  * Bootstrap NavProgressItem class
12  * @cfg {Boolean} active (true|false) Is item active default false
13  * @cfg {Boolean} disabled (true|false) Is item active default false
14  * @cfg {String} html
15  * 
16  * @constructor
17  * Create a new NavProgressItem
18  * @param {Object} config The config object
19  */
20 Roo.bootstrap.NavProgressItem = function(config){
21     Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
22     this.addEvents({
23         // raw events
24         /**
25          * @event click
26          * The raw click event for the entire grid.
27          * @param {Roo.bootstrap.NavProgressItem} this
28          * @param {Roo.EventObject} e
29          */
30         "click" : true,
31          /**
32             * @event changed
33             * Fires when the active item active state changes
34             * @param {Roo.bootstrap.NavProgressItem} this
35             * @param {boolean} state the new state
36              
37          */
38         'changed': true
39     });
40    
41 };
42
43 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component,  {
44     
45     active : false,
46     disabled : false,
47     html : '',
48     
49     getAutoCreate : function()
50     {
51          
52         var cfg = {
53             tag: 'li',
54             cls: 'roo-navigation-bar-item',
55             cn : [
56                 {
57                     tag : 'span',
58                     cls : 'roo-navigation-bar-item-text',
59                     html : this.html
60                 }
61             ]
62         }
63         
64         if (this.active) {
65             cfg.cls += ' active';
66         }
67         if (this.disabled) {
68             cfg.cls += ' disabled';
69         }
70         
71         return cfg;
72     },
73     
74     initEvents: function() 
75     {
76         Roo.log('bar item init???');
77     }
78 //    
79 //    onClick : function(e)
80 //    {
81 //        if(
82 //                this.preventDefault || 
83 //                this.href == '#' 
84 //        ){
85 //            
86 //            e.preventDefault();
87 //        }
88 //        
89 //        if (this.disabled) {
90 //            return;
91 //        }
92 //        
93 //        var tg = Roo.bootstrap.TabGroup.get(this.navId);
94 //        if (tg && tg.transition) {
95 //            Roo.log("waiting for the transitionend");
96 //            return;
97 //        }
98 //        
99 //        
100 //        
101 //        //Roo.log("fire event clicked");
102 //        if(this.fireEvent('click', this, e) === false){
103 //            return;
104 //        };
105 //        
106 //        if(this.tagtype == 'span'){
107 //            return;
108 //        }
109 //        
110 //        //Roo.log(this.href);
111 //        var ael = this.el.select('a',true).first();
112 //        //Roo.log(ael);
113 //        
114 //        if(ael && this.animateRef && this.href.indexOf('#') > -1){
115 //            //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
116 //            if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
117 //                return; // ignore... - it's a 'hash' to another page.
118 //            }
119 //            
120 //            e.preventDefault();
121 //            this.scrollToElement(e);
122 //        }
123 //        
124 //        
125 //        var p =  this.parent();
126 //   
127 //        if (['tabs','pills'].indexOf(p.type)!==-1) {
128 //            if (typeof(p.setActiveItem) !== 'undefined') {
129 //                p.setActiveItem(this);
130 //            }
131 //        }
132 //        
133 //        // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
134 //        if (p.parentType == 'NavHeaderbar' && !this.menu) {
135 //            // remove the collapsed menu expand...
136 //            p.parent().el.select('.navbar-collapse',true).removeClass('in');  
137 //        }
138 //    },
139 //    
140 //    isActive: function () {
141 //        return this.active
142 //    },
143 //    setActive : function(state, fire, is_was_active)
144 //    {
145 //        if (this.active && !state && this.navId) {
146 //            this.was_active = true;
147 //            var nv = Roo.bootstrap.NavGroup.get(this.navId);
148 //            if (nv) {
149 //                nv.clearWasActive(this);
150 //            }
151 //            
152 //        }
153 //        this.active = state;
154 //        
155 //        if (!state ) {
156 //            this.el.removeClass('active');
157 //        } else if (!this.el.hasClass('active')) {
158 //            this.el.addClass('active');
159 //        }
160 //        if (fire) {
161 //            this.fireEvent('changed', this, state);
162 //        }
163 //        
164 //        // show a panel if it's registered and related..
165 //        
166 //        if (!this.navId || !this.tabId || !state || is_was_active) {
167 //            return;
168 //        }
169 //        
170 //        var tg = Roo.bootstrap.TabGroup.get(this.navId);
171 //        if (!tg) {
172 //            return;
173 //        }
174 //        var pan = tg.getPanelByName(this.tabId);
175 //        if (!pan) {
176 //            return;
177 //        }
178 //        // if we can not flip to new panel - go back to old nav highlight..
179 //        if (false == tg.showPanel(pan)) {
180 //            var nv = Roo.bootstrap.NavGroup.get(this.navId);
181 //            if (nv) {
182 //                var onav = nv.getWasActive();
183 //                if (onav) {
184 //                    onav.setActive(true, false, true);
185 //                }
186 //            }
187 //            
188 //        }
189 //        
190 //        
191 //      
192 //    },
193 //     // this should not be here...
194 //    setDisabled : function(state)
195 //    {
196 //        this.disabled = state;
197 //        if (!state ) {
198 //            this.el.removeClass('disabled');
199 //        } else if (!this.el.hasClass('disabled')) {
200 //            this.el.addClass('disabled');
201 //        }
202 //        
203 //    },
204 //    
205 //    /**
206 //     * Fetch the element to display the tooltip on.
207 //     * @return {Roo.Element} defaults to this.el
208 //     */
209 //    tooltipEl : function()
210 //    {
211 //        return this.el.select('' + this.tagtype + '', true).first();
212 //    },
213 //    
214 //    scrollToElement : function(e)
215 //    {
216 //        var c = document.body;
217 //        
218 //        /*
219 //         * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
220 //         */
221 //        if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
222 //            c = document.documentElement;
223 //        }
224 //        
225 //        var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
226 //        
227 //        if(!target){
228 //            return;
229 //        }
230 //
231 //        var o = target.calcOffsetsTo(c);
232 //        
233 //        var options = {
234 //            target : target,
235 //            value : o[1]
236 //        }
237 //        
238 //        this.fireEvent('scrollto', this, options, e);
239 //        
240 //        Roo.get(c).scrollTo('top', options.value, true);
241 //        
242 //        return;
243 //    }
244 });
245  
246
247