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