7 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
10 * @class Roo.bootstrap.menu.Item
11 * @extends Roo.bootstrap.Component
12 * Bootstrap MenuItem class
13 * @cfg {Boolean} submenu (true | false) default false
14 * @cfg {String} html text of the item
15 * @cfg {String} href the link
16 * @cfg {Boolean} disable (true | false) default false
17 * @cfg {Boolean} preventDefault (true | false) default true
18 * @cfg {String} icon Font awesome icon
19 * @cfg {String} pos Submenu align to (left | right) default right
24 * @param {Object} config The config object
28 Roo.bootstrap.menu.Item = function(config){
29 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
33 * Fires when the mouse is hovering over this menu
34 * @param {Roo.bootstrap.menu.Item} this
35 * @param {Roo.EventObject} e
40 * Fires when the mouse exits this menu
41 * @param {Roo.bootstrap.menu.Item} this
42 * @param {Roo.EventObject} e
48 * The raw click event for the entire grid.
49 * @param {Roo.EventObject} e
55 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
65 getAutoCreate : function()
70 cls : 'roo-menu-item-text',
78 cls : 'fa ' + this.icon
87 href : this.href || '#',
94 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
98 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
100 if(this.pos == 'left'){
101 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
108 initEvents : function()
110 this.el.on('mouseover', this.onMouseOver, this);
111 this.el.on('mouseout', this.onMouseOut, this);
113 this.el.select('a', true).first().on('click', this.onClick, this);
117 onClick : function(e)
119 if(this.preventDefault){
123 this.fireEvent("click", this, e);
126 onMouseOver : function(e)
128 if(this.submenu && this.pos == 'left'){
129 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
132 this.fireEvent("mouseover", this, e);
135 onMouseOut : function(e)
137 this.fireEvent("mouseout", this, e);