8ef30ab55b63eea6237bec0b85e8c6e60b20531a
[roojs1] / Roo / bootstrap / breadcrumb / Item.js
1 /*
2  * - LGPL
3  *
4  *  Breadcrumb Item
5  * 
6  */
7
8
9 /**
10  * @class Roo.bootstrap.breadcrumb.Nav
11  * @extends Roo.bootstrap.Component
12  * @children Roo.bootstrap.Component
13  * Bootstrap Breadcrumb Nav Class
14  *  
15  * 
16  * @cfg {String} html the content of the link.
17  * @cfg {String} href where it links to if '#' is used the link will be handled by onClick.
18  * @cfg {Boolean} active is it active
19
20  * 
21  * @constructor
22  * Create a new breadcrumb.Nav
23  * @param {Object} config The config object
24  */
25
26 Roo.bootstrap.breadcrumb.Item = function(config){
27     Roo.bootstrap.breadcrumb.Item.superclass.constructor.call(this, config);
28     this.addEvents({
29         // img events
30         /**
31          * @event click
32          * The img click event for the img.
33          * @param {Roo.EventObject} e
34          */
35         "click" : true
36     });
37     
38 };
39
40 Roo.extend(Roo.bootstrap.breadcrumb.Item, Roo.bootstrap.Component,  {
41     
42     href: false,
43     html : '',
44     
45     getAutoCreate : function()
46     {
47
48         var cfg = {
49             tag: 'li',
50             cls : 'breadcrumb-item' + (this.active ? ' active' : '')
51         };
52         if (this.href !== false) {
53             cfg.cn = [{
54                 tag : 'a',
55                 href : this.href,
56                 html : this.html
57             }];
58         } else {
59             cfg.html = this.html;
60         }
61         
62         return cfg;
63     },
64     
65     initEvents: function()
66     {
67         if (this.href) {
68             this.el.select('a', true).first().on('click',this.onClick, this)
69         }
70         
71     },
72     onClick : function(e)
73     {
74         e.preventDefault();
75         this.fireEvent('click',this,  e);
76     }
77     
78 });
79
80