Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / source / DatePicker.html
diff --git a/docs/source/DatePicker.html b/docs/source/DatePicker.html
new file mode 100644 (file)
index 0000000..b809175
--- /dev/null
@@ -0,0 +1,788 @@
+<html>\r
+<head>\r
+  <title>The source code</title>\r
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
+</head>\r
+<body  onload="prettyPrint();">\r
+    <pre class="prettyprint lang-js"><div id="cls-Ext.DatePicker"></div>/**\r
+ * @class Ext.DatePicker\r
+ * @extends Ext.Component\r
+ * Simple date picker class.\r
+ * @constructor\r
+ * Create a new DatePicker\r
+ * @param {Object} config The config object\r
+ * @xtype datepicker\r
+ */\r
+Ext.DatePicker = Ext.extend(Ext.BoxComponent, {\r
+    <div id="cfg-Ext.DatePicker-todayText"></div>/**\r
+     * @cfg {String} todayText\r
+     * The text to display on the button that selects the current date (defaults to <tt>'Today'</tt>)\r
+     */\r
+    todayText : 'Today',\r
+    <div id="cfg-Ext.DatePicker-okText"></div>/**\r
+     * @cfg {String} okText\r
+     * The text to display on the ok button (defaults to <tt>'&#160;OK&#160;'</tt> to give the user extra clicking room)\r
+     */\r
+    okText : '&#160;OK&#160;',\r
+    <div id="cfg-Ext.DatePicker-cancelText"></div>/**\r
+     * @cfg {String} cancelText\r
+     * The text to display on the cancel button (defaults to <tt>'Cancel'</tt>)\r
+     */\r
+    cancelText : 'Cancel',\r
+    <div id="cfg-Ext.DatePicker-handler"></div>/**\r
+     * @cfg {Function} handler\r
+     * Optional. A function that will handle the select event of this picker.\r
+     * The handler is passed the following parameters:<div class="mdetail-params"><ul>\r
+     * <li><code>picker</code> : DatePicker<div class="sub-desc">The Ext.DatePicker.</div></li>\r
+     * <li><code>date</code> : Date<div class="sub-desc">The selected date.</div></li>\r
+     * </ul></div>\r
+     */\r
+    <div id="cfg-Ext.DatePicker-scope"></div>/**\r
+     * @cfg {Object} scope\r
+     * The scope (<tt><b>this</b></tt> reference) in which the <code>{@link #handler}</code>\r
+     * function will be called.  Defaults to this DatePicker instance.\r
+     */ \r
+    <div id="cfg-Ext.DatePicker-todayTip"></div>/**\r
+     * @cfg {String} todayTip\r
+     * The tooltip to display for the button that selects the current date (defaults to <tt>'{current date} (Spacebar)'</tt>)\r
+     */\r
+    todayTip : '{0} (Spacebar)',\r
+    <div id="cfg-Ext.DatePicker-minText"></div>/**\r
+     * @cfg {String} minText\r
+     * The error text to display if the minDate validation fails (defaults to <tt>'This date is before the minimum date'</tt>)\r
+     */\r
+    minText : 'This date is before the minimum date',\r
+    <div id="cfg-Ext.DatePicker-maxText"></div>/**\r
+     * @cfg {String} maxText\r
+     * The error text to display if the maxDate validation fails (defaults to <tt>'This date is after the maximum date'</tt>)\r
+     */\r
+    maxText : 'This date is after the maximum date',\r
+    <div id="cfg-Ext.DatePicker-format"></div>/**\r
+     * @cfg {String} format\r
+     * The default date format string which can be overriden for localization support.  The format must be\r
+     * valid according to {@link Date#parseDate} (defaults to <tt>'m/d/y'</tt>).\r
+     */\r
+    format : 'm/d/y',\r
+    <div id="cfg-Ext.DatePicker-disabledDaysText"></div>/**\r
+     * @cfg {String} disabledDaysText\r
+     * The tooltip to display when the date falls on a disabled day (defaults to <tt>'Disabled'</tt>)\r
+     */\r
+    disabledDaysText : 'Disabled',\r
+    <div id="cfg-Ext.DatePicker-disabledDatesText"></div>/**\r
+     * @cfg {String} disabledDatesText\r
+     * The tooltip text to display when the date falls on a disabled date (defaults to <tt>'Disabled'</tt>)\r
+     */\r
+    disabledDatesText : 'Disabled',\r
+    <div id="cfg-Ext.DatePicker-monthNames"></div>/**\r
+     * @cfg {Array} monthNames\r
+     * An array of textual month names which can be overriden for localization support (defaults to Date.monthNames)\r
+     */\r
+    monthNames : Date.monthNames,\r
+    <div id="cfg-Ext.DatePicker-dayNames"></div>/**\r
+     * @cfg {Array} dayNames\r
+     * An array of textual day names which can be overriden for localization support (defaults to Date.dayNames)\r
+     */\r
+    dayNames : Date.dayNames,\r
+    <div id="cfg-Ext.DatePicker-nextText"></div>/**\r
+     * @cfg {String} nextText\r
+     * The next month navigation button tooltip (defaults to <tt>'Next Month (Control+Right)'</tt>)\r
+     */\r
+    nextText : 'Next Month (Control+Right)',\r
+    <div id="cfg-Ext.DatePicker-prevText"></div>/**\r
+     * @cfg {String} prevText\r
+     * The previous month navigation button tooltip (defaults to <tt>'Previous Month (Control+Left)'</tt>)\r
+     */\r
+    prevText : 'Previous Month (Control+Left)',\r
+    <div id="cfg-Ext.DatePicker-monthYearText"></div>/**\r
+     * @cfg {String} monthYearText\r
+     * The header month selector tooltip (defaults to <tt>'Choose a month (Control+Up/Down to move years)'</tt>)\r
+     */\r
+    monthYearText : 'Choose a month (Control+Up/Down to move years)',\r
+    <div id="cfg-Ext.DatePicker-startDay"></div>/**\r
+     * @cfg {Number} startDay\r
+     * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)\r
+     */\r
+    startDay : 0,\r
+    <div id="cfg-Ext.DatePicker-showToday"></div>/**\r
+     * @cfg {Boolean} showToday\r
+     * False to hide the footer area containing the Today button and disable the keyboard handler for spacebar\r
+     * that selects the current date (defaults to <tt>true</tt>).\r
+     */\r
+    showToday : true,\r
+    <div id="cfg-Ext.DatePicker-minDate"></div>/**\r
+     * @cfg {Date} minDate\r
+     * Minimum allowable date (JavaScript date object, defaults to null)\r
+     */\r
+    <div id="cfg-Ext.DatePicker-maxDate"></div>/**\r
+     * @cfg {Date} maxDate\r
+     * Maximum allowable date (JavaScript date object, defaults to null)\r
+     */\r
+    <div id="cfg-Ext.DatePicker-disabledDays"></div>/**\r
+     * @cfg {Array} disabledDays\r
+     * An array of days to disable, 0-based. For example, [0, 6] disables Sunday and Saturday (defaults to null).\r
+     */\r
+    <div id="cfg-Ext.DatePicker-disabledDatesRE"></div>/**\r
+     * @cfg {RegExp} disabledDatesRE\r
+     * JavaScript regular expression used to disable a pattern of dates (defaults to null).  The {@link #disabledDates}\r
+     * config will generate this regex internally, but if you specify disabledDatesRE it will take precedence over the\r
+     * disabledDates value.\r
+     */\r
+    <div id="cfg-Ext.DatePicker-disabledDates"></div>/**\r
+     * @cfg {Array} disabledDates\r
+     * An array of 'dates' to disable, as strings. These strings will be used to build a dynamic regular\r
+     * expression so they are very powerful. Some examples:\r
+     * <ul>\r
+     * <li>['03/08/2003', '09/16/2003'] would disable those exact dates</li>\r
+     * <li>['03/08', '09/16'] would disable those days for every year</li>\r
+     * <li>['^03/08'] would only match the beginning (useful if you are using short years)</li>\r
+     * <li>['03/../2006'] would disable every day in March 2006</li>\r
+     * <li>['^03'] would disable every day in every March</li>\r
+     * </ul>\r
+     * Note that the format of the dates included in the array should exactly match the {@link #format} config.\r
+     * In order to support regular expressions, if you are using a date format that has '.' in it, you will have to\r
+     * escape the dot when restricting dates. For example: ['03\\.08\\.03'].\r
+     */\r
+\r
+    // private\r
+    initComponent : function(){\r
+        Ext.DatePicker.superclass.initComponent.call(this);\r
+\r
+        this.value = this.value ?\r
+                 this.value.clearTime() : new Date().clearTime();\r
+\r
+        this.addEvents(\r
+            <div id="event-Ext.DatePicker-select"></div>/**\r
+             * @event select\r
+             * Fires when a date is selected\r
+             * @param {DatePicker} this\r
+             * @param {Date} date The selected date\r
+             */\r
+            'select'\r
+        );\r
+\r
+        if(this.handler){\r
+            this.on('select', this.handler,  this.scope || this);\r
+        }\r
+\r
+        this.initDisabledDays();\r
+    },\r
+\r
+    // private\r
+    initDisabledDays : function(){\r
+        if(!this.disabledDatesRE && this.disabledDates){\r
+            var dd = this.disabledDates,\r
+                len = dd.length - 1,\r
+                re = '(?:';\r
+                \r
+            Ext.each(dd, function(d, i){\r
+                re += Ext.isDate(d) ? '^' + Ext.escapeRe(d.dateFormat(this.format)) + '$' : dd[i];\r
+                if(i != len){\r
+                    re += '|';\r
+                }\r
+            }, this);\r
+            this.disabledDatesRE = new RegExp(re + ')');\r
+        }\r
+    },\r
+\r
+    <div id="method-Ext.DatePicker-setDisabledDates"></div>/**\r
+     * Replaces any existing disabled dates with new values and refreshes the DatePicker.\r
+     * @param {Array/RegExp} disabledDates An array of date strings (see the {@link #disabledDates} config\r
+     * for details on supported values), or a JavaScript regular expression used to disable a pattern of dates.\r
+     */\r
+    setDisabledDates : function(dd){\r
+        if(Ext.isArray(dd)){\r
+            this.disabledDates = dd;\r
+            this.disabledDatesRE = null;\r
+        }else{\r
+            this.disabledDatesRE = dd;\r
+        }\r
+        this.initDisabledDays();\r
+        this.update(this.value, true);\r
+    },\r
+\r
+    <div id="method-Ext.DatePicker-setDisabledDays"></div>/**\r
+     * Replaces any existing disabled days (by index, 0-6) with new values and refreshes the DatePicker.\r
+     * @param {Array} disabledDays An array of disabled day indexes. See the {@link #disabledDays} config\r
+     * for details on supported values.\r
+     */\r
+    setDisabledDays : function(dd){\r
+        this.disabledDays = dd;\r
+        this.update(this.value, true);\r
+    },\r
+\r
+    <div id="method-Ext.DatePicker-setMinDate"></div>/**\r
+     * Replaces any existing {@link #minDate} with the new value and refreshes the DatePicker.\r
+     * @param {Date} value The minimum date that can be selected\r
+     */\r
+    setMinDate : function(dt){\r
+        this.minDate = dt;\r
+        this.update(this.value, true);\r
+    },\r
+\r
+    <div id="method-Ext.DatePicker-setMaxDate"></div>/**\r
+     * Replaces any existing {@link #maxDate} with the new value and refreshes the DatePicker.\r
+     * @param {Date} value The maximum date that can be selected\r
+     */\r
+    setMaxDate : function(dt){\r
+        this.maxDate = dt;\r
+        this.update(this.value, true);\r
+    },\r
+\r
+    <div id="method-Ext.DatePicker-setValue"></div>/**\r
+     * Sets the value of the date field\r
+     * @param {Date} value The date to set\r
+     */\r
+    setValue : function(value){\r
+        var old = this.value;\r
+        this.value = value.clearTime(true);\r
+        if(this.el){\r
+            this.update(this.value);\r
+        }\r
+    },\r
+\r
+    <div id="method-Ext.DatePicker-getValue"></div>/**\r
+     * Gets the current selected value of the date field\r
+     * @return {Date} The selected date\r
+     */\r
+    getValue : function(){\r
+        return this.value;\r
+    },\r
+\r
+    // private\r
+    focus : function(){\r
+        if(this.el){\r
+            this.update(this.activeDate);\r
+        }\r
+    },\r
+    \r
+    // private\r
+    onEnable: function(initial){\r
+        Ext.DatePicker.superclass.onEnable.call(this);    \r
+        this.doDisabled(false);\r
+        this.update(initial ? this.value : this.activeDate);\r
+        if(Ext.isIE){\r
+            this.el.repaint();\r
+        }\r
+        \r
+    },\r
+    \r
+    // private\r
+    onDisable : function(){\r
+        Ext.DatePicker.superclass.onDisable.call(this);   \r
+        this.doDisabled(true);\r
+        if(Ext.isIE && !Ext.isIE8){\r
+            /* Really strange problem in IE6/7, when disabled, have to explicitly\r
+             * repaint each of the nodes to get them to display correctly, simply\r
+             * calling repaint on the main element doesn't appear to be enough.\r
+             */\r
+             Ext.each([].concat(this.textNodes, this.el.query('th span')), function(el){\r
+                 Ext.fly(el).repaint();\r
+             });\r
+        }\r
+    },\r
+    \r
+    // private\r
+    doDisabled : function(disabled){\r
+        this.keyNav.setDisabled(disabled);\r
+        this.prevRepeater.setDisabled(disabled);\r
+        this.nextRepeater.setDisabled(disabled);\r
+        if(this.showToday){\r
+            this.todayKeyListener.setDisabled(disabled);\r
+            this.todayBtn.setDisabled(disabled);\r
+        }\r
+    },\r
+\r
+    // private\r
+    onRender : function(container, position){\r
+        var m = [\r
+             '<table cellspacing="0">',\r
+                '<tr><td class="x-date-left"><a href="#" title="', this.prevText ,'">&#160;</a></td><td class="x-date-middle" align="center"></td><td class="x-date-right"><a href="#" title="', this.nextText ,'">&#160;</a></td></tr>',\r
+                '<tr><td colspan="3"><table class="x-date-inner" cellspacing="0"><thead><tr>'],\r
+                dn = this.dayNames,\r
+                i;\r
+        for(i = 0; i < 7; i++){\r
+            var d = this.startDay+i;\r
+            if(d > 6){\r
+                d = d-7;\r
+            }\r
+            m.push('<th><span>', dn[d].substr(0,1), '</span></th>');\r
+        }\r
+        m[m.length] = '</tr></thead><tbody><tr>';\r
+        for(i = 0; i < 42; i++) {\r
+            if(i % 7 === 0 && i !== 0){\r
+                m[m.length] = '</tr><tr>';\r
+            }\r
+            m[m.length] = '<td><a href="#" hidefocus="on" class="x-date-date" tabIndex="1"><em><span></span></em></a></td>';\r
+        }\r
+        m.push('</tr></tbody></table></td></tr>',\r
+                this.showToday ? '<tr><td colspan="3" class="x-date-bottom" align="center"></td></tr>' : '',\r
+                '</table><div class="x-date-mp"></div>');\r
+\r
+        var el = document.createElement('div');\r
+        el.className = 'x-date-picker';\r
+        el.innerHTML = m.join('');\r
+\r
+        container.dom.insertBefore(el, position);\r
+\r
+        this.el = Ext.get(el);\r
+        this.eventEl = Ext.get(el.firstChild);\r
+\r
+        this.prevRepeater = new Ext.util.ClickRepeater(this.el.child('td.x-date-left a'), {\r
+            handler: this.showPrevMonth,\r
+            scope: this,\r
+            preventDefault:true,\r
+            stopDefault:true\r
+        });\r
+\r
+        this.nextRepeater = new Ext.util.ClickRepeater(this.el.child('td.x-date-right a'), {\r
+            handler: this.showNextMonth,\r
+            scope: this,\r
+            preventDefault:true,\r
+            stopDefault:true\r
+        });\r
+\r
+        this.monthPicker = this.el.down('div.x-date-mp');\r
+        this.monthPicker.enableDisplayMode('block');\r
+\r
+        this.keyNav = new Ext.KeyNav(this.eventEl, {\r
+            'left' : function(e){\r
+                if(e.ctrlKey){\r
+                    this.showPrevMonth();\r
+                }else{\r
+                    this.update(this.activeDate.add('d', -1));    \r
+                }\r
+            },\r
+\r
+            'right' : function(e){\r
+                if(e.ctrlKey){\r
+                    this.showNextMonth();\r
+                }else{\r
+                    this.update(this.activeDate.add('d', 1));    \r
+                }\r
+            },\r
+\r
+            'up' : function(e){\r
+                if(e.ctrlKey){\r
+                    this.showNextYear();\r
+                }else{\r
+                    this.update(this.activeDate.add('d', -7));\r
+                }\r
+            },\r
+\r
+            'down' : function(e){\r
+                if(e.ctrlKey){\r
+                    this.showPrevYear();\r
+                }else{\r
+                    this.update(this.activeDate.add('d', 7));\r
+                }\r
+            },\r
+\r
+            'pageUp' : function(e){\r
+                this.showNextMonth();\r
+            },\r
+\r
+            'pageDown' : function(e){\r
+                this.showPrevMonth();\r
+            },\r
+\r
+            'enter' : function(e){\r
+                e.stopPropagation();\r
+                return true;\r
+            },\r
+\r
+            scope : this\r
+        });\r
+\r
+        this.el.unselectable();\r
+\r
+        this.cells = this.el.select('table.x-date-inner tbody td');\r
+        this.textNodes = this.el.query('table.x-date-inner tbody span');\r
+\r
+        this.mbtn = new Ext.Button({\r
+            text: '&#160;',\r
+            tooltip: this.monthYearText,\r
+            renderTo: this.el.child('td.x-date-middle', true)\r
+        });\r
+        this.mbtn.el.child('em').addClass('x-btn-arrow');\r
+\r
+        if(this.showToday){\r
+            this.todayKeyListener = this.eventEl.addKeyListener(Ext.EventObject.SPACE, this.selectToday,  this);\r
+            var today = (new Date()).dateFormat(this.format);\r
+            this.todayBtn = new Ext.Button({\r
+                renderTo: this.el.child('td.x-date-bottom', true),\r
+                text: String.format(this.todayText, today),\r
+                tooltip: String.format(this.todayTip, today),\r
+                handler: this.selectToday,\r
+                scope: this\r
+            });\r
+        }\r
+        this.mon(this.eventEl, 'mousewheel', this.handleMouseWheel, this);\r
+        this.mon(this.eventEl, 'click', this.handleDateClick,  this, {delegate: 'a.x-date-date'});\r
+        this.mon(this.mbtn, 'click', this.showMonthPicker, this);\r
+        this.onEnable(true);\r
+    },\r
+\r
+    // private\r
+    createMonthPicker : function(){\r
+        if(!this.monthPicker.dom.firstChild){\r
+            var buf = ['<table border="0" cellspacing="0">'];\r
+            for(var i = 0; i < 6; i++){\r
+                buf.push(\r
+                    '<tr><td class="x-date-mp-month"><a href="#">', Date.getShortMonthName(i), '</a></td>',\r
+                    '<td class="x-date-mp-month x-date-mp-sep"><a href="#">', Date.getShortMonthName(i + 6), '</a></td>',\r
+                    i === 0 ?\r
+                    '<td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-prev"></a></td><td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-next"></a></td></tr>' :\r
+                    '<td class="x-date-mp-year"><a href="#"></a></td><td class="x-date-mp-year"><a href="#"></a></td></tr>'\r
+                );\r
+            }\r
+            buf.push(\r
+                '<tr class="x-date-mp-btns"><td colspan="4"><button type="button" class="x-date-mp-ok">',\r
+                    this.okText,\r
+                    '</button><button type="button" class="x-date-mp-cancel">',\r
+                    this.cancelText,\r
+                    '</button></td></tr>',\r
+                '</table>'\r
+            );\r
+            this.monthPicker.update(buf.join(''));\r
+\r
+            this.mon(this.monthPicker, 'click', this.onMonthClick, this);\r
+            this.mon(this.monthPicker, 'dblclick', this.onMonthDblClick, this);\r
+\r
+            this.mpMonths = this.monthPicker.select('td.x-date-mp-month');\r
+            this.mpYears = this.monthPicker.select('td.x-date-mp-year');\r
+\r
+            this.mpMonths.each(function(m, a, i){\r
+                i += 1;\r
+                if((i%2) === 0){\r
+                    m.dom.xmonth = 5 + Math.round(i * 0.5);\r
+                }else{\r
+                    m.dom.xmonth = Math.round((i-1) * 0.5);\r
+                }\r
+            });\r
+        }\r
+    },\r
+\r
+    // private\r
+    showMonthPicker : function(){\r
+        if(!this.disabled){\r
+            this.createMonthPicker();\r
+            var size = this.el.getSize();\r
+            this.monthPicker.setSize(size);\r
+            this.monthPicker.child('table').setSize(size);\r
+\r
+            this.mpSelMonth = (this.activeDate || this.value).getMonth();\r
+            this.updateMPMonth(this.mpSelMonth);\r
+            this.mpSelYear = (this.activeDate || this.value).getFullYear();\r
+            this.updateMPYear(this.mpSelYear);\r
+\r
+            this.monthPicker.slideIn('t', {duration:0.2});\r
+        }\r
+    },\r
+\r
+    // private\r
+    updateMPYear : function(y){\r
+        this.mpyear = y;\r
+        var ys = this.mpYears.elements;\r
+        for(var i = 1; i <= 10; i++){\r
+            var td = ys[i-1], y2;\r
+            if((i%2) === 0){\r
+                y2 = y + Math.round(i * 0.5);\r
+                td.firstChild.innerHTML = y2;\r
+                td.xyear = y2;\r
+            }else{\r
+                y2 = y - (5-Math.round(i * 0.5));\r
+                td.firstChild.innerHTML = y2;\r
+                td.xyear = y2;\r
+            }\r
+            this.mpYears.item(i-1)[y2 == this.mpSelYear ? 'addClass' : 'removeClass']('x-date-mp-sel');\r
+        }\r
+    },\r
+\r
+    // private\r
+    updateMPMonth : function(sm){\r
+        this.mpMonths.each(function(m, a, i){\r
+            m[m.dom.xmonth == sm ? 'addClass' : 'removeClass']('x-date-mp-sel');\r
+        });\r
+    },\r
+\r
+    // private\r
+    selectMPMonth : function(m){\r
+\r
+    },\r
+\r
+    // private\r
+    onMonthClick : function(e, t){\r
+        e.stopEvent();\r
+        var el = new Ext.Element(t), pn;\r
+        if(el.is('button.x-date-mp-cancel')){\r
+            this.hideMonthPicker();\r
+        }\r
+        else if(el.is('button.x-date-mp-ok')){\r
+            var d = new Date(this.mpSelYear, this.mpSelMonth, (this.activeDate || this.value).getDate());\r
+            if(d.getMonth() != this.mpSelMonth){\r
+                // 'fix' the JS rolling date conversion if needed\r
+                d = new Date(this.mpSelYear, this.mpSelMonth, 1).getLastDateOfMonth();\r
+            }\r
+            this.update(d);\r
+            this.hideMonthPicker();\r
+        }\r
+        else if((pn = el.up('td.x-date-mp-month', 2))){\r
+            this.mpMonths.removeClass('x-date-mp-sel');\r
+            pn.addClass('x-date-mp-sel');\r
+            this.mpSelMonth = pn.dom.xmonth;\r
+        }\r
+        else if((pn = el.up('td.x-date-mp-year', 2))){\r
+            this.mpYears.removeClass('x-date-mp-sel');\r
+            pn.addClass('x-date-mp-sel');\r
+            this.mpSelYear = pn.dom.xyear;\r
+        }\r
+        else if(el.is('a.x-date-mp-prev')){\r
+            this.updateMPYear(this.mpyear-10);\r
+        }\r
+        else if(el.is('a.x-date-mp-next')){\r
+            this.updateMPYear(this.mpyear+10);\r
+        }\r
+    },\r
+\r
+    // private\r
+    onMonthDblClick : function(e, t){\r
+        e.stopEvent();\r
+        var el = new Ext.Element(t), pn;\r
+        if((pn = el.up('td.x-date-mp-month', 2))){\r
+            this.update(new Date(this.mpSelYear, pn.dom.xmonth, (this.activeDate || this.value).getDate()));\r
+            this.hideMonthPicker();\r
+        }\r
+        else if((pn = el.up('td.x-date-mp-year', 2))){\r
+            this.update(new Date(pn.dom.xyear, this.mpSelMonth, (this.activeDate || this.value).getDate()));\r
+            this.hideMonthPicker();\r
+        }\r
+    },\r
+\r
+    // private\r
+    hideMonthPicker : function(disableAnim){\r
+        if(this.monthPicker){\r
+            if(disableAnim === true){\r
+                this.monthPicker.hide();\r
+            }else{\r
+                this.monthPicker.slideOut('t', {duration:0.2});\r
+            }\r
+        }\r
+    },\r
+\r
+    // private\r
+    showPrevMonth : function(e){\r
+        this.update(this.activeDate.add('mo', -1));\r
+    },\r
+\r
+    // private\r
+    showNextMonth : function(e){\r
+        this.update(this.activeDate.add('mo', 1));\r
+    },\r
+\r
+    // private\r
+    showPrevYear : function(){\r
+        this.update(this.activeDate.add('y', -1));\r
+    },\r
+\r
+    // private\r
+    showNextYear : function(){\r
+        this.update(this.activeDate.add('y', 1));\r
+    },\r
+\r
+    // private\r
+    handleMouseWheel : function(e){\r
+        e.stopEvent();\r
+        if(!this.disabled){\r
+            var delta = e.getWheelDelta();\r
+            if(delta > 0){\r
+                this.showPrevMonth();\r
+            } else if(delta < 0){\r
+                this.showNextMonth();\r
+            }\r
+        }\r
+    },\r
+\r
+    // private\r
+    handleDateClick : function(e, t){\r
+        e.stopEvent();\r
+        if(!this.disabled && t.dateValue && !Ext.fly(t.parentNode).hasClass('x-date-disabled')){\r
+            this.setValue(new Date(t.dateValue));\r
+            this.fireEvent('select', this, this.value);\r
+        }\r
+    },\r
+\r
+    // private\r
+    selectToday : function(){\r
+        if(this.todayBtn && !this.todayBtn.disabled){\r
+            this.setValue(new Date().clearTime());\r
+            this.fireEvent('select', this, this.value);\r
+        }\r
+    },\r
+\r
+    // private\r
+    update : function(date, forceRefresh){\r
+        var vd = this.activeDate, vis = this.isVisible();\r
+        this.activeDate = date;\r
+        if(!forceRefresh && vd && this.el){\r
+            var t = date.getTime();\r
+            if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){\r
+                this.cells.removeClass('x-date-selected');\r
+                this.cells.each(function(c){\r
+                   if(c.dom.firstChild.dateValue == t){\r
+                       c.addClass('x-date-selected');\r
+                       if(vis){\r
+                           Ext.fly(c.dom.firstChild).focus(50);\r
+                       }\r
+                       return false;\r
+                   }\r
+                });\r
+                return;\r
+            }\r
+        }\r
+        var days = date.getDaysInMonth();\r
+        var firstOfMonth = date.getFirstDateOfMonth();\r
+        var startingPos = firstOfMonth.getDay()-this.startDay;\r
+\r
+        if(startingPos <= this.startDay){\r
+            startingPos += 7;\r
+        }\r
+\r
+        var pm = date.add('mo', -1);\r
+        var prevStart = pm.getDaysInMonth()-startingPos;\r
+\r
+        var cells = this.cells.elements;\r
+        var textEls = this.textNodes;\r
+        days += startingPos;\r
+\r
+        // convert everything to numbers so it's fast\r
+        var day = 86400000;\r
+        var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();\r
+        var today = new Date().clearTime().getTime();\r
+        var sel = date.clearTime().getTime();\r
+        var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;\r
+        var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;\r
+        var ddMatch = this.disabledDatesRE;\r
+        var ddText = this.disabledDatesText;\r
+        var ddays = this.disabledDays ? this.disabledDays.join('') : false;\r
+        var ddaysText = this.disabledDaysText;\r
+        var format = this.format;\r
+\r
+        if(this.showToday){\r
+            var td = new Date().clearTime();\r
+            var disable = (td < min || td > max ||\r
+                (ddMatch && format && ddMatch.test(td.dateFormat(format))) ||\r
+                (ddays && ddays.indexOf(td.getDay()) != -1));\r
+\r
+            if(!this.disabled){\r
+                this.todayBtn.setDisabled(disable);\r
+                this.todayKeyListener[disable ? 'disable' : 'enable']();\r
+            }\r
+        }\r
+\r
+        var setCellClass = function(cal, cell){\r
+            cell.title = '';\r
+            var t = d.getTime();\r
+            cell.firstChild.dateValue = t;\r
+            if(t == today){\r
+                cell.className += ' x-date-today';\r
+                cell.title = cal.todayText;\r
+            }\r
+            if(t == sel){\r
+                cell.className += ' x-date-selected';\r
+                if(vis){\r
+                    Ext.fly(cell.firstChild).focus(50);\r
+                }\r
+            }\r
+            // disabling\r
+            if(t < min) {\r
+                cell.className = ' x-date-disabled';\r
+                cell.title = cal.minText;\r
+                return;\r
+            }\r
+            if(t > max) {\r
+                cell.className = ' x-date-disabled';\r
+                cell.title = cal.maxText;\r
+                return;\r
+            }\r
+            if(ddays){\r
+                if(ddays.indexOf(d.getDay()) != -1){\r
+                    cell.title = ddaysText;\r
+                    cell.className = ' x-date-disabled';\r
+                }\r
+            }\r
+            if(ddMatch && format){\r
+                var fvalue = d.dateFormat(format);\r
+                if(ddMatch.test(fvalue)){\r
+                    cell.title = ddText.replace('%0', fvalue);\r
+                    cell.className = ' x-date-disabled';\r
+                }\r
+            }\r
+        };\r
+\r
+        var i = 0;\r
+        for(; i < startingPos; i++) {\r
+            textEls[i].innerHTML = (++prevStart);\r
+            d.setDate(d.getDate()+1);\r
+            cells[i].className = 'x-date-prevday';\r
+            setCellClass(this, cells[i]);\r
+        }\r
+        for(; i < days; i++){\r
+            var intDay = i - startingPos + 1;\r
+            textEls[i].innerHTML = (intDay);\r
+            d.setDate(d.getDate()+1);\r
+            cells[i].className = 'x-date-active';\r
+            setCellClass(this, cells[i]);\r
+        }\r
+        var extraDays = 0;\r
+        for(; i < 42; i++) {\r
+             textEls[i].innerHTML = (++extraDays);\r
+             d.setDate(d.getDate()+1);\r
+             cells[i].className = 'x-date-nextday';\r
+             setCellClass(this, cells[i]);\r
+        }\r
+\r
+        this.mbtn.setText(this.monthNames[date.getMonth()] + ' ' + date.getFullYear());\r
+\r
+        if(!this.internalRender){\r
+            var main = this.el.dom.firstChild;\r
+            var w = main.offsetWidth;\r
+            this.el.setWidth(w + this.el.getBorderWidth('lr'));\r
+            Ext.fly(main).setWidth(w);\r
+            this.internalRender = true;\r
+            // opera does not respect the auto grow header center column\r
+            // then, after it gets a width opera refuses to recalculate\r
+            // without a second pass\r
+            if(Ext.isOpera && !this.secondPass){\r
+                main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + 'px';\r
+                this.secondPass = true;\r
+                this.update.defer(10, this, [date]);\r
+            }\r
+        }\r
+    },\r
+\r
+    // private\r
+    beforeDestroy : function() {\r
+        if(this.rendered){\r
+            this.keyNav.disable();\r
+            this.keyNav = null;\r
+            Ext.destroy(\r
+                this.leftClickRpt,\r
+                this.rightClickRpt,\r
+                this.monthPicker,\r
+                this.eventEl,\r
+                this.mbtn,\r
+                this.todayBtn\r
+            );\r
+        }\r
+    }\r
+\r
+    <div id="cfg-Ext.DatePicker-autoEl"></div>/**\r
+     * @cfg {String} autoEl @hide\r
+     */\r
+});\r
+\r
+Ext.reg('datepicker', Ext.DatePicker);\r
+</pre>    \r
+</body>\r
+</html>
\ No newline at end of file