diff --git a/dist/css/datepicker.css b/dist/css/datepicker.css index 4340950..2ee01d5 100644 --- a/dist/css/datepicker.css +++ b/dist/css/datepicker.css @@ -107,5 +107,5 @@ .datepicker--cell-year { width: 25%; height: 40px; } - .datepicker--cell-year.-another-decade- { + .datepicker--cell-year.-other-decade- { color: #ddd; } diff --git a/dist/js/datepicker.js b/dist/js/datepicker.js index fb3e64b..fc2050e 100644 --- a/dist/js/datepicker.js +++ b/dist/js/datepicker.js @@ -16,6 +16,8 @@ var Datepicker; start: '', // Start date weekends: [6, 0], defaultView: 'days', + //TODO сделать минимальный вид + minView: 'days', dateFormat: 'dd.mm.yyyy', toggleSelected: true, @@ -37,8 +39,8 @@ var Datepicker; nextHtml: '»', // events - //TODO сделать обратный вызов - onChange: '' + onChange: '', + onRenderCell: '' }; Datepicker = function (el, options) { @@ -583,13 +585,19 @@ Datepicker.Cell = function () { var _class = "datepicker--cell datepicker--cell-day", currentDate = new Date(), d = Datepicker.getParsedDate(date), + render, html = d.date; + if (this.opts.onRenderCell) { + render = this.opts.onRenderCell(date, 'day') || {}; + html = render.html ? render.html : html; + _class += render.classes ? ' ' + render.classes : ''; + } if (this.d.isWeekend(d.day)) _class += " -weekend-"; if (Datepicker.isSame(currentDate, date)) _class += ' -current-'; if (this.d._isSelected(date, 'day')) _class += ' -selected-'; - if (!this.d._isInRange(date)) _class += ' -disabled-'; + if (!this.d._isInRange(date) || render.disabled) _class += ' -disabled-'; if (d.month != this.d.parsedDate.month) { _class += " -other-month-"; @@ -629,12 +637,20 @@ Datepicker.Cell = function () { var _class = "datepicker--cell datepicker--cell-month", d = Datepicker.getParsedDate(date), currentDate = new Date(), - loc = this.d.loc; + loc = this.d.loc, + html = loc.months[d.month], + render = {}; + + if (this.opts.onRenderCell) { + render = this.opts.onRenderCell(date, 'month') || {}; + html = render.html ? render.html : html; + _class += render.classes ? ' ' + render.classes : ''; + } if (Datepicker.isSame(currentDate, date, 'month')) _class += ' -current-'; - if (!this.d._isInRange(date, 'month')) _class += ' -disabled-'; + if (!this.d._isInRange(date, 'month') || render.disabled) _class += ' -disabled-'; - return '