fix selecting disabled date from timepicker

This commit is contained in:
t1m0n 2016-03-02 11:01:30 +03:00
parent 2966825be5
commit 2d0dbf0b3b
7 changed files with 35 additions and 49 deletions

View File

@ -457,8 +457,10 @@
-ms-flex-align: center;
align-items: center;
font-size: 11px;
height: 18px;
height: 17px;
background: linear-gradient(to right, #dedede, #dedede) left 50%/100% 1px no-repeat; }
.datepicker--time-row:first-child {
margin-bottom: 4px; }
.datepicker--time-row input[type='range'] {
background: none;
cursor: pointer;

File diff suppressed because one or more lines are too long

34
dist/js/datepicker.js vendored
View File

@ -1132,7 +1132,7 @@ var Datepicker;
date.setHours(h);
date.setMinutes(m);
if (!selected) {
if (!selected && !this._getCell(date).hasClass('-disabled-')) {
this.selectDate(date);
} else {
this._setInputValue();
@ -1791,27 +1791,20 @@ var Datepicker;
})();
(function (window, $, datepicker) {
//TODO включить время в минимальную и максимальную дату
//TODO возможность задания минимальных и максимальных минут/часов
//TODO возможность задания шага для часов минут
//TODO возоможность задавать определенные часы и минуты
var template = '<div class="datepicker--time">' +
'<div class="datepicker--time-sliders">' +
' <label class="datepicker--time-label">#{hourLabel}</label>' +
' <div class="datepicker--time-row">' +
' <input type="range" name="hours" value="#{hourValue}" min="#{hourMin}" max="#{hourMax}" step="#{hourStep}"/>' +
' </div>' +
' <label class="datepicker--time-label">#{minLabel}</label>' +
' <div class="datepicker--time-row">' +
' <input type="range" name="minutes" value="#{minValue}" min="#{minMin}" max="#{minMax}" step="#{minStep}"/>' +
' </div>' +
'</div>' +
'<div class="datepicker--time-current">' +
' <span class="datepicker--time-current-hours">#{hourValue}</span>' +
' <span class="datepicker--time-current-colon">:</span>' +
' <span class="datepicker--time-current-minutes">#{minValue}</span>' +
'</div>' +
'<div class="datepicker--time-sliders">' +
' <div class="datepicker--time-row">' +
' <input type="range" name="hours" value="#{hourValue}" min="#{hourMin}" max="#{hourMax}" step="#{hourStep}"/>' +
' </div>' +
' <div class="datepicker--time-row">' +
' <input type="range" name="minutes" value="#{minValue}" min="#{minMin}" max="#{minMax}" step="#{minStep}"/>' +
' </div>' +
'</div>' +
'</div>';
datepicker.Timepicker = function (inst, opts) {
@ -1855,12 +1848,13 @@ var Datepicker;
_setDefaultMinMaxTime: function () {
var maxHours = 23,
maxMinutes = 59,
opts = this.opts;
this.minHours = opts.minHours < 0 || opts.minHours > maxHours ? 0 : opts.minHours;
this.minMinutes = opts.minMinutes < 0 || opts.minMinutes > 59 ? 0 : opts.minMinutes;
this.minMinutes = opts.minMinutes < 0 || opts.minMinutes > maxMinutes ? 0 : opts.minMinutes;
this.maxHours = opts.maxHours < 0 || opts.maxHours > maxHours ? maxHours : opts.maxHours;
this.maxMinutes = opts.maxMinutes < 0 || opts.maxMinutes > 59 ? 59 : opts.maxMinutes;
this.maxMinutes = opts.maxMinutes < 0 || opts.maxMinutes > maxMinutes ? maxMinutes : opts.maxMinutes;
},
/**
@ -1909,10 +1903,6 @@ var Datepicker;
}
},
_render: function () {
},
_updateCurrentTime: function () {
var h = datepicker.getLeadingZeroNum(this.displayHours),
m = datepicker.getLeadingZeroNum(this.minutes);

File diff suppressed because one or more lines are too long

View File

@ -1132,7 +1132,7 @@ var Datepicker;
date.setHours(h);
date.setMinutes(m);
if (!selected) {
if (!selected && !this._getCell(date).hasClass('-disabled-')) {
this.selectDate(date);
} else {
this._setInputValue();

View File

@ -1,25 +1,18 @@
(function (window, $, datepicker) {
//TODO включить время в минимальную и максимальную дату
//TODO возможность задания минимальных и максимальных минут/часов
//TODO возможность задания шага для часов минут
//TODO возоможность задавать определенные часы и минуты
var template = '<div class="datepicker--time">' +
'<div class="datepicker--time-sliders">' +
' <label class="datepicker--time-label">#{hourLabel}</label>' +
' <div class="datepicker--time-row">' +
' <input type="range" name="hours" value="#{hourValue}" min="#{hourMin}" max="#{hourMax}" step="#{hourStep}"/>' +
' </div>' +
' <label class="datepicker--time-label">#{minLabel}</label>' +
' <div class="datepicker--time-row">' +
' <input type="range" name="minutes" value="#{minValue}" min="#{minMin}" max="#{minMax}" step="#{minStep}"/>' +
' </div>' +
'</div>' +
'<div class="datepicker--time-current">' +
' <span class="datepicker--time-current-hours">#{hourValue}</span>' +
' <span class="datepicker--time-current-colon">:</span>' +
' <span class="datepicker--time-current-minutes">#{minValue}</span>' +
'</div>' +
'<div class="datepicker--time-sliders">' +
' <div class="datepicker--time-row">' +
' <input type="range" name="hours" value="#{hourValue}" min="#{hourMin}" max="#{hourMax}" step="#{hourStep}"/>' +
' </div>' +
' <div class="datepicker--time-row">' +
' <input type="range" name="minutes" value="#{minValue}" min="#{minMin}" max="#{minMax}" step="#{minStep}"/>' +
' </div>' +
'</div>' +
'</div>';
datepicker.Timepicker = function (inst, opts) {
@ -63,12 +56,13 @@
_setDefaultMinMaxTime: function () {
var maxHours = 23,
maxMinutes = 59,
opts = this.opts;
this.minHours = opts.minHours < 0 || opts.minHours > maxHours ? 0 : opts.minHours;
this.minMinutes = opts.minMinutes < 0 || opts.minMinutes > 59 ? 0 : opts.minMinutes;
this.minMinutes = opts.minMinutes < 0 || opts.minMinutes > maxMinutes ? 0 : opts.minMinutes;
this.maxHours = opts.maxHours < 0 || opts.maxHours > maxHours ? maxHours : opts.maxHours;
this.maxMinutes = opts.maxMinutes < 0 || opts.maxMinutes > 59 ? 59 : opts.maxMinutes;
this.maxMinutes = opts.maxMinutes < 0 || opts.maxMinutes > maxMinutes ? maxMinutes : opts.maxMinutes;
},
/**
@ -117,10 +111,6 @@
}
},
_render: function () {
},
_updateCurrentTime: function () {
var h = datepicker.getLeadingZeroNum(this.displayHours),
m = datepicker.getLeadingZeroNum(this.minutes);

View File

@ -84,9 +84,13 @@ $rangeThumbBg: #dedede;
display: flex;
align-items: center;
font-size: 11px;
height: 18px;
height: 17px;
background: linear-gradient(to right,$rangeTrackBg, $rangeTrackBg) left 50%/100% $rangeTrackHeight no-repeat;
&:first-child {
margin-bottom: 4px;
}
input[type='range'] {
background: none;
cursor: pointer;