fixed just broken date-time widget and duration not accepting commas

This commit is contained in:
Ralf Becker 2014-01-30 16:24:58 +00:00
parent efd6bf87d5
commit 01fad19d9d

View File

@ -177,33 +177,28 @@ var et2_date = et2_inputWidget.extend(
} }
// Update input - popups do, but framework doesn't // Update input - popups do, but framework doesn't
_value = '';
if(this._type != 'date-timeonly') if(this._type != 'date-timeonly')
{ {
this._oldValue = jQuery.datepicker.formatDate(this.input_date.datepicker("option","dateFormat"),this.date); _value = jQuery.datepicker.formatDate(this.input_date.datepicker("option","dateFormat"),this.date);
} }
if(this._type != 'date') if(this._type != 'date')
{ {
var current = this.input_date.val(); if(this._type != 'date-timeonly') _value += ' ';
if(this._type != 'date-timeonly')
{ _value += jQuery.datepicker.formatTime(this.input_date.datepicker("option","timeFormat"),{
current += " ";
}
else
{
current = '';
}
this._oldValue = current + jQuery.datepicker.formatTime(this.input_date.datepicker("option","timeFormat"),{
hour: this.date.getHours(), hour: this.date.getHours(),
minute: this.date.getMinutes(), minute: this.date.getMinutes(),
seconds: 0, seconds: 0,
timezone: 0 timezone: 0
}); });
} }
this.input_date.val(this._oldValue); this.input_date.val(_value);
if(this._oldValue !== et2_no_init && old_value != this.getValue()) if(this._oldValue !== et2_no_init && old_value != this.getValue())
{ {
this.change(this.input_date); this.change(this.input_date);
} }
this._oldValue = _value;
}, },
getValue: function() { getValue: function() {
@ -310,7 +305,8 @@ var et2_date_duration = et2_date.extend(
createInputWidget: function() { createInputWidget: function() {
// Create nodes // Create nodes
this.node = $j(document.createElement("span")); this.node = $j(document.createElement("span"));
this.duration = $j(document.createElement("input")).attr("size", "2"); this.duration = $j(document.createElement("input"))
.attr({type: 'number', size: 3, style: 'width: 3em'});
this.node.append(this.duration); this.node.append(this.duration);
if(this.options.display_format.length > 1) if(this.options.display_format.length > 1)
@ -419,7 +415,6 @@ var et2_date_duration = et2_date.extend(
} }
} }
// Figure out best unit for display // Figure out best unit for display
var _unit = this.options.display_format == "d" ? "d" : "h"; var _unit = this.options.display_format == "d" ? "d" : "h";
if (this.options.data_format.indexOf('m') > -1 && _value && _value < 60) if (this.options.data_format.indexOf('m') > -1 && _value && _value < 60)
@ -450,7 +445,7 @@ var et2_date_duration = et2_date.extend(
* Change displayed value into storage value and return * Change displayed value into storage value and return
*/ */
getValue: function() { getValue: function() {
var value = this.duration.val(); var value = this.duration.val().replace(',', '.');
if(value === '') if(value === '')
{ {
return this.options.empty_not_0 ? null : 0; return this.options.empty_not_0 ? null : 0;
@ -488,9 +483,7 @@ var et2_date_duration_ro = et2_date_duration.extend([et2_IDetachedDOM],
* @memberOf et2_date_duration_ro * @memberOf et2_date_duration_ro
*/ */
createInputWidget: function() { createInputWidget: function() {
this.node = $j(document.createElement("span")); this.node = $j(document.createElement("span"));
var display = this._convert_to_display(this.options.value);
this.duration = $j(document.createElement("span")).appendTo(this.node); this.duration = $j(document.createElement("span")).appendTo(this.node);
this.format = $j(document.createElement("span")).appendTo(this.node); this.format = $j(document.createElement("span")).appendTo(this.node);
}, },