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)
18 * @param {Object} config The config object
22 Roo.bootstrap.menu.Menu = function(config){
23 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
28 * Fires before this menu is displayed
29 * @param {Roo.bootstrap.menu.Menu} this
34 * Fires before this menu is hidden
35 * @param {Roo.bootstrap.menu.Menu} this
40 * Fires after this menu is displayed
41 * @param {Roo.bootstrap.menu.Menu} this
46 * Fires after this menu is hidden
47 * @param {Roo.bootstrap.menu.Menu} this
52 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
53 * @param {Roo.bootstrap.menu.Menu} this
54 * @param {Roo.EventObject} e
61 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
68 getChildContainer : function() {
73 return this.el.select('ul.dropdown-menu', true).first();
76 getAutoCreate : function()
84 cls : 'dropdown-button btn btn-' + this.weight,
89 cls : 'dropdown-toggle btn btn-' + this.weight,
105 if(this.isSubMenu()){
108 cls : 'dropdown-menu'
115 isSubMenu : function()
117 Roo.log(this.parent());
118 if(this.parent() instanceof Roo.bootstrap.menu.Item){
127 initEvents : function()
131 Roo.log('is submenu');
135 Roo.log('not submenu');
139 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
140 this.triggerEl.on('click', this.onTriggerPress, this);
142 this.buttonEl = this.el.select('button.dropdown-button', true).first();
143 this.buttonEl.on('click', this.onClick, this);
147 onClick : function(e)
149 this.fireEvent("click", this, e);
152 onTriggerPress : function(e)
154 if (this.isVisible()) {
161 isVisible : function(){
167 this.fireEvent("beforeshow", this);
170 this.el.addClass('open');
172 Roo.get(document).on("mouseup", this.onMouseUp, this);
174 this.fireEvent("show", this);
180 this.fireEvent("beforehide", this);
183 this.el.removeClass('open');
185 Roo.get(document).un("mouseup", this.onMouseUp);
187 this.fireEvent("hide", this);
190 onMouseUp : function()