Upgrade to ExtJS 3.0.3 - Released 10/11/2009
[extjs.git] / docs / source / ColorMenu.html
1 <html>
2 <head>
3   <title>The source code</title>
4     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
6 </head>
7 <body  onload="prettyPrint();">
8     <pre class="prettyprint lang-js">/*!
9  * Ext JS Library 3.0.3
10  * Copyright(c) 2006-2009 Ext JS, LLC
11  * licensing@extjs.com
12  * http://www.extjs.com/license
13  */
14 <div id="cls-Ext.menu.ColorMenu"></div>/**\r
15  * @class Ext.menu.ColorMenu\r
16  * @extends Ext.menu.Menu\r
17  * <p>A menu containing a {@link Ext.ColorPalette} Component.</p>\r
18  * <p>Notes:</p><div class="mdetail-params"><ul>\r
19  * <li>Although not listed here, the <b>constructor</b> for this class\r
20  * accepts all of the configuration options of <b>{@link Ext.ColorPalette}</b>.</li>\r
21  * <li>If subclassing ColorMenu, any configuration options for the ColorPalette must be\r
22  * applied to the <tt><b>initialConfig</b></tt> property of the ColorMenu.\r
23  * Applying {@link Ext.ColorPalette ColorPalette} configuration settings to\r
24  * <b><tt>this</tt></b> will <b>not</b> affect the ColorPalette's configuration.</li>\r
25  * </ul></div> * \r
26  * @xtype colormenu\r
27  */\r
28  Ext.menu.ColorMenu = Ext.extend(Ext.menu.Menu, {\r
29     <div id="cfg-Ext.menu.ColorMenu-enableScrolling"></div>/** \r
30      * @cfg {Boolean} enableScrolling\r
31      * @hide \r
32      */\r
33     enableScrolling : false,\r
34     <div id="cfg-Ext.menu.ColorMenu-handler"></div>/**\r
35      * @cfg {Function} handler\r
36      * Optional. A function that will handle the select event of this menu.\r
37      * The handler is passed the following parameters:<div class="mdetail-params"><ul>\r
38      * <li><code>palette</code> : ColorPalette<div class="sub-desc">The {@link #palette Ext.ColorPalette}.</div></li>\r
39      * <li><code>color</code> : String<div class="sub-desc">The 6-digit color hex code (without the # symbol).</div></li>\r
40      * </ul></div>\r
41      */\r
42     <div id="cfg-Ext.menu.ColorMenu-scope"></div>/**\r
43      * @cfg {Object} scope\r
44      * The scope (<tt><b>this</b></tt> reference) in which the <code>{@link #handler}</code>\r
45      * function will be called.  Defaults to this ColorMenu instance.\r
46      */    \r
47     \r
48     <div id="cfg-Ext.menu.ColorMenu-hideOnClick"></div>/** \r
49      * @cfg {Boolean} hideOnClick\r
50      * False to continue showing the menu after a color is selected, defaults to true.\r
51      */\r
52     hideOnClick : true,\r
53     \r
54     cls : 'x-color-menu',\r
55     \r
56     <div id="cfg-Ext.menu.ColorMenu-paletteId"></div>/** \r
57      * @cfg {String} paletteId\r
58      * An id to assign to the underlying color palette. Defaults to <tt>null</tt>.\r
59      */\r
60     paletteId : null,\r
61     \r
62     <div id="cfg-Ext.menu.ColorMenu-maxHeight"></div>/** \r
63      * @cfg {Number} maxHeight\r
64      * @hide \r
65      */\r
66     <div id="cfg-Ext.menu.ColorMenu-scrollIncrement"></div>/** \r
67      * @cfg {Number} scrollIncrement\r
68      * @hide \r
69      */\r
70     <div id="prop-Ext.menu.ColorMenu-palette"></div>/**\r
71      * @property palette\r
72      * @type ColorPalette\r
73      * The {@link Ext.ColorPalette} instance for this ColorMenu\r
74      */\r
75     \r
76     \r
77     <div id="event-Ext.menu.ColorMenu-click"></div>/**\r
78      * @event click\r
79      * @hide\r
80      */\r
81     \r
82     <div id="event-Ext.menu.ColorMenu-itemclick"></div>/**\r
83      * @event itemclick\r
84      * @hide\r
85      */\r
86     \r
87     initComponent : function(){\r
88         Ext.apply(this, {\r
89             plain: true,\r
90             showSeparator: false,\r
91             items: this.palette = new Ext.ColorPalette(Ext.applyIf({\r
92                 id: this.paletteId\r
93             }, this.initialConfig))\r
94         });\r
95         this.palette.purgeListeners();\r
96         Ext.menu.ColorMenu.superclass.initComponent.call(this);\r
97         <div id="event-Ext.menu.ColorMenu-select"></div>/**\r
98          * @event select\r
99          * Fires when a color is selected from the {@link #palette Ext.ColorPalette}\r
100          * @param {Ext.ColorPalette} palette The {@link #palette Ext.ColorPalette}\r
101          * @param {String} color The 6-digit color hex code (without the # symbol)\r
102          */\r
103         this.relayEvents(this.palette, ['select']);\r
104         this.on('select', this.menuHide, this);\r
105         if(this.handler){\r
106             this.on('select', this.handler, this.scope || this);\r
107         }\r
108     },\r
109 \r
110     menuHide : function(){\r
111         if(this.hideOnClick){\r
112             this.hide(true);\r
113         }\r
114     }\r
115 });\r
116 Ext.reg('colormenu', Ext.menu.ColorMenu);\r
117 </pre>
118 </body>
119 </html>