3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
8 * @class Ext.menu.ColorMenu
9 * @extends Ext.menu.Menu
10 * <p>A menu containing a {@link Ext.ColorPalette} Component.</p>
11 * <p>Notes:</p><div class="mdetail-params"><ul>
12 * <li>Although not listed here, the <b>constructor</b> for this class
13 * accepts all of the configuration options of <b>{@link Ext.ColorPalette}</b>.</li>
14 * <li>If subclassing ColorMenu, any configuration options for the ColorPalette must be
15 * applied to the <tt><b>initialConfig</b></tt> property of the ColorMenu.
16 * Applying {@link Ext.ColorPalette ColorPalette} configuration settings to
17 * <b><tt>this</tt></b> will <b>not</b> affect the ColorPalette's configuration.</li>
21 Ext.menu.ColorMenu = Ext.extend(Ext.menu.Menu, {
23 * @cfg {Boolean} enableScrolling
26 enableScrolling : false,
28 * @cfg {Function} handler
29 * Optional. A function that will handle the select event of this menu.
30 * The handler is passed the following parameters:<div class="mdetail-params"><ul>
31 * <li><code>palette</code> : ColorPalette<div class="sub-desc">The {@link #palette Ext.ColorPalette}.</div></li>
32 * <li><code>color</code> : String<div class="sub-desc">The 6-digit color hex code (without the # symbol).</div></li>
37 * The scope (<tt><b>this</b></tt> reference) in which the <code>{@link #handler}</code>
38 * function will be called. Defaults to this ColorMenu instance.
42 * @cfg {Boolean} hideOnClick
43 * False to continue showing the menu after a color is selected, defaults to true.
50 * @cfg {String} paletteId
51 * An id to assign to the underlying color palette. Defaults to <tt>null</tt>.
56 * @cfg {Number} maxHeight
60 * @cfg {Number} scrollIncrement
66 * The {@link Ext.ColorPalette} instance for this ColorMenu
80 initComponent : function(){
84 items: this.palette = new Ext.ColorPalette(Ext.applyIf({
86 }, this.initialConfig))
88 this.palette.purgeListeners();
89 Ext.menu.ColorMenu.superclass.initComponent.call(this);
92 * Fires when a color is selected from the {@link #palette Ext.ColorPalette}
93 * @param {Ext.ColorPalette} palette The {@link #palette Ext.ColorPalette}
94 * @param {String} color The 6-digit color hex code (without the # symbol)
96 this.relayEvents(this.palette, ['select']);
97 this.on('select', this.menuHide, this);
99 this.on('select', this.handler, this.scope || this);
103 menuHide : function(){
104 if(this.hideOnClick){
109 Ext.reg('colormenu', Ext.menu.ColorMenu);