Revision of limit min/maxdatetime by voda

This commit is contained in:
Trent Richardson 2011-03-23 08:48:57 -04:00
parent cc80af42fe
commit 4bca74de36

View file

@ -514,8 +514,7 @@ $.extend(Timepicker.prototype, {
//########################################################################
_limitMinMaxDateTime: function(dp_inst, adjustSliders){
var o = this._defaults,
dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay),
tp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay, this.hour, this.minute, this.second, 0);
dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay);
if(this._defaults.minDateTime !== null && dp_date){
var minDateTime = this._defaults.minDateTime,
@ -527,14 +526,22 @@ $.extend(Timepicker.prototype, {
this.secondMinOriginal = o.secondMin;
}
if(minDateTimeDate.getTime() == dp_date.getTime()){
if(dp_inst.settings.timeOnly || minDateTimeDate.getTime() == dp_date.getTime()) {
this._defaults.hourMin = minDateTime.getHours();
if (this.hour <= this._defaults.hourMin) {
this.hour = this._defaults.hourMin;
this._defaults.minuteMin = minDateTime.getMinutes();
if (this.minute <= this._defaults.minuteMin) {
this.minute = this._defaults.minuteMin;
this._defaults.secondMin = minDateTime.getSeconds();
if(this.hour < this._defaults.hourMin) this.hour = this._defaults.hourMin;
if(this.minute < this._defaults.minuteMin) this.minute = this._defaults.minuteMin;
} else {
if(this.second < this._defaults.secondMin) this.second = this._defaults.secondMin;
this._defaults.secondMin = this.secondMinOriginal;
}
} else {
this._defaults.minuteMin = this.minuteMinOriginal;
this._defaults.secondMin = this.secondMinOriginal;
}
}else{
this._defaults.hourMin = this.hourMinOriginal;
this._defaults.minuteMin = this.minuteMinOriginal;
@ -552,14 +559,22 @@ $.extend(Timepicker.prototype, {
this.secondMaxOriginal = o.secondMax;
}
if(maxDateTimeDate.getTime() == dp_date.getTime()){
if(dp_inst.settings.timeOnly || maxDateTimeDate.getTime() == dp_date.getTime()){
this._defaults.hourMax = maxDateTime.getHours();
if (this.hour >= this._defaults.hourMax) {
this.hour = this._defaults.hourMax;
this._defaults.minuteMax = maxDateTime.getMinutes();
this._defaults.secondMax = maxDateTime.getSeconds();
if(this.hour > this._defaults.hourMax){ this.hour = this._defaults.hourMax; }
if(this.minute > this._defaults.minuteMax) this.minute = this._defaults.minuteMax;
if (this.minute >= this._defaults.minuteMax) {
this.minute = this._defaults.minuteMax;
this._defaults.secondMin = maxDateTime.getSeconds();
} else {
if(this.second > this._defaults.secondMax) this.second = this._defaults.secondMax;
this._defaults.secondMax = this.secondMaxOriginal;
}
} else {
this._defaults.minuteMax = this.minuteMaxOriginal;
this._defaults.secondMax = this.secondMaxOriginal;
}
}else{
this._defaults.hourMax = this.hourMaxOriginal;
this._defaults.minuteMax = this.minuteMaxOriginal;
@ -575,6 +590,7 @@ $.extend(Timepicker.prototype, {
},
//########################################################################
// when a slider moves, set the internal time...
// on time change is also called when the time is updated in the text field
@ -601,6 +617,7 @@ $.extend(Timepicker.prototype, {
if (minute !== false) this.minute = minute;
if (second !== false) this.second = second;
if (timezone !== false) this.timezone = timezone;
this._limitMinMaxDateTime(this.inst, true);
}
if (this._defaults.ampm) this.ampm = ampm;