1cd46025d27fe362ebf9c43a7477bd4af4faf949
[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
18  * 
19  * @constructor
20  * Create a new breadcrumb.Nav
21  * @param {Object} config The config object
22  */
23
24 Roo.bootstrap.breadcrumb.Item = function(config){
25     Roo.bootstrap.breadcrumb.Item.superclass.constructor.call(this, config);
26     this.addEvents({
27         // img events
28         /**
29          * @event click
30          * The img click event for the img.
31          * @param {Roo.EventObject} e
32          */
33         "click" : true
34     });
35     
36 };
37
38 Roo.extend(Roo.bootstrap.breadcrumb.Item, Roo.bootstrap.Component,  {
39     
40     href: false,
41     html : '',
42     
43     getAutoCreate : function()
44     {
45
46         var cfg = {
47             tag: 'li'
48         };
49         if (this.href !== false) {
50             cfg.cn = [{
51                 tag : 'a',
52                 href : this.href,
53                 html : this.html
54             }];
55         } else {
56             cfg.html = this.html;
57         }
58         
59         return cfg;
60     },
61     
62     initEvents: function()
63     {
64         if (this.href) {
65             this.el.select('a', true).first().onClick(this.onClick, this)
66         }
67         
68     },
69     onClick : function(e)
70     {
71         e.preventDefault();
72         this.fireEvent('click',this,  e);
73     }
74     
75 });
76
77