mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
silently fix skiped minutes or times with just one digit, as parser is quite pedantic ;-)
This commit is contained in:
parent
db3422fccb
commit
a659b49f51
@ -285,7 +285,7 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener],
|
|||||||
// Check for required
|
// Check for required
|
||||||
if(this.options && this.options.needed && !this.options.readonly && (this.getValue() == null || this.getValue().valueOf() == ''))
|
if(this.options && this.options.needed && !this.options.readonly && (this.getValue() == null || this.getValue().valueOf() == ''))
|
||||||
{
|
{
|
||||||
messages.push(this.egw().lang('input required'));
|
messages.push(this.egw().lang('Field must not be empty !!!'));
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
|
@ -83,6 +83,7 @@ var et2_date = et2_inputWidget.extend(
|
|||||||
var self = this;
|
var self = this;
|
||||||
this.input_date.bind('change', function(e){
|
this.input_date.bind('change', function(e){
|
||||||
self.set_value(this.value);
|
self.set_value(this.value);
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Framewok skips nulls, but null needs to be processed here
|
// Framewok skips nulls, but null needs to be processed here
|
||||||
@ -128,8 +129,28 @@ var et2_date = et2_inputWidget.extend(
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
this.date = new Date(jQuery.datepicker.parseDateTime(this.input_date.datepicker('option', 'dateFormat'),
|
try {
|
||||||
this.input_date.datepicker('option', 'timeFormat'), _value));
|
// silently fix skiped minutes or times with just one digit, as parser is quite pedantic ;-)
|
||||||
|
var fix_reg = / ([0-9]+)(:[0-9]*)?( ?(a|p)m?)?$/i;
|
||||||
|
var matches = _value.match(fix_reg);
|
||||||
|
if (matches && (matches[1].length < 2 || matches[2] === undefined || matches[2].length < 3 ||
|
||||||
|
matches[3] && matches[3] != 'am' && matches[3] != 'pm'))
|
||||||
|
{
|
||||||
|
if (matches[1].length < 2 && !matches[3]) matches[1] = '0'+matches[1];
|
||||||
|
if (matches[2] === undefined) matches[2] = ':00';
|
||||||
|
while (matches[2].length < 3) matches[2] = ':0'+matches[2].substr(1);
|
||||||
|
_value = _value.replace(fix_reg, ' '+matches[1]+matches[2]+matches[3]);
|
||||||
|
if (matches[4] !== undefined) matches[3] = matches[4].toLowerCase() == 'a' ? 'am' : 'pm';
|
||||||
|
}
|
||||||
|
var parsed = jQuery.datepicker.parseDateTime(this.input_date.datepicker('option', 'dateFormat'),
|
||||||
|
this.input_date.datepicker('option', 'timeFormat'), _value);
|
||||||
|
this.date = new Date(parsed);
|
||||||
|
this.set_validation_error(false);
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
this.set_validation_error(this.egw().lang("'%1' has an invalid format !!!",_value));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (typeof _value == 'object' && _value.date) {
|
} else if (typeof _value == 'object' && _value.date) {
|
||||||
this.date = _value.date;
|
this.date = _value.date;
|
||||||
|
@ -49,7 +49,8 @@ egw.extend('calendar', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
|
|||||||
function timePreferences(_egw)
|
function timePreferences(_egw)
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
"timeFormat": egw.preference("timeformat") == 12 ? "h:mm tt" : "HH:mm",
|
// timepicker does NOT work with spaces in timeformat
|
||||||
|
"timeFormat": egw.preference("timeformat") == 12 ? "h:mmtt" : "HH:mm",
|
||||||
"ampm": (egw.preference("timeformat") == "12"),
|
"ampm": (egw.preference("timeformat") == "12"),
|
||||||
"hourGrid": 4,
|
"hourGrid": 4,
|
||||||
"minuteGrid": 10
|
"minuteGrid": 10
|
||||||
@ -87,8 +88,8 @@ egw.extend('calendar', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
|
|||||||
onClose: function(date_text, picker) {
|
onClose: function(date_text, picker) {
|
||||||
// Only update if there's a change - "" if no date selected
|
// Only update if there's a change - "" if no date selected
|
||||||
if(date_text != "") self.set_value(new Date(
|
if(date_text != "") self.set_value(new Date(
|
||||||
picker.selectedYear,
|
picker.selectedYear,
|
||||||
picker.selectedMonth,
|
picker.selectedMonth,
|
||||||
picker.selectedDay,
|
picker.selectedDay,
|
||||||
self.input_hours ? self.input_hours.val() : 0,
|
self.input_hours ? self.input_hours.val() : 0,
|
||||||
self.input_minutes ? self.input_minutes.val() : 0,
|
self.input_minutes ? self.input_minutes.val() : 0,
|
||||||
@ -119,10 +120,10 @@ egw.extend('calendar', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
|
|||||||
"currentText": false,
|
"currentText": false,
|
||||||
"prevText": false,
|
"prevText": false,
|
||||||
"closeText": false,
|
"closeText": false,
|
||||||
|
|
||||||
// These ones are arrays.
|
// These ones are arrays.
|
||||||
// Integers are length. If lang() has no short translation, just trim full
|
// Integers are length. If lang() has no short translation, just trim full
|
||||||
"dayNames": false,
|
"dayNames": false,
|
||||||
"dayNamesShort":3,
|
"dayNamesShort":3,
|
||||||
"dayNamesMin": 2,
|
"dayNamesMin": 2,
|
||||||
"monthNames": false,
|
"monthNames": false,
|
||||||
@ -201,11 +202,11 @@ egw.extend('calendar', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
|
|||||||
var ready = this.module('ready', _wnd);
|
var ready = this.module('ready', _wnd);
|
||||||
ready.ready(translateCalendar,this);
|
ready.ready(translateCalendar,this);
|
||||||
ready.ready(translateTimepicker,this);
|
ready.ready(translateTimepicker,this);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
* setup a calendar / date-selection
|
* setup a calendar / date-selection
|
||||||
*
|
*
|
||||||
* @member of egw
|
* @member of egw
|
||||||
* @param _input
|
* @param _input
|
||||||
* @param _time
|
* @param _time
|
||||||
@ -218,7 +219,7 @@ egw.extend('calendar', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* setup a time-selection
|
* setup a time-selection
|
||||||
*
|
*
|
||||||
* @param _input
|
* @param _input
|
||||||
* @param _callback
|
* @param _callback
|
||||||
* @param _context
|
* @param _context
|
||||||
|
Loading…
Reference in New Issue
Block a user