datepicker: fix arrow click after clear date

This commit is contained in:
vitalets 2012-12-08 18:14:19 +04:00
parent 48eff4a33d
commit 5c1ebaaf5e
2 changed files with 5 additions and 4 deletions
CHANGELOG.txt
src/inputs/date/bootstrap-datepicker/js

@ -4,6 +4,7 @@ X-editable changelog
Version 1.2.1 wip Version 1.2.1 wip
---------------------------- ----------------------------
[bug] datepicker: error when click on arrows after clear date (vitalets)
[enh] 'hidden' event: added possible value of reason param - 'nochange'. Occurs when form is submitted but value was not changed (vitalets) [enh] 'hidden' event: added possible value of reason param - 'nochange'. Occurs when form is submitted but value was not changed (vitalets)
[enh] 'submit' method changed: error-callback's parameter simplified (vitalets) [enh] 'submit' method changed: error-callback's parameter simplified (vitalets)
[enh] 'submit' method changed: now when response 200 OK it does not set pk automatically (vitalets) [enh] 'submit' method changed: now when response 200 OK it does not set pk automatically (vitalets)

@ -286,7 +286,7 @@
startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity, startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity, endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity, endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
currentDate = this.date.valueOf(), currentDate = this.date && this.date.valueOf(),
today = new Date(); today = new Date();
this.picker.find('.datepicker-days thead th:eq(1)') this.picker.find('.datepicker-days thead th:eq(1)')
.text(dates[this.language].months[month]+' '+year); .text(dates[this.language].months[month]+' '+year);
@ -321,7 +321,7 @@
prevMonth.getUTCDate() == today.getDate()) { prevMonth.getUTCDate() == today.getDate()) {
clsName += ' today'; clsName += ' today';
} }
if (prevMonth.valueOf() == currentDate) { if (currentDate && prevMonth.valueOf() == currentDate) {
clsName += ' active'; clsName += ' active';
} }
if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate) { if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate) {
@ -334,14 +334,14 @@
prevMonth.setUTCDate(prevMonth.getUTCDate()+1); prevMonth.setUTCDate(prevMonth.getUTCDate()+1);
} }
this.picker.find('.datepicker-days tbody').empty().append(html.join('')); this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
var currentYear = this.date.getUTCFullYear(); var currentYear = this.date && this.date.getUTCFullYear();
var months = this.picker.find('.datepicker-months') var months = this.picker.find('.datepicker-months')
.find('th:eq(1)') .find('th:eq(1)')
.text(year) .text(year)
.end() .end()
.find('span').removeClass('active'); .find('span').removeClass('active');
if (currentYear == year) { if (currentYear && currentYear == year) {
months.eq(this.date.getUTCMonth()).addClass('active'); months.eq(this.date.getUTCMonth()).addClass('active');
} }
if (year < startYear || year > endYear) { if (year < startYear || year > endYear) {