7 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
10 * @class Roo.bootstrap.menu.Menu
11 * @extends Roo.bootstrap.Component
12 * Bootstrap Menu class - container for Menu
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);
29 * Fires before this menu is displayed
30 * @param {Roo.bootstrap.menu.Menu} this
35 * Fires before this menu is hidden
36 * @param {Roo.bootstrap.menu.Menu} this
41 * Fires after this menu is displayed
42 * @param {Roo.bootstrap.menu.Menu} this
47 * Fires after this menu is hidden
48 * @param {Roo.bootstrap.menu.Menu} this
53 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
54 * @param {Roo.bootstrap.menu.Menu} this
55 * @param {Roo.EventObject} e
62 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
69 getChildContainer : function() {
74 return this.el.select('ul.dropdown-menu', true).first();
77 getAutoCreate : function()
85 cls : 'btn btn-' + this.weight,
90 cls : 'dropdown-toggle btn btn-' + this.weight,
100 cls : 'dropdown-menu'
109 cls : 'dropdown-menu'
116 initEvents : function()
123 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
124 this.triggerEl.on('click', this.onTriggerPress, this);
126 this.el.on('click', this.onClick, this);
130 onClick : function(e)
132 this.fireEvent("click", this, e);
135 onTriggerPress : function(e)
137 if (this.isVisible()) {
144 isVisible : function(){
150 this.fireEvent("beforeshow", this);
153 this.el.addClass('open');
155 Roo.get(document).on("mouseup", this.onMouseUp, this);
157 this.fireEvent("show", this);
163 this.fireEvent("beforehide", this);
166 this.el.removeClass('open');
168 Roo.get(document).un("mouseup", onMouseUp);
170 this.fireEvent("hide", this);
173 onMouseUp : function()