mirror of
https://github.com/frappe/air-datepicker.git
synced 2026-01-14 11:01:22 +08:00
add possibility to change time when clicking on selected date
This commit is contained in:
parent
5453ad8728
commit
f5c1ae4705
36
dist/js/datepicker.js
vendored
36
dist/js/datepicker.js
vendored
@ -434,8 +434,7 @@
|
|||||||
|
|
||||||
// Set new time values from Date
|
// Set new time values from Date
|
||||||
if (this.timepicker) {
|
if (this.timepicker) {
|
||||||
this.timepicker.hours = date.getHours();
|
this.timepicker._setTime(date);
|
||||||
this.timepicker.minutes = date.getMinutes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// On this step timepicker will set valid values in it's instance
|
// On this step timepicker will set valid values in it's instance
|
||||||
@ -445,7 +444,7 @@
|
|||||||
// Prevent from setting hours or minutes which values are lesser then `min` value or
|
// Prevent from setting hours or minutes which values are lesser then `min` value or
|
||||||
// greater then `max` value
|
// greater then `max` value
|
||||||
if (this.timepicker) {
|
if (this.timepicker) {
|
||||||
date.setHours(this.timepicker.hours)
|
date.setHours(this.timepicker.hours);
|
||||||
date.setMinutes(this.timepicker.minutes)
|
date.setMinutes(this.timepicker.minutes)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -626,9 +625,14 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_isSelected: function (checkDate, cellType) {
|
_isSelected: function (checkDate, cellType) {
|
||||||
return this.selectedDates.some(function (date) {
|
var res = false;
|
||||||
return datepicker.isSame(date, checkDate, cellType)
|
this.selectedDates.some(function (date) {
|
||||||
})
|
if (datepicker.isSame(date, checkDate, cellType)) {
|
||||||
|
res = date;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return res;
|
||||||
},
|
},
|
||||||
|
|
||||||
_setInputValue: function () {
|
_setInputValue: function () {
|
||||||
@ -1691,6 +1695,12 @@
|
|||||||
this.d._trigger('clickCell', selectedDate);
|
this.d._trigger('clickCell', selectedDate);
|
||||||
} else if (alreadySelected && this.opts.toggleSelected){
|
} else if (alreadySelected && this.opts.toggleSelected){
|
||||||
this.d.removeDate(selectedDate);
|
this.d.removeDate(selectedDate);
|
||||||
|
} else if (alreadySelected && !this.opts.toggleSelected) {
|
||||||
|
this.d.lastSelectedDate = alreadySelected;
|
||||||
|
if (this.d.opts.timepicker) {
|
||||||
|
this.d.timepicker._setTime(alreadySelected);
|
||||||
|
this.d.timepicker.update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -1877,7 +1887,7 @@
|
|||||||
datepicker.Timepicker.prototype = {
|
datepicker.Timepicker.prototype = {
|
||||||
init: function () {
|
init: function () {
|
||||||
var input = 'input';
|
var input = 'input';
|
||||||
this._setInitialTime(this.d.date);
|
this._setTime(this.d.date);
|
||||||
this._buildHTML();
|
this._buildHTML();
|
||||||
|
|
||||||
if (navigator.userAgent.match(/trident/gi)) {
|
if (navigator.userAgent.match(/trident/gi)) {
|
||||||
@ -1891,7 +1901,7 @@
|
|||||||
this.$ranges.on('mouseout blur', this._onMouseOutRange.bind(this));
|
this.$ranges.on('mouseout blur', this._onMouseOutRange.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
_setInitialTime: function (date, parse) {
|
_setTime: function (date) {
|
||||||
var _date = dp.getParsedDate(date);
|
var _date = dp.getParsedDate(date);
|
||||||
|
|
||||||
this._handleDate(date);
|
this._handleDate(date);
|
||||||
@ -1984,15 +1994,13 @@
|
|||||||
_updateRanges: function () {
|
_updateRanges: function () {
|
||||||
this.$hours.attr({
|
this.$hours.attr({
|
||||||
min: this.minHours,
|
min: this.minHours,
|
||||||
max: this.maxHours,
|
max: this.maxHours
|
||||||
value: this.hours
|
}).val(this.hours);
|
||||||
});
|
|
||||||
|
|
||||||
this.$minutes.attr({
|
this.$minutes.attr({
|
||||||
min: this.minMinutes,
|
min: this.minMinutes,
|
||||||
max: this.maxMinutes,
|
max: this.maxMinutes
|
||||||
value: this.minutes
|
}).val(this.minutes)
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
4
dist/js/datepicker.min.js
vendored
4
dist/js/datepicker.min.js
vendored
File diff suppressed because one or more lines are too long
@ -294,6 +294,12 @@
|
|||||||
this.d._trigger('clickCell', selectedDate);
|
this.d._trigger('clickCell', selectedDate);
|
||||||
} else if (alreadySelected && this.opts.toggleSelected){
|
} else if (alreadySelected && this.opts.toggleSelected){
|
||||||
this.d.removeDate(selectedDate);
|
this.d.removeDate(selectedDate);
|
||||||
|
} else if (alreadySelected && !this.opts.toggleSelected) {
|
||||||
|
this.d.lastSelectedDate = alreadySelected;
|
||||||
|
if (this.d.opts.timepicker) {
|
||||||
|
this.d.timepicker._setTime(alreadySelected);
|
||||||
|
this.d.timepicker.update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
@ -434,8 +434,7 @@
|
|||||||
|
|
||||||
// Set new time values from Date
|
// Set new time values from Date
|
||||||
if (this.timepicker) {
|
if (this.timepicker) {
|
||||||
this.timepicker.hours = date.getHours();
|
this.timepicker._setTime(date);
|
||||||
this.timepicker.minutes = date.getMinutes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// On this step timepicker will set valid values in it's instance
|
// On this step timepicker will set valid values in it's instance
|
||||||
@ -445,7 +444,7 @@
|
|||||||
// Prevent from setting hours or minutes which values are lesser then `min` value or
|
// Prevent from setting hours or minutes which values are lesser then `min` value or
|
||||||
// greater then `max` value
|
// greater then `max` value
|
||||||
if (this.timepicker) {
|
if (this.timepicker) {
|
||||||
date.setHours(this.timepicker.hours)
|
date.setHours(this.timepicker.hours);
|
||||||
date.setMinutes(this.timepicker.minutes)
|
date.setMinutes(this.timepicker.minutes)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -626,9 +625,14 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_isSelected: function (checkDate, cellType) {
|
_isSelected: function (checkDate, cellType) {
|
||||||
return this.selectedDates.some(function (date) {
|
var res = false;
|
||||||
return datepicker.isSame(date, checkDate, cellType)
|
this.selectedDates.some(function (date) {
|
||||||
})
|
if (datepicker.isSame(date, checkDate, cellType)) {
|
||||||
|
res = date;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return res;
|
||||||
},
|
},
|
||||||
|
|
||||||
_setInputValue: function () {
|
_setInputValue: function () {
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
datepicker.Timepicker.prototype = {
|
datepicker.Timepicker.prototype = {
|
||||||
init: function () {
|
init: function () {
|
||||||
var input = 'input';
|
var input = 'input';
|
||||||
this._setInitialTime(this.d.date);
|
this._setTime(this.d.date);
|
||||||
this._buildHTML();
|
this._buildHTML();
|
||||||
|
|
||||||
if (navigator.userAgent.match(/trident/gi)) {
|
if (navigator.userAgent.match(/trident/gi)) {
|
||||||
@ -41,7 +41,7 @@
|
|||||||
this.$ranges.on('mouseout blur', this._onMouseOutRange.bind(this));
|
this.$ranges.on('mouseout blur', this._onMouseOutRange.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
_setInitialTime: function (date, parse) {
|
_setTime: function (date) {
|
||||||
var _date = dp.getParsedDate(date);
|
var _date = dp.getParsedDate(date);
|
||||||
|
|
||||||
this._handleDate(date);
|
this._handleDate(date);
|
||||||
@ -134,15 +134,13 @@
|
|||||||
_updateRanges: function () {
|
_updateRanges: function () {
|
||||||
this.$hours.attr({
|
this.$hours.attr({
|
||||||
min: this.minHours,
|
min: this.minHours,
|
||||||
max: this.maxHours,
|
max: this.maxHours
|
||||||
value: this.hours
|
}).val(this.hours);
|
||||||
});
|
|
||||||
|
|
||||||
this.$minutes.attr({
|
this.$minutes.attr({
|
||||||
min: this.minMinutes,
|
min: this.minMinutes,
|
||||||
max: this.maxMinutes,
|
max: this.maxMinutes
|
||||||
value: this.minutes
|
}).val(this.minutes)
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -75,6 +75,20 @@
|
|||||||
<h2>{timepicker: true}</h2>
|
<h2>{timepicker: true}</h2>
|
||||||
<div class="datepicker-here" data-timepicker="true"></div>
|
<div class="datepicker-here" data-timepicker="true"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="vt-tile">
|
||||||
|
<h2>{onChange: ..., toggleSelected: false, range: true}</h2>
|
||||||
|
<input id="dp-5" class="datepicker-here" data-timepicker="true" />
|
||||||
|
<script type="text/javascript">
|
||||||
|
$('#dp-5').datepicker({
|
||||||
|
toggleSelected: false,
|
||||||
|
inline: true,
|
||||||
|
range: true,
|
||||||
|
onSelect: function (fd) {
|
||||||
|
log(fd)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
<div class="vt-tile">
|
<div class="vt-tile">
|
||||||
<h2>{timepicker: true}</h2>
|
<h2>{timepicker: true}</h2>
|
||||||
<input class="datepicker-here" data-timepicker="true" />
|
<input class="datepicker-here" data-timepicker="true" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user