4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-picker-Date'>/**
19 </span> * @class Ext.picker.Date
20 * @extends Ext.Component
21 * <p>A date picker. This class is used by the {@link Ext.form.field.Date} field to allow browsing and
22 * selection of valid dates in a popup next to the field, but may also be used with other components.</p>
23 * <p>Typically you will need to implement a handler function to be notified when the user chooses a color from the
24 * picker; you can register the handler using the {@link #select} event, or by implementing the {@link #handler}
26 * <p>By default the user will be allowed to pick any date; this can be changed by using the {@link #minDate},
27 * {@link #maxDate}, {@link #disabledDays}, {@link #disabledDatesRE}, and/or {@link #disabledDates} configs.</p>
28 * <p>All the string values documented below may be overridden by including an Ext locale file in your page.</p>
29 * <p>Example usage:</p>
30 * <pre><code>new Ext.panel.Panel({
31 title: 'Choose a future date:',
34 renderTo: Ext.getBody(),
38 handler: function(picker, date) {
39 // do something with the selected date
42 });</code></pre>
43 * {@img Ext.picker.Date/Ext.picker.Date.png Ext.picker.Date component}
46 Ext.define('Ext.picker.Date', {
47 extend: 'Ext.Component',
52 'Ext.util.ClickRepeater',
58 alias: 'widget.datepicker',
59 alternateClassName: 'Ext.DatePicker',
62 '<div class="{cls}" id="{id}" role="grid" title="{ariaTitle} {value:this.longDay}">',
63 '<div role="presentation" class="{baseCls}-header">',
64 '<div class="{baseCls}-prev"><a href="#" role="button" title="{prevText}"></a></div>',
65 '<div class="{baseCls}-month"></div>',
66 '<div class="{baseCls}-next"><a href="#" role="button" title="{nextText}"></a></div>',
68 '<table class="{baseCls}-inner" cellspacing="0" role="presentation">',
69 '<thead role="presentation"><tr role="presentation">',
70 '<tpl for="dayNames">',
71 '<th role="columnheader" title="{.}"><span>{.:this.firstInitial}</span></th>',
73 '</tr></thead>',
74 '<tbody role="presentation"><tr role="presentation">',
75 '<tpl for="days">',
76 '{#:this.isEndOfWeek}',
77 '<td role="gridcell" id="{[Ext.id()]}">',
78 '<a role="presentation" href="#" hidefocus="on" class="{parent.baseCls}-date" tabIndex="1">',
79 '<em role="presentation"><span role="presentation"></span></em>',
83 '</tr></tbody>',
85 '<tpl if="showToday">',
86 '<div role="presentation" class="{baseCls}-footer"></div>',
90 firstInitial: function(value) {
91 return value.substr(0,1);
93 isEndOfWeek: function(value) {
94 // convert from 1 based index to 0 based
95 // by decrementing value once.
97 var end = value % 7 === 0 && value !== 0;
98 return end ? '</tr><tr role="row">' : '';
100 longDay: function(value){
101 return Ext.Date.format(value, this.longDayFormat);
106 ariaTitle: 'Date Picker',
107 <span id='Ext-picker-Date-cfg-todayText'> /**
108 </span> * @cfg {String} todayText
109 * The text to display on the button that selects the current date (defaults to <code>'Today'</code>)
112 <span id='Ext-picker-Date-cfg-handler'> /**
113 </span> * @cfg {Function} handler
114 * Optional. A function that will handle the select event of this picker.
115 * The handler is passed the following parameters:<div class="mdetail-params"><ul>
116 * <li><code>picker</code> : Ext.picker.Date <div class="sub-desc">This Date picker.</div></li>
117 * <li><code>date</code> : Date <div class="sub-desc">The selected date.</div></li>
118 * </ul></div>
120 <span id='Ext-picker-Date-cfg-scope'> /**
121 </span> * @cfg {Object} scope
122 * The scope (<code><b>this</b></code> reference) in which the <code>{@link #handler}</code>
123 * function will be called. Defaults to this DatePicker instance.
125 <span id='Ext-picker-Date-cfg-todayTip'> /**
126 </span> * @cfg {String} todayTip
127 * A string used to format the message for displaying in a tooltip over the button that
128 * selects the current date. Defaults to <code>'{0} (Spacebar)'</code> where
129 * the <code>{0}</code> token is replaced by today's date.
131 todayTip : '{0} (Spacebar)',
132 <span id='Ext-picker-Date-cfg-minText'> /**
133 </span> * @cfg {String} minText
134 * The error text to display if the minDate validation fails (defaults to <code>'This date is before the minimum date'</code>)
136 minText : 'This date is before the minimum date',
137 <span id='Ext-picker-Date-cfg-maxText'> /**
138 </span> * @cfg {String} maxText
139 * The error text to display if the maxDate validation fails (defaults to <code>'This date is after the maximum date'</code>)
141 maxText : 'This date is after the maximum date',
142 <span id='Ext-picker-Date-cfg-format'> /**
143 </span> * @cfg {String} format
144 * The default date format string which can be overriden for localization support. The format must be
145 * valid according to {@link Ext.Date#parse} (defaults to {@link Ext.Date#defaultFormat}).
147 <span id='Ext-picker-Date-cfg-disabledDaysText'> /**
148 </span> * @cfg {String} disabledDaysText
149 * The tooltip to display when the date falls on a disabled day (defaults to <code>'Disabled'</code>)
151 disabledDaysText : 'Disabled',
152 <span id='Ext-picker-Date-cfg-disabledDatesText'> /**
153 </span> * @cfg {String} disabledDatesText
154 * The tooltip text to display when the date falls on a disabled date (defaults to <code>'Disabled'</code>)
156 disabledDatesText : 'Disabled',
157 <span id='Ext-picker-Date-cfg-monthNames'> /**
158 </span> * @cfg {Array} monthNames
159 * An array of textual month names which can be overriden for localization support (defaults to Ext.Date.monthNames)
161 <span id='Ext-picker-Date-cfg-dayNames'> /**
162 </span> * @cfg {Array} dayNames
163 * An array of textual day names which can be overriden for localization support (defaults to Ext.Date.dayNames)
165 <span id='Ext-picker-Date-cfg-nextText'> /**
166 </span> * @cfg {String} nextText
167 * The next month navigation button tooltip (defaults to <code>'Next Month (Control+Right)'</code>)
169 nextText : 'Next Month (Control+Right)',
170 <span id='Ext-picker-Date-cfg-prevText'> /**
171 </span> * @cfg {String} prevText
172 * The previous month navigation button tooltip (defaults to <code>'Previous Month (Control+Left)'</code>)
174 prevText : 'Previous Month (Control+Left)',
175 <span id='Ext-picker-Date-cfg-monthYearText'> /**
176 </span> * @cfg {String} monthYearText
177 * The header month selector tooltip (defaults to <code>'Choose a month (Control+Up/Down to move years)'</code>)
179 monthYearText : 'Choose a month (Control+Up/Down to move years)',
180 <span id='Ext-picker-Date-cfg-startDay'> /**
181 </span> * @cfg {Number} startDay
182 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
185 <span id='Ext-picker-Date-cfg-showToday'> /**
186 </span> * @cfg {Boolean} showToday
187 * False to hide the footer area containing the Today button and disable the keyboard handler for spacebar
188 * that selects the current date (defaults to <code>true</code>).
191 <span id='Ext-picker-Date-cfg-minDate'> /**
192 </span> * @cfg {Date} minDate
193 * Minimum allowable date (JavaScript date object, defaults to null)
195 <span id='Ext-picker-Date-cfg-maxDate'> /**
196 </span> * @cfg {Date} maxDate
197 * Maximum allowable date (JavaScript date object, defaults to null)
199 <span id='Ext-picker-Date-cfg-disabledDays'> /**
200 </span> * @cfg {Array} disabledDays
201 * An array of days to disable, 0-based. For example, [0, 6] disables Sunday and Saturday (defaults to null).
203 <span id='Ext-picker-Date-cfg-disabledDatesRE'> /**
204 </span> * @cfg {RegExp} disabledDatesRE
205 * JavaScript regular expression used to disable a pattern of dates (defaults to null). The {@link #disabledDates}
206 * config will generate this regex internally, but if you specify disabledDatesRE it will take precedence over the
207 * disabledDates value.
209 <span id='Ext-picker-Date-cfg-disabledDates'> /**
210 </span> * @cfg {Array} disabledDates
211 * An array of 'dates' to disable, as strings. These strings will be used to build a dynamic regular
212 * expression so they are very powerful. Some examples:
214 * <li>['03/08/2003', '09/16/2003'] would disable those exact dates</li>
215 * <li>['03/08', '09/16'] would disable those days for every year</li>
216 * <li>['^03/08'] would only match the beginning (useful if you are using short years)</li>
217 * <li>['03/../2006'] would disable every day in March 2006</li>
218 * <li>['^03'] would disable every day in every March</li>
220 * Note that the format of the dates included in the array should exactly match the {@link #format} config.
221 * In order to support regular expressions, if you are using a date format that has '.' in it, you will have to
222 * escape the dot when restricting dates. For example: ['03\\.08\\.03'].
225 <span id='Ext-picker-Date-cfg-disableAnim'> /**
226 </span> * @cfg {Boolean} disableAnim True to disable animations when showing the month picker. Defaults to <tt>false</tt>.
230 <span id='Ext-picker-Date-cfg-baseCls'> /**
231 </span> * @cfg {String} baseCls
232 * The base CSS class to apply to this components element (defaults to <tt>'x-datepicker'</tt>).
234 baseCls: Ext.baseCSSPrefix + 'datepicker',
236 <span id='Ext-picker-Date-cfg-selectedCls'> /**
237 </span> * @cfg {String} selectedCls
238 * The class to apply to the selected cell. Defaults to <tt>'x-datepicker-selected'</tt>
241 <span id='Ext-picker-Date-cfg-disabledCellCls'> /**
242 </span> * @cfg {String} disabledCellCls
243 * The class to apply to disabled cells. Defaults to <tt>'x-datepicker-disabled'</tt>
246 <span id='Ext-picker-Date-cfg-longDayFormat'> /**
247 </span> * @cfg {String} longDayFormat
248 * The format for displaying a date in a longer format. Defaults to <tt>'F d, Y'</tt>
250 longDayFormat: 'F d, Y',
252 <span id='Ext-picker-Date-cfg-keyNavConfig'> /**
253 </span> * @cfg {Object} keyNavConfig Specifies optional custom key event handlers for the {@link Ext.util.KeyNav}
254 * attached to this date picker. Must conform to the config format recognized by the {@link Ext.util.KeyNav}
255 * constructor. Handlers specified in this object will replace default handlers of the same name.
258 <span id='Ext-picker-Date-cfg-focusOnShow'> /**
259 </span> * @cfg {Boolean} focusOnShow
260 * True to automatically focus the picker on show. Defaults to <tt>false</tt>.
265 // Set by other components to stop the picker focus being updated when the value changes.
270 // default value used to initialise each date in the DatePicker
271 // (note: 12 noon was chosen because it steers well clear of all DST timezone changes)
272 initHour: 12, // 24-hour format
276 // private, inherit docs
277 initComponent : function() {
279 clearTime = Ext.Date.clearTime;
281 me.selectedCls = me.baseCls + '-selected';
282 me.disabledCellCls = me.baseCls + '-disabled';
283 me.prevCls = me.baseCls + '-prevday';
284 me.activeCls = me.baseCls + '-active';
285 me.nextCls = me.baseCls + '-prevday';
286 me.todayCls = me.baseCls + '-today';
287 me.dayNames = me.dayNames.slice(me.startDay).concat(me.dayNames.slice(0, me.startDay));
290 me.value = me.value ?
291 clearTime(me.value, true) : clearTime(new Date());
294 <span id='Ext-picker-Date-event-select'> /**
295 </span> * @event select
296 * Fires when a date is selected
297 * @param {DatePicker} this DatePicker
298 * @param {Date} date The selected date
303 me.initDisabledDays();
306 // private, inherit docs
307 onRender : function(container, position){
309 * days array for looping through 6 full weeks (6 weeks * 7 days)
310 * Note that we explicitly force the size here so the template creates
311 * all the appropriate cells.
315 days = new Array(me.numDays),
316 today = Ext.Date.format(new Date(), me.format);
323 Ext.apply(me.renderData, {
324 dayNames: me.dayNames,
325 ariaTitle: me.ariaTitle,
327 showToday: me.showToday,
328 prevText: me.prevText,
329 nextText: me.nextText,
332 me.getTpl('renderTpl').longDayFormat = me.longDayFormat;
334 Ext.apply(me.renderSelectors, {
335 eventEl: 'table.' + me.baseCls + '-inner',
336 prevEl: '.' + me.baseCls + '-prev a',
337 nextEl: '.' + me.baseCls + '-next a',
338 middleBtnEl: '.' + me.baseCls + '-month',
339 footerEl: '.' + me.baseCls + '-footer'
342 this.callParent(arguments);
343 me.el.unselectable();
345 me.cells = me.eventEl.select('tbody td');
346 me.textNodes = me.eventEl.query('tbody td span');
348 me.monthBtn = Ext.create('Ext.button.Split', {
350 tooltip: me.monthYearText,
351 renderTo: me.middleBtnEl
353 //~ me.middleBtnEl.down('button').addCls(Ext.baseCSSPrefix + 'btn-arrow');
356 me.todayBtn = Ext.create('Ext.button.Button', {
357 renderTo: me.footerEl,
358 text: Ext.String.format(me.todayText, today),
359 tooltip: Ext.String.format(me.todayTip, today),
360 handler: me.selectToday,
365 // private, inherit docs
366 initEvents: function(){
373 me.prevRepeater = Ext.create('Ext.util.ClickRepeater', me.prevEl, {
374 handler: me.showPrevMonth,
376 preventDefault: true,
380 me.nextRepeater = Ext.create('Ext.util.ClickRepeater', me.nextEl, {
381 handler: me.showNextMonth,
387 me.keyNav = Ext.create('Ext.util.KeyNav', me.eventEl, Ext.apply({
389 'left' : function(e){
393 me.update(eDate.add(me.activeDate, day, -1));
397 'right' : function(e){
401 me.update(eDate.add(me.activeDate, day, 1));
409 me.update(eDate.add(me.activeDate, day, -7));
413 'down' : function(e){
417 me.update(eDate.add(me.activeDate, day, 7));
420 'pageUp' : me.showNextMonth,
421 'pageDown' : me.showPrevMonth,
422 'enter' : function(e){
426 }, me.keyNavConfig));
429 me.todayKeyListener = me.eventEl.addKeyListener(Ext.EventObject.SPACE, me.selectToday, me);
431 me.mon(me.eventEl, 'mousewheel', me.handleMouseWheel, me);
432 me.mon(me.eventEl, 'click', me.handleDateClick, me, {delegate: 'a.' + me.baseCls + '-date'});
433 me.mon(me.monthBtn, 'click', me.showMonthPicker, me);
434 me.mon(me.monthBtn, 'arrowclick', me.showMonthPicker, me);
438 <span id='Ext-picker-Date-method-initDisabledDays'> /**
439 </span> * Setup the disabled dates regex based on config options
442 initDisabledDays : function(){
444 dd = me.disabledDates,
448 if(!me.disabledDatesRE && dd){
451 Ext.each(dd, function(d, i){
452 re += Ext.isDate(d) ? '^' + Ext.String.escapeRegex(Ext.Date.dateFormat(d, me.format)) + '$' : dd[i];
457 me.disabledDatesRE = new RegExp(re + ')');
461 <span id='Ext-picker-Date-method-setDisabledDates'> /**
462 </span> * Replaces any existing disabled dates with new values and refreshes the DatePicker.
463 * @param {Array/RegExp} disabledDates An array of date strings (see the {@link #disabledDates} config
464 * for details on supported values), or a JavaScript regular expression used to disable a pattern of dates.
465 * @return {Ext.picker.Date} this
467 setDisabledDates : function(dd){
471 me.disabledDates = dd;
472 me.disabledDatesRE = null;
474 me.disabledDatesRE = dd;
476 me.initDisabledDays();
477 me.update(me.value, true);
481 <span id='Ext-picker-Date-method-setDisabledDays'> /**
482 </span> * Replaces any existing disabled days (by index, 0-6) with new values and refreshes the DatePicker.
483 * @param {Array} disabledDays An array of disabled day indexes. See the {@link #disabledDays} config
484 * for details on supported values.
485 * @return {Ext.picker.Date} this
487 setDisabledDays : function(dd){
488 this.disabledDays = dd;
489 return this.update(this.value, true);
492 <span id='Ext-picker-Date-method-setMinDate'> /**
493 </span> * Replaces any existing {@link #minDate} with the new value and refreshes the DatePicker.
494 * @param {Date} value The minimum date that can be selected
495 * @return {Ext.picker.Date} this
497 setMinDate : function(dt){
499 return this.update(this.value, true);
502 <span id='Ext-picker-Date-method-setMaxDate'> /**
503 </span> * Replaces any existing {@link #maxDate} with the new value and refreshes the DatePicker.
504 * @param {Date} value The maximum date that can be selected
505 * @return {Ext.picker.Date} this
507 setMaxDate : function(dt){
509 return this.update(this.value, true);
512 <span id='Ext-picker-Date-method-setValue'> /**
513 </span> * Sets the value of the date field
514 * @param {Date} value The date to set
515 * @return {Ext.picker.Date} this
517 setValue : function(value){
518 this.value = Ext.Date.clearTime(value, true);
519 return this.update(this.value);
522 <span id='Ext-picker-Date-method-getValue'> /**
523 </span> * Gets the current selected value of the date field
524 * @return {Date} The selected date
526 getValue : function(){
532 this.update(this.activeDate);
535 // private, inherit docs
536 onEnable: function(){
538 this.setDisabledStatus(false);
539 this.update(this.activeDate);
543 // private, inherit docs
544 onDisable : function(){
546 this.setDisabledStatus(true);
549 <span id='Ext-picker-Date-method-setDisabledStatus'> /**
550 </span> * Set the disabled state of various internal components
552 * @param {Boolean} disabled
554 setDisabledStatus : function(disabled){
557 me.keyNav.setDisabled(disabled);
558 me.prevRepeater.setDisabled(disabled);
559 me.nextRepeater.setDisabled(disabled);
561 me.todayKeyListener.setDisabled(disabled);
562 me.todayBtn.setDisabled(disabled);
566 <span id='Ext-picker-Date-method-getActive'> /**
567 </span> * Get the current active date.
569 * @return {Date} The active date
571 getActive: function(){
572 return this.activeDate || me.value;
575 <span id='Ext-picker-Date-method-runAnimation'> /**
576 </span> * Run any animation required to hide/show the month picker.
578 * @param {Boolean} isHide True if it's a hide operation
580 runAnimation: function(isHide){
582 target: this.monthPicker,
586 Ext.fx.Manager.run();
592 Ext.create('Ext.fx.Anim', options);
595 <span id='Ext-picker-Date-method-hideMonthPicker'> /**
596 </span> * Hides the month picker, if it's visible.
597 * @return {Ext.picker.Date} this
599 hideMonthPicker : function(){
601 picker = me.monthPicker;
604 if (me.disableAnim) {
607 this.runAnimation(true);
613 <span id='Ext-picker-Date-method-showMonthPicker'> /**
614 </span> * Show the month picker
615 * @return {Ext.picker.Date} this
617 showMonthPicker : function(){
626 if (me.rendered && !me.disabled) {
628 picker = me.createMonthPicker();
630 picker.setSize(size);
631 picker.setValue(me.getActive());
633 if (me.disableAnim) {
634 picker.setPosition(-1, -1);
636 me.runAnimation(false);
642 <span id='Ext-picker-Date-method-createMonthPicker'> /**
643 </span> * Create the month picker instance
645 * @return {Ext.picker.Month} picker
647 createMonthPicker: function(){
649 picker = me.monthPicker;
652 me.monthPicker = picker = Ext.create('Ext.picker.Month', {
656 small: me.showToday === false,
659 cancelclick: me.onCancelClick,
660 okclick: me.onOkClick,
661 yeardblclick: me.onOkClick,
662 monthdblclick: me.onOkClick
666 me.on('beforehide', me.hideMonthPicker, me);
671 <span id='Ext-picker-Date-method-onOkClick'> /**
672 </span> * Respond to an ok click on the month picker
675 onOkClick: function(picker, value){
679 date = new Date(year, month, me.getActive().getDate());
681 if (date.getMonth() !== month) {
682 // 'fix' the JS rolling date conversion if needed
683 date = new Date(year, month, 1).getLastDateOfMonth();
686 me.hideMonthPicker();
689 <span id='Ext-picker-Date-method-onCancelClick'> /**
690 </span> * Respond to a cancel click on the month picker
693 onCancelClick: function(){
694 this.hideMonthPicker();
697 <span id='Ext-picker-Date-method-showPrevMonth'> /**
698 </span> * Show the previous month.
699 * @return {Ext.picker.Date} this
701 showPrevMonth : function(e){
702 return this.update(Ext.Date.add(this.activeDate, Ext.Date.MONTH, -1));
705 <span id='Ext-picker-Date-method-showNextMonth'> /**
706 </span> * Show the next month.
707 * @return {Ext.picker.Date} this
709 showNextMonth : function(e){
710 return this.update(Ext.Date.add(this.activeDate, Ext.Date.MONTH, 1));
713 <span id='Ext-picker-Date-method-showPrevYear'> /**
714 </span> * Show the previous year.
715 * @return {Ext.picker.Date} this
717 showPrevYear : function(){
718 this.update(Ext.Date.add(this.activeDate, Ext.Date.YEAR, -1));
721 <span id='Ext-picker-Date-method-showNextYear'> /**
722 </span> * Show the next year.
723 * @return {Ext.picker.Date} this
725 showNextYear : function(){
726 this.update(Ext.Date.add(this.activeDate, Ext.Date.YEAR, 1));
729 <span id='Ext-picker-Date-method-handleMouseWheel'> /**
730 </span> * Respond to the mouse wheel event
732 * @param {Ext.EventObject} e
734 handleMouseWheel : function(e){
737 var delta = e.getWheelDelta();
739 this.showPrevMonth();
740 } else if(delta < 0){
741 this.showNextMonth();
746 <span id='Ext-picker-Date-method-handleDateClick'> /**
747 </span> * Respond to a date being clicked in the picker
749 * @param {Ext.EventObject} e
750 * @param {HTMLElement} t
752 handleDateClick : function(e, t){
754 handler = me.handler;
757 if(!me.disabled && t.dateValue && !Ext.fly(t.parentNode).hasCls(me.disabledCellCls)){
758 me.cancelFocus = me.focusOnSelect === false;
759 me.setValue(new Date(t.dateValue));
760 delete me.cancelFocus;
761 me.fireEvent('select', me, me.value);
763 handler.call(me.scope || me, me, me.value);
765 // event handling is turned off on hide
766 // when we are using the picker in a field
767 // therefore onSelect comes AFTER the select
773 <span id='Ext-picker-Date-method-onSelect'> /**
774 </span> * Perform any post-select actions
777 onSelect: function() {
778 if (this.hideOnSelect) {
783 <span id='Ext-picker-Date-method-selectToday'> /**
784 </span> * Sets the current value to today.
785 * @return {Ext.picker.Date} this
787 selectToday : function(){
790 handler = me.handler;
792 if(btn && !btn.disabled){
793 me.setValue(Ext.Date.clearTime(new Date()));
794 me.fireEvent('select', me, me.value);
796 handler.call(me.scope || me, me, me.value);
803 <span id='Ext-picker-Date-method-selectedUpdate'> /**
804 </span> * Update the selected cell
806 * @param {Date} date The new date
807 * @param {Date} active The active date
809 selectedUpdate: function(date, active){
813 cls = me.selectedCls;
815 cells.removeCls(cls);
816 cells.each(function(c){
817 if (c.dom.firstChild.dateValue == t) {
818 me.el.dom.setAttribute('aria-activedescendent', c.dom.id);
820 if(me.isVisible() && !me.cancelFocus){
821 Ext.fly(c.dom.firstChild).focus(50);
828 <span id='Ext-picker-Date-method-fullUpdate'> /**
829 </span> * Update the contents of the picker for a new month
831 * @param {Date} date The new date
832 * @param {Date} active The active date
834 fullUpdate: function(date, active){
836 cells = me.cells.elements,
837 textNodes = me.textNodes,
838 disabledCls = me.disabledCellCls,
842 visible = me.isVisible(),
843 sel = +eDate.clearTime(date, true),
844 today = +eDate.clearTime(new Date()),
845 min = me.minDate ? eDate.clearTime(me.minDate, true) : Number.NEGATIVE_INFINITY,
846 max = me.maxDate ? eDate.clearTime(me.maxDate, true) : Number.POSITIVE_INFINITY,
847 ddMatch = me.disabledDatesRE,
848 ddText = me.disabledDatesText,
849 ddays = me.disabledDays ? me.disabledDays.join('') : false,
850 ddaysText = me.disabledDaysText,
852 days = eDate.getDaysInMonth(date),
853 firstOfMonth = eDate.getFirstDateOfMonth(date),
854 startingPos = firstOfMonth.getDay() - me.startDay,
855 previousMonth = eDate.add(date, eDate.MONTH, -1),
856 longDayFormat = me.longDayFormat,
867 if (startingPos < 0) {
872 prevStart = eDate.getDaysInMonth(previousMonth) - startingPos;
873 current = new Date(previousMonth.getFullYear(), previousMonth.getMonth(), prevStart, me.initHour);
876 tempDate = eDate.clearTime(new Date());
877 disableToday = (tempDate < min || tempDate > max ||
878 (ddMatch && format && ddMatch.test(eDate.dateFormat(tempDate, format))) ||
879 (ddays && ddays.indexOf(tempDate.getDay()) != -1));
882 me.todayBtn.setDisabled(disableToday);
883 me.todayKeyListener.setDisabled(disableToday);
887 setCellClass = function(cell){
888 value = +eDate.clearTime(current, true);
889 cell.title = eDate.format(current, longDayFormat);
890 // store dateValue number as an expando
891 cell.firstChild.dateValue = value;
893 cell.className += ' ' + me.todayCls;
894 cell.title = me.todayText;
897 cell.className += ' ' + me.selectedCls;
898 me.el.dom.setAttribute('aria-activedescendant', cell.id);
899 if (visible && me.floating) {
900 Ext.fly(cell.firstChild).focus(50);
905 cell.className = disabledCls;
906 cell.title = me.minText;
910 cell.className = disabledCls;
911 cell.title = me.maxText;
915 if(ddays.indexOf(current.getDay()) != -1){
916 cell.title = ddaysText;
917 cell.className = disabledCls;
920 if(ddMatch && format){
921 formatValue = eDate.dateFormat(current, format);
922 if(ddMatch.test(formatValue)){
923 cell.title = ddText.replace('%0', formatValue);
924 cell.className = disabledCls;
929 for(; i < me.numDays; ++i) {
930 if (i < startingPos) {
931 html = (++prevStart);
933 } else if (i >= days) {
934 html = (++extraDays);
937 html = i - startingPos + 1;
940 textNodes[i].innerHTML = html;
941 cells[i].className = cls;
942 current.setDate(current.getDate() + 1);
943 setCellClass(cells[i]);
946 me.monthBtn.setText(me.monthNames[date.getMonth()] + ' ' + date.getFullYear());
949 <span id='Ext-picker-Date-method-update'> /**
950 </span> * Update the contents of the picker
952 * @param {Date} date The new date
953 * @param {Boolean} forceRefresh True to force a full refresh
955 update : function(date, forceRefresh){
957 active = me.activeDate;
960 me.activeDate = date;
961 if(!forceRefresh && active && me.el && active.getMonth() == date.getMonth() && active.getFullYear() == date.getFullYear()){
962 me.selectedUpdate(date, active);
964 me.fullUpdate(date, active);
970 // private, inherit docs
971 beforeDestroy : function() {
985 delete me.cells.elements;
989 // private, inherit docs
991 this.callParent(arguments);
992 if (this.focusOnShow) {
998 // After dependencies have loaded:
1000 var proto = this.prototype;
1002 proto.monthNames = Ext.Date.monthNames;
1004 proto.dayNames = Ext.Date.dayNames;
1006 proto.format = Ext.Date.defaultFormat;