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 {String} html Text of the menu
14 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
15 * @cfg {Boolean} preventDefault (true | false) default true
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, {
70 getChildContainer : function() {
75 return this.el.select('ul.dropdown-menu', true).first();
78 getAutoCreate : function()
86 cls : 'dropdown-button btn btn-' + this.weight,
91 cls : 'dropdown-toggle btn btn-' + this.weight,
101 cls : 'dropdown-menu'
107 if(this.isSubMenu()){
110 cls : 'dropdown-menu'
117 isSubMenu : function()
119 if(this.parent() instanceof Roo.bootstrap.menu.Item){
127 initEvents : function()
130 if(this.isSubMenu()){
136 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
137 this.triggerEl.on('click', this.onTriggerPress, this);
139 this.buttonEl = this.el.select('button.dropdown-button', true).first();
140 this.buttonEl.on('click', this.onClick, this);
144 onClick : function(e)
146 this.fireEvent("click", this, e);
149 onTriggerPress : function(e)
151 if (this.isVisible()) {
158 isVisible : function(){
164 this.fireEvent("beforeshow", this);
167 this.el.addClass('open');
169 Roo.get(document).on("mouseup", this.onMouseUp, this);
171 this.fireEvent("show", this);
177 this.fireEvent("beforehide", this);
180 this.el.removeClass('open');
182 Roo.get(document).un("mouseup", this.onMouseUp);
184 this.fireEvent("hide", this);
187 onMouseUp : function()