Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / src / widgets / menu / ColorMenu.js
1 /*!
2  * Ext JS Library 3.0.0
3  * Copyright(c) 2006-2009 Ext JS, LLC
4  * licensing@extjs.com
5  * http://www.extjs.com/license
6  */
7 /**\r
8  * @class Ext.menu.ColorMenu\r
9  * @extends Ext.menu.Menu\r
10  * A menu containing a {@link Ext.ColorPalette} Component.\r
11  * @xtype colormenu\r
12  */\r
13  Ext.menu.ColorMenu = Ext.extend(Ext.menu.Menu, {\r
14     /** \r
15      * @cfg {Boolean} enableScrolling\r
16      * @hide \r
17      */\r
18     enableScrolling: false,\r
19     \r
20     /** \r
21      * @cfg {Boolean} hideOnClick\r
22      * False to continue showing the menu after a color is selected, defaults to true.\r
23      */\r
24     hideOnClick: true,\r
25     \r
26     /** \r
27      * @cfg {Number} maxHeight\r
28      * @hide \r
29      */\r
30     /** \r
31      * @cfg {Number} scrollIncrement\r
32      * @hide \r
33      */\r
34     /**\r
35      * @property palette\r
36      * @type ColorPalette\r
37      * The {@link Ext.ColorPalette} instance for this ColorMenu\r
38      */\r
39     \r
40     \r
41     /**\r
42      * @event click\r
43      * @hide\r
44      */\r
45     \r
46     /**\r
47      * @event itemclick\r
48      * @hide\r
49      */\r
50     \r
51     initComponent: function(){\r
52         Ext.apply(this, {\r
53             plain: true,\r
54             showSeparator: false,\r
55             items: this.palette = new Ext.ColorPalette(this.initialConfig)\r
56         });\r
57         this.palette.purgeListeners();\r
58         Ext.menu.ColorMenu.superclass.initComponent.call(this);\r
59         this.relayEvents(this.palette, ['select']);\r
60         this.on('select', this.menuHide, this);\r
61         if(this.handler){\r
62             this.on('select', this.handler, this.scope || this)\r
63         }\r
64     },\r
65 \r
66     menuHide: function(){\r
67         if(this.hideOnClick){\r
68             this.hide(true);\r
69         }\r
70     }\r
71 });\r
72 Ext.reg('colormenu', Ext.menu.ColorMenu);