Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / docs / source / ColorPicker.html
1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-menu.ColorPicker'>/**
2 </span> * @class Ext.menu.ColorPicker
3  * @extends Ext.menu.Menu
4  * &lt;p&gt;A menu containing a {@link Ext.picker.Color} Component.&lt;/p&gt;
5  * &lt;p&gt;Notes:&lt;/p&gt;&lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
6  * &lt;li&gt;Although not listed here, the &lt;b&gt;constructor&lt;/b&gt; for this class
7  * accepts all of the configuration options of &lt;b&gt;{@link Ext.picker.Color}&lt;/b&gt;.&lt;/li&gt;
8  * &lt;li&gt;If subclassing ColorMenu, any configuration options for the ColorPicker must be
9  * applied to the &lt;tt&gt;&lt;b&gt;initialConfig&lt;/b&gt;&lt;/tt&gt; property of the ColorMenu.
10  * Applying {@link Ext.picker.Color ColorPicker} configuration settings to
11  * &lt;b&gt;&lt;tt&gt;this&lt;/tt&gt;&lt;/b&gt; will &lt;b&gt;not&lt;/b&gt; affect the ColorPicker's configuration.&lt;/li&gt;
12  * &lt;/ul&gt;&lt;/div&gt;
13  * {@img Ext.menu.ColorPicker/Ext.menu.ColorPicker.png Ext.menu.ColorPicker component}
14  * __Example Usage__
15      var colorPicker = Ext.create('Ext.menu.ColorPicker', {
16         value: '000000'
17     });
18
19     Ext.create('Ext.menu.Menu', {
20                 width: 100,
21                 height: 90,
22                 floating: false,  // usually you want this set to True (default)
23                 renderTo: Ext.getBody(),  // usually rendered by it's containing component
24                 items: [{
25                     text: 'choose a color',
26                     menu: colorPicker
27                 },{
28             iconCls: 'add16',
29                     text: 'icon item'
30                 },{
31                     text: 'regular item'
32                 }]
33         });
34
35  * @xtype colormenu
36  * @author Nicolas Ferrero
37  */
38  Ext.define('Ext.menu.ColorPicker', {
39      extend: 'Ext.menu.Menu',
40
41      alias: 'widget.colormenu',
42
43      requires: [
44         'Ext.picker.Color'
45      ],
46
47 <span id='Ext-menu.ColorPicker-cfg-hideOnClick'>    /**
48 </span>     * @cfg {Boolean} hideOnClick
49      * False to continue showing the menu after a date is selected, defaults to true.
50      */
51     hideOnClick : true,
52
53 <span id='Ext-menu.ColorPicker-cfg-pickerId'>    /**
54 </span>     * @cfg {String} pickerId
55      * An id to assign to the underlying color picker. Defaults to &lt;tt&gt;null&lt;/tt&gt;.
56      */
57     pickerId : null,
58
59 <span id='Ext-menu.ColorPicker-cfg-maxHeight'>    /**
60 </span>     * @cfg {Number} maxHeight
61      * @hide
62      */
63
64 <span id='Ext-menu.ColorPicker-property-picker'>    /**
65 </span>     * The {@link Ext.picker.Color} instance for this ColorMenu
66      * @property picker
67      * @type ColorPicker
68      */
69
70 <span id='Ext-menu.ColorPicker-event-click'>    /**
71 </span>     * @event click
72      * @hide
73      */
74
75 <span id='Ext-menu.ColorPicker-event-itemclick'>    /**
76 </span>     * @event itemclick
77      * @hide
78      */
79
80     initComponent : function(){
81         var me = this;
82
83         Ext.apply(me, {
84             plain: true,
85             showSeparator: false,
86             items: Ext.applyIf({
87                 cls: Ext.baseCSSPrefix + 'menu-color-item',
88                 id: me.pickerId,
89                 xtype: 'colorpicker'
90             }, me.initialConfig)
91         });
92
93         me.callParent(arguments);
94
95         me.picker = me.down('colorpicker');
96
97 <span id='Ext-menu.ColorPicker-event-select'>        /**
98 </span>         * @event select
99          * Fires when a date is selected from the {@link #picker Ext.picker.Color}
100          * @param {Ext.picker.Color} picker The {@link #picker Ext.picker.Color}
101          * @param {String} color The 6-digit color hex code (without the # symbol)
102          */
103         me.relayEvents(me.picker, ['select']);
104
105         if (me.hideOnClick) {
106             me.on('select', me.hidePickerOnSelect, me);
107         }
108     },
109
110 <span id='Ext-menu.ColorPicker-method-hidePickerOnSelect'>    /**
111 </span>     * Hides picker on select if hideOnClick is true
112      * @private
113      */
114     hidePickerOnSelect: function() {
115         Ext.menu.Manager.hideAll();
116     }
117  });</pre></pre></body></html>