fixed current date detection method

This commit is contained in:
t1m0n 2015-10-19 12:27:46 +03:00
parent f8b762c481
commit a364079130
3 changed files with 18 additions and 12 deletions

15
dist/js/datepicker.js vendored
View File

@ -47,7 +47,7 @@ var Datepicker;
this.currentDate = this.opts.start;
this.currentView = this.opts.defaultView;
this.selectedDate = '';
this.selectedDate = [];
this.views = {};
this.init()
@ -110,7 +110,6 @@ var Datepicker;
this.date = new Date(d.year + 10, 0, 1);
break;
}
},
prev: function () {
@ -409,11 +408,15 @@ Datepicker.Cell = function () {
},
_getDayHtml: function (date) {
var _class = "datepicker--cell datepicker--cell-day";
var _class = "datepicker--cell datepicker--cell-day",
currentDate = new Date(),
d = Datepicker.getParsedDate(date);
if (this.d.isWeekend(date.getDay())) _class += " -weekend-";
if (date.getMonth() != this.d.currentDate.getMonth()) _class += " -another-month-";
if (date.getDate() == new Date().getDate()) _class += ' -current-';
if (this.d.isWeekend(d.day)) _class += " -weekend-";
if (d.month != this.d.parsedDate.month) _class += " -another-month-";
if (d.date == currentDate.getDate() &&
d.month == currentDate.getMonth() &&
d.year == currentDate.getFullYear()) _class += ' -current-';
return '<div class="' + _class + '" data-date="' + date.getDate() + '">' + date.getDate() + '</div>';
},

View File

@ -85,11 +85,15 @@
},
_getDayHtml: function (date) {
var _class = "datepicker--cell datepicker--cell-day";
var _class = "datepicker--cell datepicker--cell-day",
currentDate = new Date(),
d = Datepicker.getParsedDate(date);
if (this.d.isWeekend(date.getDay())) _class += " -weekend-";
if (date.getMonth() != this.d.currentDate.getMonth()) _class += " -another-month-";
if (date.getDate() == new Date().getDate()) _class += ' -current-';
if (this.d.isWeekend(d.day)) _class += " -weekend-";
if (d.month != this.d.parsedDate.month) _class += " -another-month-";
if (d.date == currentDate.getDate() &&
d.month == currentDate.getMonth() &&
d.year == currentDate.getFullYear()) _class += ' -current-';
return '<div class="' + _class + '" data-date="' + date.getDate() + '">' + date.getDate() + '</div>';
},

View File

@ -47,7 +47,7 @@ var Datepicker;
this.currentDate = this.opts.start;
this.currentView = this.opts.defaultView;
this.selectedDate = '';
this.selectedDate = [];
this.views = {};
this.init()
@ -110,7 +110,6 @@ var Datepicker;
this.date = new Date(d.year + 10, 0, 1);
break;
}
},
prev: function () {