Roo/bootstrap/menu/Menu.js
[roojs1] / Roo / bootstrap / menu / Menu.js
1 /*
2  * - LGPL
3  *
4  * menu
5  * 
6  */
7 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
8
9 /**
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 (primary | success | info | warning | danger | inverse) default empty
16  * 
17  * @constructor
18  * Create a new Menu
19  * @param {Object} config The config object
20  */
21
22
23 Roo.bootstrap.menu.Menu = function(config){
24     Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
25     
26 //    this.addEvents({
27 //        /**
28 //         * @event beforeshow
29 //         * Fires before this menu is displayed
30 //         * @param {Roo.menu.Menu} this
31 //         */
32 //        beforeshow : true,
33 //        /**
34 //         * @event beforehide
35 //         * Fires before this menu is hidden
36 //         * @param {Roo.menu.Menu} this
37 //         */
38 //        beforehide : true,
39 //        /**
40 //         * @event show
41 //         * Fires after this menu is displayed
42 //         * @param {Roo.menu.Menu} this
43 //         */
44 //        show : true,
45 //        /**
46 //         * @event hide
47 //         * Fires after this menu is hidden
48 //         * @param {Roo.menu.Menu} this
49 //         */
50 //        hide : true,
51 //        /**
52 //         * @event click
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
57 //         */
58 //        click : true,
59 //        /**
60 //         * @event mouseover
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
65 //         */
66 //        mouseover : true,
67 //        /**
68 //         * @event mouseout
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
73 //         */
74 //        mouseout : true,
75 //        /**
76 //         * @event itemclick
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
80 //         */
81 //        itemclick: true
82 //    });
83     
84 };
85
86 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component,  {
87     
88     submenu : false,
89     html : '',
90     weight : '',
91     
92     
93     getChildContainer : function() {
94         return this.el.select('ul.dropdown-menu', true).first();  
95     },
96     
97     getAutoCreate : function()
98     {
99         var cfg = {
100             tag : 'div',
101             cls : 'btn-group',
102             cn : [
103                 {
104                     tag : 'button',
105                     cls : 'btn ' + ((this.weight) ? ('btn-' + this.weight) : '')
106                 },
107                 {
108                     tag : 'button',
109                     cls : 'dropdown-toggle btn ' + ((this.weight) ? ('btn-' + this.weight) : ''),
110                     cn : [
111                         {
112                             tag : 'span',
113                             cls : 'caret'
114                         }
115                     ]
116                 },
117                 {
118                     tag : 'ul',
119                     cls : 'dropdown-menu'
120                 }
121             ]
122             
123         };
124         Roo.log(cfg);
125         return cfg;
126     }
127 });
128
129  
130