mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 12:39:25 +01:00
fixed date(-time)-picker looses changes made in textfield directly, we now bind to change of input instead using onSelect of picker
also changed parsing of date(-time) strings to use parser of datetimepicker with our format, instead of date object, which does not understand our formats
This commit is contained in:
parent
0629f22bcc
commit
db3422fccb
@ -81,39 +81,8 @@ var et2_date = et2_inputWidget.extend(
|
|||||||
}
|
}
|
||||||
// Update internal value when changed
|
// Update internal value when changed
|
||||||
var self = this;
|
var self = this;
|
||||||
this.input_date.datepicker("option","onSelect", function(text,inst) {
|
this.input_date.bind('change', function(e){
|
||||||
var date_inst = null;
|
self.set_value(this.value);
|
||||||
if(inst.inst && inst.inst.selectedYear)
|
|
||||||
{
|
|
||||||
date_inst = inst.inst;
|
|
||||||
}
|
|
||||||
else if (inst.selectedYear)
|
|
||||||
{
|
|
||||||
date_inst = inst;
|
|
||||||
}
|
|
||||||
var d;
|
|
||||||
// Date could be in different places, if it's a datetime or just date
|
|
||||||
if(date_inst)
|
|
||||||
{
|
|
||||||
// calling setYear(), setMonth() and setDate() one after the other can lead to unexpected results,
|
|
||||||
// if day is not valid for selected month, eg. setMonth(1/*=Feb*/) on a date-object with day>28 gives March
|
|
||||||
d = new Date(date_inst.selectedYear, date_inst.selectedMonth, date_inst.selectedDay);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
d = new Date();
|
|
||||||
}
|
|
||||||
if(inst && typeof inst.hour != 'undefined')
|
|
||||||
{
|
|
||||||
d.setHours(inst.hour);
|
|
||||||
d.setMinutes(inst.minute);
|
|
||||||
}
|
|
||||||
else if(inst && (typeof inst.hour === 'undefined') && (typeof inst.settings.timepicker !== 'undefined'))
|
|
||||||
{
|
|
||||||
d.setHours(inst.settings.timepicker.hour);
|
|
||||||
d.setMinutes(inst.settings.timepicker.minute);
|
|
||||||
}
|
|
||||||
self.set_value(d);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Framewok skips nulls, but null needs to be processed here
|
// Framewok skips nulls, but null needs to be processed here
|
||||||
@ -159,12 +128,8 @@ var et2_date = et2_inputWidget.extend(
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
var text = new Date(_value);
|
this.date = new Date(jQuery.datepicker.parseDateTime(this.input_date.datepicker('option', 'dateFormat'),
|
||||||
|
this.input_date.datepicker('option', 'timeFormat'), _value));
|
||||||
// Handle timezone offset - times are already in user time
|
|
||||||
var localOffset = text.getTimezoneOffset() * 60000;
|
|
||||||
this.date.setTime(text.valueOf()+localOffset);
|
|
||||||
_value = Math.round(this.date.valueOf() / 1000);
|
|
||||||
}
|
}
|
||||||
} else if (typeof _value == 'object' && _value.date) {
|
} else if (typeof _value == 'object' && _value.date) {
|
||||||
this.date = _value.date;
|
this.date = _value.date;
|
||||||
|
Loading…
Reference in New Issue
Block a user