7 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
10 * @class Roo.bootstrap.menu.Menu
11 * @extends Roo.bootstrap.Component
12 * Bootstrap Menu class - container for MenuItems
13 * @cfg {Boolean} submenu (true | false) default false
14 * @cfg {String} html Text of the menu
15 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
19 * @param {Object} config The config object
23 Roo.bootstrap.menu.Menu = function(config){
24 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
28 // * @event beforeshow
29 // * Fires before this menu is displayed
30 // * @param {Roo.menu.Menu} this
34 // * @event beforehide
35 // * Fires before this menu is hidden
36 // * @param {Roo.menu.Menu} this
41 // * Fires after this menu is displayed
42 // * @param {Roo.menu.Menu} this
47 // * Fires after this menu is hidden
48 // * @param {Roo.menu.Menu} this
53 // * Fires when this menu is clicked (or when the enter key is pressed while it is active)
54 // * @param {Roo.menu.Menu} this
55 // * @param {Roo.menu.Item} menuItem The menu item that was clicked
56 // * @param {Roo.EventObject} e
61 // * Fires when the mouse is hovering over this menu
62 // * @param {Roo.menu.Menu} this
63 // * @param {Roo.EventObject} e
64 // * @param {Roo.menu.Item} menuItem The menu item that was clicked
69 // * Fires when the mouse exits this menu
70 // * @param {Roo.menu.Menu} this
71 // * @param {Roo.EventObject} e
72 // * @param {Roo.menu.Item} menuItem The menu item that was clicked
77 // * Fires when a menu item contained in this menu is clicked
78 // * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
79 // * @param {Roo.EventObject} e
86 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
93 getChildContainer : function() {
98 return this.el.select('ul.dropdown-menu', true).first();
101 getAutoCreate : function()
109 cls : 'btn btn-' + this.weight,
114 cls : 'dropdown-toggle btn btn-' + this.weight,
124 cls : 'dropdown-menu'
133 cls : 'dropdown-menu'
140 initEvents : function()
147 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
148 this.triggerEl.on('click', this.onTriggerPress, this);
150 this.el.on('click', this.onClick, this);
154 onClick : function(e)
156 this.fireEvent("click", this, e);
159 onTriggerPress : function(e)
161 Roo.log('trigger press');
163 if (this.isVisible()) {
172 isVisible : function(){
179 this.el.addClass('open');
181 Roo.get(document).on("mousedown", this.onMouseDown, this);
188 this.el.removeClass('open');;
191 onMouseDown : function()
193 Roo.log('onMouseDown');