mirror of
https://github.com/xdan/datetimepicker.git
synced 2024-11-18 06:24:22 +00:00
fix minTime/maxTime; improvement: timebox only contains time lines between minTime <= x < maxTime
This commit is contained in:
parent
a530a454a3
commit
9eba6ad646
@ -1824,6 +1824,17 @@ var datetimepickerFactory = function ($) {
|
||||
h = '';
|
||||
m = '';
|
||||
|
||||
var minTimeMinutesOfDay = 0;
|
||||
if (options.minTime !== false) {
|
||||
var t = _xdsoft_datetime.strtotime(options.minTime);
|
||||
minTimeMinutesOfDay = 60 * t.getHours() + t.getMinutes();
|
||||
}
|
||||
var maxTimeMinutesOfDay = 24 * 60;
|
||||
if (options.maxTime !== false) {
|
||||
var t = _xdsoft_datetime.strtotime(options.maxTime);
|
||||
maxTimeMinutesOfDay = 60 * t.getHours() + t.getMinutes();
|
||||
}
|
||||
|
||||
line_time = function line_time(h, m) {
|
||||
var now = _xdsoft_datetime.now(), optionDateTime, current_time,
|
||||
isALlowTimesInit = options.allowTimes && $.isArray(options.allowTimes) && options.allowTimes.length;
|
||||
@ -1835,7 +1846,8 @@ var datetimepickerFactory = function ($) {
|
||||
optionDateTime.setHours(h);
|
||||
optionDateTime.setMinutes(m);
|
||||
classes = [];
|
||||
if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || (options.maxTime !== false && _xdsoft_datetime.strtotime(options.maxTime).getTime() < now.getTime()) || (options.minTime !== false && _xdsoft_datetime.strtotime(options.minTime).getTime() > now.getTime())) {
|
||||
var currentMinutesOfDay = 60 * h + m;
|
||||
if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || (currentMinutesOfDay >= maxTimeMinutesOfDay) || (currentMinutesOfDay < minTimeMinutesOfDay)) {
|
||||
classes.push('xdsoft_disabled');
|
||||
} else if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || ((options.disabledMinTime !== false && now.getTime() > _xdsoft_datetime.strtotime(options.disabledMinTime).getTime()) && (options.disabledMaxTime !== false && now.getTime() < _xdsoft_datetime.strtotime(options.disabledMaxTime).getTime()))) {
|
||||
classes.push('xdsoft_disabled');
|
||||
@ -1866,6 +1878,9 @@ var datetimepickerFactory = function ($) {
|
||||
if (!options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length) {
|
||||
for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) {
|
||||
for (j = 0; j < 60; j += options.step) {
|
||||
var currentMinutesOfDay = i * 60 + j;
|
||||
if (currentMinutesOfDay < minTimeMinutesOfDay) continue;
|
||||
if (currentMinutesOfDay >= maxTimeMinutesOfDay) continue;
|
||||
h = (i < 10 ? '0' : '') + i;
|
||||
m = (j < 10 ? '0' : '') + j;
|
||||
line_time(h, m);
|
||||
|
2
build/jquery.datetimepicker.full.min.js
vendored
2
build/jquery.datetimepicker.full.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1814,6 +1814,17 @@ var datetimepickerFactory = function ($) {
|
||||
h = '';
|
||||
m = '';
|
||||
|
||||
var minTimeMinutesOfDay = 0;
|
||||
if (options.minTime !== false) {
|
||||
var t = _xdsoft_datetime.strtotime(options.minTime);
|
||||
minTimeMinutesOfDay = 60 * t.getHours() + t.getMinutes();
|
||||
}
|
||||
var maxTimeMinutesOfDay = 24 * 60;
|
||||
if (options.maxTime !== false) {
|
||||
var t = _xdsoft_datetime.strtotime(options.maxTime);
|
||||
maxTimeMinutesOfDay = 60 * t.getHours() + t.getMinutes();
|
||||
}
|
||||
|
||||
line_time = function line_time(h, m) {
|
||||
var now = _xdsoft_datetime.now(), optionDateTime, current_time,
|
||||
isALlowTimesInit = options.allowTimes && $.isArray(options.allowTimes) && options.allowTimes.length;
|
||||
@ -1825,7 +1836,8 @@ var datetimepickerFactory = function ($) {
|
||||
optionDateTime.setHours(h);
|
||||
optionDateTime.setMinutes(m);
|
||||
classes = [];
|
||||
if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || (options.maxTime !== false && _xdsoft_datetime.strtotime(options.maxTime).getTime() < now.getTime()) || (options.minTime !== false && _xdsoft_datetime.strtotime(options.minTime).getTime() > now.getTime())) {
|
||||
var currentMinutesOfDay = 60 * h + m;
|
||||
if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || (currentMinutesOfDay >= maxTimeMinutesOfDay) || (currentMinutesOfDay < minTimeMinutesOfDay)) {
|
||||
classes.push('xdsoft_disabled');
|
||||
} else if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || ((options.disabledMinTime !== false && now.getTime() > _xdsoft_datetime.strtotime(options.disabledMinTime).getTime()) && (options.disabledMaxTime !== false && now.getTime() < _xdsoft_datetime.strtotime(options.disabledMaxTime).getTime()))) {
|
||||
classes.push('xdsoft_disabled');
|
||||
@ -1856,6 +1868,9 @@ var datetimepickerFactory = function ($) {
|
||||
if (!options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length) {
|
||||
for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) {
|
||||
for (j = 0; j < 60; j += options.step) {
|
||||
var currentMinutesOfDay = i * 60 + j;
|
||||
if (currentMinutesOfDay < minTimeMinutesOfDay) continue;
|
||||
if (currentMinutesOfDay >= maxTimeMinutesOfDay) continue;
|
||||
h = (i < 10 ? '0' : '') + i;
|
||||
m = (j < 10 ? '0' : '') + j;
|
||||
line_time(h, m);
|
||||
|
Loading…
Reference in New Issue
Block a user