implement formatting of numbers in read-only widget

This commit is contained in:
Ralf Becker 2015-03-18 22:04:47 +00:00
parent d40f41950b
commit fac9f796a8

View File

@ -149,8 +149,22 @@ var et2_number_ro = et2_textbox_ro.extend(
attributes: { attributes: {
min: { ignore: true}, min: { ignore: true},
max: { ignore: true}, max: { ignore: true},
precision: { ignore: true}, precision: {
name: "Precision",
type: "integer",
default: et2_no_init,
description: "Allowed precision - # of decimal places",
ignore: true
},
value: { type: "float" } value: { type: "float" }
},
set_value: function(_value)
{
if (typeof this.options.precision != 'undefined' && ""+_value != "")
{
_value = parseFloat(_value).toFixed(this.options.precision);
}
this._super.call(this, _value);
} }
}); });
et2_register_widget(et2_number_ro, ["int_ro", "integer_ro", "float_ro"]); et2_register_widget(et2_number_ro, ["int_ro", "integer_ro", "float_ro"]);