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.DatePicker"></div>/**
\r
15 * @class Ext.DatePicker
\r
16 * @extends Ext.Component
\r
17 * Simple date picker class.
\r
19 * Create a new DatePicker
\r
20 * @param {Object} config The config object
\r
23 Ext.DatePicker = Ext.extend(Ext.BoxComponent, {
\r
24 <div id="cfg-Ext.DatePicker-todayText"></div>/**
\r
25 * @cfg {String} todayText
\r
26 * The text to display on the button that selects the current date (defaults to <tt>'Today'</tt>)
\r
28 todayText : 'Today',
\r
29 <div id="cfg-Ext.DatePicker-okText"></div>/**
\r
30 * @cfg {String} okText
\r
31 * The text to display on the ok button (defaults to <tt>' OK '</tt> to give the user extra clicking room)
\r
33 okText : ' OK ',
\r
34 <div id="cfg-Ext.DatePicker-cancelText"></div>/**
\r
35 * @cfg {String} cancelText
\r
36 * The text to display on the cancel button (defaults to <tt>'Cancel'</tt>)
\r
38 cancelText : 'Cancel',
\r
39 <div id="cfg-Ext.DatePicker-handler"></div>/**
\r
40 * @cfg {Function} handler
\r
41 * Optional. A function that will handle the select event of this picker.
\r
42 * The handler is passed the following parameters:<div class="mdetail-params"><ul>
\r
43 * <li><code>picker</code> : DatePicker<div class="sub-desc">The Ext.DatePicker.</div></li>
\r
44 * <li><code>date</code> : Date<div class="sub-desc">The selected date.</div></li>
\r
47 <div id="cfg-Ext.DatePicker-scope"></div>/**
\r
48 * @cfg {Object} scope
\r
49 * The scope (<tt><b>this</b></tt> reference) in which the <code>{@link #handler}</code>
\r
50 * function will be called. Defaults to this DatePicker instance.
\r
52 <div id="cfg-Ext.DatePicker-todayTip"></div>/**
\r
53 * @cfg {String} todayTip
\r
54 * The tooltip to display for the button that selects the current date (defaults to <tt>'{current date} (Spacebar)'</tt>)
\r
56 todayTip : '{0} (Spacebar)',
\r
57 <div id="cfg-Ext.DatePicker-minText"></div>/**
\r
58 * @cfg {String} minText
\r
59 * The error text to display if the minDate validation fails (defaults to <tt>'This date is before the minimum date'</tt>)
\r
61 minText : 'This date is before the minimum date',
\r
62 <div id="cfg-Ext.DatePicker-maxText"></div>/**
\r
63 * @cfg {String} maxText
\r
64 * The error text to display if the maxDate validation fails (defaults to <tt>'This date is after the maximum date'</tt>)
\r
66 maxText : 'This date is after the maximum date',
\r
67 <div id="cfg-Ext.DatePicker-format"></div>/**
\r
68 * @cfg {String} format
\r
69 * The default date format string which can be overriden for localization support. The format must be
\r
70 * valid according to {@link Date#parseDate} (defaults to <tt>'m/d/y'</tt>).
\r
73 <div id="cfg-Ext.DatePicker-disabledDaysText"></div>/**
\r
74 * @cfg {String} disabledDaysText
\r
75 * The tooltip to display when the date falls on a disabled day (defaults to <tt>'Disabled'</tt>)
\r
77 disabledDaysText : 'Disabled',
\r
78 <div id="cfg-Ext.DatePicker-disabledDatesText"></div>/**
\r
79 * @cfg {String} disabledDatesText
\r
80 * The tooltip text to display when the date falls on a disabled date (defaults to <tt>'Disabled'</tt>)
\r
82 disabledDatesText : 'Disabled',
\r
83 <div id="cfg-Ext.DatePicker-monthNames"></div>/**
\r
84 * @cfg {Array} monthNames
\r
85 * An array of textual month names which can be overriden for localization support (defaults to Date.monthNames)
\r
87 monthNames : Date.monthNames,
\r
88 <div id="cfg-Ext.DatePicker-dayNames"></div>/**
\r
89 * @cfg {Array} dayNames
\r
90 * An array of textual day names which can be overriden for localization support (defaults to Date.dayNames)
\r
92 dayNames : Date.dayNames,
\r
93 <div id="cfg-Ext.DatePicker-nextText"></div>/**
\r
94 * @cfg {String} nextText
\r
95 * The next month navigation button tooltip (defaults to <tt>'Next Month (Control+Right)'</tt>)
\r
97 nextText : 'Next Month (Control+Right)',
\r
98 <div id="cfg-Ext.DatePicker-prevText"></div>/**
\r
99 * @cfg {String} prevText
\r
100 * The previous month navigation button tooltip (defaults to <tt>'Previous Month (Control+Left)'</tt>)
\r
102 prevText : 'Previous Month (Control+Left)',
\r
103 <div id="cfg-Ext.DatePicker-monthYearText"></div>/**
\r
104 * @cfg {String} monthYearText
\r
105 * The header month selector tooltip (defaults to <tt>'Choose a month (Control+Up/Down to move years)'</tt>)
\r
107 monthYearText : 'Choose a month (Control+Up/Down to move years)',
\r
108 <div id="cfg-Ext.DatePicker-startDay"></div>/**
\r
109 * @cfg {Number} startDay
\r
110 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
\r
113 <div id="cfg-Ext.DatePicker-showToday"></div>/**
\r
114 * @cfg {Boolean} showToday
\r
115 * False to hide the footer area containing the Today button and disable the keyboard handler for spacebar
\r
116 * that selects the current date (defaults to <tt>true</tt>).
\r
119 <div id="cfg-Ext.DatePicker-minDate"></div>/**
\r
120 * @cfg {Date} minDate
\r
121 * Minimum allowable date (JavaScript date object, defaults to null)
\r
123 <div id="cfg-Ext.DatePicker-maxDate"></div>/**
\r
124 * @cfg {Date} maxDate
\r
125 * Maximum allowable date (JavaScript date object, defaults to null)
\r
127 <div id="cfg-Ext.DatePicker-disabledDays"></div>/**
\r
128 * @cfg {Array} disabledDays
\r
129 * An array of days to disable, 0-based. For example, [0, 6] disables Sunday and Saturday (defaults to null).
\r
131 <div id="cfg-Ext.DatePicker-disabledDatesRE"></div>/**
\r
132 * @cfg {RegExp} disabledDatesRE
\r
133 * JavaScript regular expression used to disable a pattern of dates (defaults to null). The {@link #disabledDates}
\r
134 * config will generate this regex internally, but if you specify disabledDatesRE it will take precedence over the
\r
135 * disabledDates value.
\r
137 <div id="cfg-Ext.DatePicker-disabledDates"></div>/**
\r
138 * @cfg {Array} disabledDates
\r
139 * An array of 'dates' to disable, as strings. These strings will be used to build a dynamic regular
\r
140 * expression so they are very powerful. Some examples:
\r
142 * <li>['03/08/2003', '09/16/2003'] would disable those exact dates</li>
\r
143 * <li>['03/08', '09/16'] would disable those days for every year</li>
\r
144 * <li>['^03/08'] would only match the beginning (useful if you are using short years)</li>
\r
145 * <li>['03/../2006'] would disable every day in March 2006</li>
\r
146 * <li>['^03'] would disable every day in every March</li>
\r
148 * Note that the format of the dates included in the array should exactly match the {@link #format} config.
\r
149 * In order to support regular expressions, if you are using a date format that has '.' in it, you will have to
\r
150 * escape the dot when restricting dates. For example: ['03\\.08\\.03'].
\r
154 initComponent : function(){
\r
155 Ext.DatePicker.superclass.initComponent.call(this);
\r
157 this.value = this.value ?
\r
158 this.value.clearTime(true) : new Date().clearTime();
\r
161 <div id="event-Ext.DatePicker-select"></div>/**
\r
163 * Fires when a date is selected
\r
164 * @param {DatePicker} this
\r
165 * @param {Date} date The selected date
\r
171 this.on('select', this.handler, this.scope || this);
\r
174 this.initDisabledDays();
\r
178 initDisabledDays : function(){
\r
179 if(!this.disabledDatesRE && this.disabledDates){
\r
180 var dd = this.disabledDates,
\r
181 len = dd.length - 1,
\r
184 Ext.each(dd, function(d, i){
\r
185 re += Ext.isDate(d) ? '^' + Ext.escapeRe(d.dateFormat(this.format)) + '$' : dd[i];
\r
190 this.disabledDatesRE = new RegExp(re + ')');
\r
194 <div id="method-Ext.DatePicker-setDisabledDates"></div>/**
\r
195 * Replaces any existing disabled dates with new values and refreshes the DatePicker.
\r
196 * @param {Array/RegExp} disabledDates An array of date strings (see the {@link #disabledDates} config
\r
197 * for details on supported values), or a JavaScript regular expression used to disable a pattern of dates.
\r
199 setDisabledDates : function(dd){
\r
200 if(Ext.isArray(dd)){
\r
201 this.disabledDates = dd;
\r
202 this.disabledDatesRE = null;
\r
204 this.disabledDatesRE = dd;
\r
206 this.initDisabledDays();
\r
207 this.update(this.value, true);
\r
210 <div id="method-Ext.DatePicker-setDisabledDays"></div>/**
\r
211 * Replaces any existing disabled days (by index, 0-6) with new values and refreshes the DatePicker.
\r
212 * @param {Array} disabledDays An array of disabled day indexes. See the {@link #disabledDays} config
\r
213 * for details on supported values.
\r
215 setDisabledDays : function(dd){
\r
216 this.disabledDays = dd;
\r
217 this.update(this.value, true);
\r
220 <div id="method-Ext.DatePicker-setMinDate"></div>/**
\r
221 * Replaces any existing {@link #minDate} with the new value and refreshes the DatePicker.
\r
222 * @param {Date} value The minimum date that can be selected
\r
224 setMinDate : function(dt){
\r
226 this.update(this.value, true);
\r
229 <div id="method-Ext.DatePicker-setMaxDate"></div>/**
\r
230 * Replaces any existing {@link #maxDate} with the new value and refreshes the DatePicker.
\r
231 * @param {Date} value The maximum date that can be selected
\r
233 setMaxDate : function(dt){
\r
235 this.update(this.value, true);
\r
238 <div id="method-Ext.DatePicker-setValue"></div>/**
\r
239 * Sets the value of the date field
\r
240 * @param {Date} value The date to set
\r
242 setValue : function(value){
\r
243 this.value = value.clearTime(true);
\r
244 this.update(this.value);
\r
247 <div id="method-Ext.DatePicker-getValue"></div>/**
\r
248 * Gets the current selected value of the date field
\r
249 * @return {Date} The selected date
\r
251 getValue : function(){
\r
256 focus : function(){
\r
257 this.update(this.activeDate);
\r
261 onEnable: function(initial){
\r
262 Ext.DatePicker.superclass.onEnable.call(this);
\r
263 this.doDisabled(false);
\r
264 this.update(initial ? this.value : this.activeDate);
\r
272 onDisable : function(){
\r
273 Ext.DatePicker.superclass.onDisable.call(this);
\r
274 this.doDisabled(true);
\r
275 if(Ext.isIE && !Ext.isIE8){
\r
276 /* Really strange problem in IE6/7, when disabled, have to explicitly
\r
277 * repaint each of the nodes to get them to display correctly, simply
\r
278 * calling repaint on the main element doesn't appear to be enough.
\r
280 Ext.each([].concat(this.textNodes, this.el.query('th span')), function(el){
\r
281 Ext.fly(el).repaint();
\r
287 doDisabled : function(disabled){
\r
288 this.keyNav.setDisabled(disabled);
\r
289 this.prevRepeater.setDisabled(disabled);
\r
290 this.nextRepeater.setDisabled(disabled);
\r
291 if(this.showToday){
\r
292 this.todayKeyListener.setDisabled(disabled);
\r
293 this.todayBtn.setDisabled(disabled);
\r
298 onRender : function(container, position){
\r
300 '<table cellspacing="0">',
\r
301 '<tr><td class="x-date-left"><a href="#" title="', this.prevText ,'"> </a></td><td class="x-date-middle" align="center"></td><td class="x-date-right"><a href="#" title="', this.nextText ,'"> </a></td></tr>',
\r
302 '<tr><td colspan="3"><table class="x-date-inner" cellspacing="0"><thead><tr>'],
\r
303 dn = this.dayNames,
\r
305 for(i = 0; i < 7; i++){
\r
306 var d = this.startDay+i;
\r
310 m.push('<th><span>', dn[d].substr(0,1), '</span></th>');
\r
312 m[m.length] = '</tr></thead><tbody><tr>';
\r
313 for(i = 0; i < 42; i++) {
\r
314 if(i % 7 === 0 && i !== 0){
\r
315 m[m.length] = '</tr><tr>';
\r
317 m[m.length] = '<td><a href="#" hidefocus="on" class="x-date-date" tabIndex="1"><em><span></span></em></a></td>';
\r
319 m.push('</tr></tbody></table></td></tr>',
\r
320 this.showToday ? '<tr><td colspan="3" class="x-date-bottom" align="center"></td></tr>' : '',
\r
321 '</table><div class="x-date-mp"></div>');
\r
323 var el = document.createElement('div');
\r
324 el.className = 'x-date-picker';
\r
325 el.innerHTML = m.join('');
\r
327 container.dom.insertBefore(el, position);
\r
329 this.el = Ext.get(el);
\r
330 this.eventEl = Ext.get(el.firstChild);
\r
332 this.prevRepeater = new Ext.util.ClickRepeater(this.el.child('td.x-date-left a'), {
\r
333 handler: this.showPrevMonth,
\r
335 preventDefault:true,
\r
339 this.nextRepeater = new Ext.util.ClickRepeater(this.el.child('td.x-date-right a'), {
\r
340 handler: this.showNextMonth,
\r
342 preventDefault:true,
\r
346 this.monthPicker = this.el.down('div.x-date-mp');
\r
347 this.monthPicker.enableDisplayMode('block');
\r
349 this.keyNav = new Ext.KeyNav(this.eventEl, {
\r
350 'left' : function(e){
\r
352 this.showPrevMonth();
\r
354 this.update(this.activeDate.add('d', -1));
\r
358 'right' : function(e){
\r
360 this.showNextMonth();
\r
362 this.update(this.activeDate.add('d', 1));
\r
366 'up' : function(e){
\r
368 this.showNextYear();
\r
370 this.update(this.activeDate.add('d', -7));
\r
374 'down' : function(e){
\r
376 this.showPrevYear();
\r
378 this.update(this.activeDate.add('d', 7));
\r
382 'pageUp' : function(e){
\r
383 this.showNextMonth();
\r
386 'pageDown' : function(e){
\r
387 this.showPrevMonth();
\r
390 'enter' : function(e){
\r
391 e.stopPropagation();
\r
398 this.el.unselectable();
\r
400 this.cells = this.el.select('table.x-date-inner tbody td');
\r
401 this.textNodes = this.el.query('table.x-date-inner tbody span');
\r
403 this.mbtn = new Ext.Button({
\r
405 tooltip: this.monthYearText,
\r
406 renderTo: this.el.child('td.x-date-middle', true)
\r
408 this.mbtn.el.child('em').addClass('x-btn-arrow');
\r
410 if(this.showToday){
\r
411 this.todayKeyListener = this.eventEl.addKeyListener(Ext.EventObject.SPACE, this.selectToday, this);
\r
412 var today = (new Date()).dateFormat(this.format);
\r
413 this.todayBtn = new Ext.Button({
\r
414 renderTo: this.el.child('td.x-date-bottom', true),
\r
415 text: String.format(this.todayText, today),
\r
416 tooltip: String.format(this.todayTip, today),
\r
417 handler: this.selectToday,
\r
421 this.mon(this.eventEl, 'mousewheel', this.handleMouseWheel, this);
\r
422 this.mon(this.eventEl, 'click', this.handleDateClick, this, {delegate: 'a.x-date-date'});
\r
423 this.mon(this.mbtn, 'click', this.showMonthPicker, this);
\r
424 this.onEnable(true);
\r
428 createMonthPicker : function(){
\r
429 if(!this.monthPicker.dom.firstChild){
\r
430 var buf = ['<table border="0" cellspacing="0">'];
\r
431 for(var i = 0; i < 6; i++){
\r
433 '<tr><td class="x-date-mp-month"><a href="#">', Date.getShortMonthName(i), '</a></td>',
\r
434 '<td class="x-date-mp-month x-date-mp-sep"><a href="#">', Date.getShortMonthName(i + 6), '</a></td>',
\r
436 '<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
437 '<td class="x-date-mp-year"><a href="#"></a></td><td class="x-date-mp-year"><a href="#"></a></td></tr>'
\r
441 '<tr class="x-date-mp-btns"><td colspan="4"><button type="button" class="x-date-mp-ok">',
\r
443 '</button><button type="button" class="x-date-mp-cancel">',
\r
445 '</button></td></tr>',
\r
448 this.monthPicker.update(buf.join(''));
\r
450 this.mon(this.monthPicker, 'click', this.onMonthClick, this);
\r
451 this.mon(this.monthPicker, 'dblclick', this.onMonthDblClick, this);
\r
453 this.mpMonths = this.monthPicker.select('td.x-date-mp-month');
\r
454 this.mpYears = this.monthPicker.select('td.x-date-mp-year');
\r
456 this.mpMonths.each(function(m, a, i){
\r
459 m.dom.xmonth = 5 + Math.round(i * 0.5);
\r
461 m.dom.xmonth = Math.round((i-1) * 0.5);
\r
468 showMonthPicker : function(){
\r
469 if(!this.disabled){
\r
470 this.createMonthPicker();
\r
471 var size = this.el.getSize();
\r
472 this.monthPicker.setSize(size);
\r
473 this.monthPicker.child('table').setSize(size);
\r
475 this.mpSelMonth = (this.activeDate || this.value).getMonth();
\r
476 this.updateMPMonth(this.mpSelMonth);
\r
477 this.mpSelYear = (this.activeDate || this.value).getFullYear();
\r
478 this.updateMPYear(this.mpSelYear);
\r
480 this.monthPicker.slideIn('t', {duration:0.2});
\r
485 updateMPYear : function(y){
\r
487 var ys = this.mpYears.elements;
\r
488 for(var i = 1; i <= 10; i++){
\r
489 var td = ys[i-1], y2;
\r
491 y2 = y + Math.round(i * 0.5);
\r
492 td.firstChild.innerHTML = y2;
\r
495 y2 = y - (5-Math.round(i * 0.5));
\r
496 td.firstChild.innerHTML = y2;
\r
499 this.mpYears.item(i-1)[y2 == this.mpSelYear ? 'addClass' : 'removeClass']('x-date-mp-sel');
\r
504 updateMPMonth : function(sm){
\r
505 this.mpMonths.each(function(m, a, i){
\r
506 m[m.dom.xmonth == sm ? 'addClass' : 'removeClass']('x-date-mp-sel');
\r
511 selectMPMonth : function(m){
\r
516 onMonthClick : function(e, t){
\r
518 var el = new Ext.Element(t), pn;
\r
519 if(el.is('button.x-date-mp-cancel')){
\r
520 this.hideMonthPicker();
\r
522 else if(el.is('button.x-date-mp-ok')){
\r
523 var d = new Date(this.mpSelYear, this.mpSelMonth, (this.activeDate || this.value).getDate());
\r
524 if(d.getMonth() != this.mpSelMonth){
\r
525 // 'fix' the JS rolling date conversion if needed
\r
526 d = new Date(this.mpSelYear, this.mpSelMonth, 1).getLastDateOfMonth();
\r
529 this.hideMonthPicker();
\r
531 else if((pn = el.up('td.x-date-mp-month', 2))){
\r
532 this.mpMonths.removeClass('x-date-mp-sel');
\r
533 pn.addClass('x-date-mp-sel');
\r
534 this.mpSelMonth = pn.dom.xmonth;
\r
536 else if((pn = el.up('td.x-date-mp-year', 2))){
\r
537 this.mpYears.removeClass('x-date-mp-sel');
\r
538 pn.addClass('x-date-mp-sel');
\r
539 this.mpSelYear = pn.dom.xyear;
\r
541 else if(el.is('a.x-date-mp-prev')){
\r
542 this.updateMPYear(this.mpyear-10);
\r
544 else if(el.is('a.x-date-mp-next')){
\r
545 this.updateMPYear(this.mpyear+10);
\r
550 onMonthDblClick : function(e, t){
\r
552 var el = new Ext.Element(t), pn;
\r
553 if((pn = el.up('td.x-date-mp-month', 2))){
\r
554 this.update(new Date(this.mpSelYear, pn.dom.xmonth, (this.activeDate || this.value).getDate()));
\r
555 this.hideMonthPicker();
\r
557 else if((pn = el.up('td.x-date-mp-year', 2))){
\r
558 this.update(new Date(pn.dom.xyear, this.mpSelMonth, (this.activeDate || this.value).getDate()));
\r
559 this.hideMonthPicker();
\r
564 hideMonthPicker : function(disableAnim){
\r
565 if(this.monthPicker){
\r
566 if(disableAnim === true){
\r
567 this.monthPicker.hide();
\r
569 this.monthPicker.slideOut('t', {duration:0.2});
\r
575 showPrevMonth : function(e){
\r
576 this.update(this.activeDate.add('mo', -1));
\r
580 showNextMonth : function(e){
\r
581 this.update(this.activeDate.add('mo', 1));
\r
585 showPrevYear : function(){
\r
586 this.update(this.activeDate.add('y', -1));
\r
590 showNextYear : function(){
\r
591 this.update(this.activeDate.add('y', 1));
\r
595 handleMouseWheel : function(e){
\r
597 if(!this.disabled){
\r
598 var delta = e.getWheelDelta();
\r
600 this.showPrevMonth();
\r
601 } else if(delta < 0){
\r
602 this.showNextMonth();
\r
608 handleDateClick : function(e, t){
\r
610 if(!this.disabled && t.dateValue && !Ext.fly(t.parentNode).hasClass('x-date-disabled')){
\r
611 this.setValue(new Date(t.dateValue));
\r
612 this.fireEvent('select', this, this.value);
\r
617 selectToday : function(){
\r
618 if(this.todayBtn && !this.todayBtn.disabled){
\r
619 this.setValue(new Date().clearTime());
\r
620 this.fireEvent('select', this, this.value);
\r
625 update : function(date, forceRefresh){
\r
627 var vd = this.activeDate, vis = this.isVisible();
\r
628 this.activeDate = date;
\r
629 if(!forceRefresh && vd && this.el){
\r
630 var t = date.getTime();
\r
631 if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
\r
632 this.cells.removeClass('x-date-selected');
\r
633 this.cells.each(function(c){
\r
634 if(c.dom.firstChild.dateValue == t){
\r
635 c.addClass('x-date-selected');
\r
637 Ext.fly(c.dom.firstChild).focus(50);
\r
645 var days = date.getDaysInMonth(),
\r
646 firstOfMonth = date.getFirstDateOfMonth(),
\r
647 startingPos = firstOfMonth.getDay()-this.startDay;
\r
649 if(startingPos < 0){
\r
652 days += startingPos;
\r
654 var pm = date.add('mo', -1),
\r
655 prevStart = pm.getDaysInMonth()-startingPos,
\r
656 cells = this.cells.elements,
\r
657 textEls = this.textNodes,
\r
658 // convert everything to numbers so it's fast
\r
660 d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime(),
\r
661 today = new Date().clearTime().getTime(),
\r
662 sel = date.clearTime(true).getTime(),
\r
663 min = this.minDate ? this.minDate.clearTime(true) : Number.NEGATIVE_INFINITY,
\r
664 max = this.maxDate ? this.maxDate.clearTime(true) : Number.POSITIVE_INFINITY,
\r
665 ddMatch = this.disabledDatesRE,
\r
666 ddText = this.disabledDatesText,
\r
667 ddays = this.disabledDays ? this.disabledDays.join('') : false,
\r
668 ddaysText = this.disabledDaysText,
\r
669 format = this.format;
\r
671 if(this.showToday){
\r
672 var td = new Date().clearTime(),
\r
673 disable = (td < min || td > max ||
\r
674 (ddMatch && format && ddMatch.test(td.dateFormat(format))) ||
\r
675 (ddays && ddays.indexOf(td.getDay()) != -1));
\r
677 if(!this.disabled){
\r
678 this.todayBtn.setDisabled(disable);
\r
679 this.todayKeyListener[disable ? 'disable' : 'enable']();
\r
683 var setCellClass = function(cal, cell){
\r
685 var t = d.getTime();
\r
686 cell.firstChild.dateValue = t;
\r
688 cell.className += ' x-date-today';
\r
689 cell.title = cal.todayText;
\r
692 cell.className += ' x-date-selected';
\r
694 Ext.fly(cell.firstChild).focus(50);
\r
699 cell.className = ' x-date-disabled';
\r
700 cell.title = cal.minText;
\r
704 cell.className = ' x-date-disabled';
\r
705 cell.title = cal.maxText;
\r
709 if(ddays.indexOf(d.getDay()) != -1){
\r
710 cell.title = ddaysText;
\r
711 cell.className = ' x-date-disabled';
\r
714 if(ddMatch && format){
\r
715 var fvalue = d.dateFormat(format);
\r
716 if(ddMatch.test(fvalue)){
\r
717 cell.title = ddText.replace('%0', fvalue);
\r
718 cell.className = ' x-date-disabled';
\r
724 for(; i < startingPos; i++) {
\r
725 textEls[i].innerHTML = (++prevStart);
\r
726 d.setDate(d.getDate()+1);
\r
727 cells[i].className = 'x-date-prevday';
\r
728 setCellClass(this, cells[i]);
\r
730 for(; i < days; i++){
\r
731 var intDay = i - startingPos + 1;
\r
732 textEls[i].innerHTML = (intDay);
\r
733 d.setDate(d.getDate()+1);
\r
734 cells[i].className = 'x-date-active';
\r
735 setCellClass(this, cells[i]);
\r
738 for(; i < 42; i++) {
\r
739 textEls[i].innerHTML = (++extraDays);
\r
740 d.setDate(d.getDate()+1);
\r
741 cells[i].className = 'x-date-nextday';
\r
742 setCellClass(this, cells[i]);
\r
745 this.mbtn.setText(this.monthNames[date.getMonth()] + ' ' + date.getFullYear());
\r
747 if(!this.internalRender){
\r
748 var main = this.el.dom.firstChild,
\r
749 w = main.offsetWidth;
\r
750 this.el.setWidth(w + this.el.getBorderWidth('lr'));
\r
751 Ext.fly(main).setWidth(w);
\r
752 this.internalRender = true;
\r
753 // opera does not respect the auto grow header center column
\r
754 // then, after it gets a width opera refuses to recalculate
\r
755 // without a second pass
\r
756 if(Ext.isOpera && !this.secondPass){
\r
757 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + 'px';
\r
758 this.secondPass = true;
\r
759 this.update.defer(10, this, [date]);
\r
766 beforeDestroy : function() {
\r
768 this.keyNav.disable();
\r
769 this.keyNav = null;
\r
772 this.rightClickRpt,
\r
781 <div id="cfg-Ext.DatePicker-autoEl"></div>/**
\r
782 * @cfg {String} autoEl @hide
\r
786 Ext.reg('datepicker', Ext.DatePicker);
\r