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