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>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
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
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
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
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
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
54 cls : 'x-color-menu',
\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
62 <div id="cfg-Ext.menu.ColorMenu-maxHeight"></div>/**
\r
63 * @cfg {Number} maxHeight
\r
66 <div id="cfg-Ext.menu.ColorMenu-scrollIncrement"></div>/**
\r
67 * @cfg {Number} scrollIncrement
\r
70 <div id="prop-Ext.menu.ColorMenu-palette"></div>/**
\r
72 * @type ColorPalette
\r
73 * The {@link Ext.ColorPalette} instance for this ColorMenu
\r
77 <div id="event-Ext.menu.ColorMenu-click"></div>/**
\r
82 <div id="event-Ext.menu.ColorMenu-itemclick"></div>/**
\r
87 initComponent : function(){
\r
90 showSeparator: false,
\r
91 items: this.palette = new Ext.ColorPalette(Ext.applyIf({
\r
93 }, this.initialConfig))
\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
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
103 this.relayEvents(this.palette, ['select']);
\r
104 this.on('select', this.menuHide, this);
\r
106 this.on('select', this.handler, this.scope || this);
\r
110 menuHide : function(){
\r
111 if(this.hideOnClick){
\r
116 Ext.reg('colormenu', Ext.menu.ColorMenu);
\r