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