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 {String} icon Font awesome icon
16 * @cfg {String} pos Menu align to (top | bottom) default bottom
21 * @param {Object} config The config object
25 Roo.bootstrap.menu.Menu = function(config){
26 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
31 * Fires before this menu is displayed
32 * @param {Roo.bootstrap.menu.Menu} this
37 * Fires before this menu is hidden
38 * @param {Roo.bootstrap.menu.Menu} this
43 * Fires after this menu is displayed
44 * @param {Roo.bootstrap.menu.Menu} this
49 * Fires after this menu is hidden
50 * @param {Roo.bootstrap.menu.Menu} this
55 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
56 * @param {Roo.bootstrap.menu.Menu} this
57 * @param {Roo.EventObject} e
64 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
72 getChildContainer : function() {
77 return this.el.select('ul.dropdown-menu', true).first();
80 getAutoCreate : function()
85 cls : 'roo-menu-text',
93 cls : 'fa ' + this.icon
104 cls : 'dropdown-button btn btn-' + this.weight,
109 cls : 'dropdown-toggle btn btn-' + this.weight,
119 cls : 'dropdown-menu'
125 if(this.isSubMenu()){
128 cls : 'dropdown-menu'
135 isSubMenu : function()
137 if(this.parent() instanceof Roo.bootstrap.menu.Item){
145 initEvents : function()
148 if(this.isSubMenu()){
154 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
155 this.triggerEl.on('click', this.onTriggerPress, this);
157 this.buttonEl = this.el.select('button.dropdown-button', true).first();
158 this.buttonEl.on('click', this.onClick, this);
162 onClick : function(e)
164 this.fireEvent("click", this, e);
167 onTriggerPress : function(e)
169 if (this.isVisible()) {
176 isVisible : function(){
182 this.fireEvent("beforeshow", this);
185 this.el.addClass('open');
187 Roo.get(document).on("mouseup", this.onMouseUp, this);
189 this.fireEvent("show", this);
195 this.fireEvent("beforehide", this);
198 this.el.removeClass('open');
200 Roo.get(document).un("mouseup", this.onMouseUp);
202 this.fireEvent("hide", this);
205 onMouseUp : function()