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