3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
8 * @class Ext.menu.DateMenu
9 * @extends Ext.menu.Menu
10 * <p>A menu containing an {@link Ext.DatePicker} 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.DatePicker}</b>.</li>
14 * <li>If subclassing DateMenu, any configuration options for the DatePicker must be
15 * applied to the <tt><b>initialConfig</b></tt> property of the DateMenu.
16 * Applying {@link Ext.DatePicker DatePicker} configuration settings to
17 * <b><tt>this</tt></b> will <b>not</b> affect the DatePicker's configuration.</li>
21 Ext.menu.DateMenu = 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>picker</code> : DatePicker<div class="sub-desc">The Ext.DatePicker.</div></li>
32 * <li><code>date</code> : Date<div class="sub-desc">The selected date.</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 DateMenu instance.
41 * @cfg {Boolean} hideOnClick
42 * False to continue showing the menu after a date is selected, defaults to true.
47 * @cfg {String} pickerId
48 * An id to assign to the underlying date picker. Defaults to <tt>null</tt>.
53 * @cfg {Number} maxHeight
57 * @cfg {Number} scrollIncrement
61 * The {@link Ext.DatePicker} instance for this DateMenu
77 initComponent : function(){
78 this.on('beforeshow', this.onBeforeShow, this);
79 if(this.strict = (Ext.isIE7 && Ext.isStrict)){
80 this.on('show', this.onShow, this, {single: true, delay: 20});
85 items: this.picker = new Ext.DatePicker(Ext.applyIf({
86 internalRender: this.strict || !Ext.isIE,
87 ctCls: 'x-menu-date-item',
89 }, this.initialConfig))
91 this.picker.purgeListeners();
92 Ext.menu.DateMenu.superclass.initComponent.call(this);
95 * Fires when a date is selected from the {@link #picker Ext.DatePicker}
96 * @param {DatePicker} picker The {@link #picker Ext.DatePicker}
97 * @param {Date} date The selected date
99 this.relayEvents(this.picker, ['select']);
100 this.on('show', this.picker.focus, this.picker);
101 this.on('select', this.menuHide, this);
103 this.on('select', this.handler, this.scope || this);
107 menuHide : function() {
108 if(this.hideOnClick){
113 onBeforeShow : function(){
115 this.picker.hideMonthPicker(true);
120 var el = this.picker.getEl();
121 el.setWidth(el.getWidth()); //nasty hack for IE7 strict mode
124 Ext.reg('datemenu', Ext.menu.DateMenu);