Commit 39906b30 authored by Tomáš Peterka's avatar Tomáš Peterka

[renderjs_ui] HTML5 Input can display pre/a-ppending text (useful for percentages)

parent b3312b0d
......@@ -9,10 +9,13 @@
value: undefined,
checked: undefined,
title: '',
name: '',
type: 'text',
required: false,
trim: false,
focus: undefined
required: false, // mandatory field
trim: false, // trim content for spaces
focus: undefined, // has focus by default
prepend: undefined, // text to prepend infront the field
append: undefined // text to apend after the field
})
.declareMethod('render', function (options) {
......@@ -27,13 +30,17 @@
focus: options.focus,
step: options.step,
hidden: options.hidden,
trim: options.trim || false
trim: options.trim || false,
append: options.append,
prepend: options.prepend
};
return this.changeState(state_dict);
})
.onStateChange(function () {
var textarea = this.element.querySelector('input');
.onStateChange(function (modification_dict) {
var textarea = this.element.querySelector('input'),
tmp; // general use short-scope variable
if (this.state.type === 'checkbox') {
textarea.checked = this.state.checked;
} else {
......@@ -81,6 +88,22 @@
textarea.autofocus = false;
textarea.blur();
}
if (modification_dict.append) {
this.element.classList.add('ui-input-has-appendinx');
tmp = document.createElement('i');
tmp.appendChild(document.createTextNode(modification_dict.append));
this.element.appendChild(tmp);
tmp = undefined;
}
if (modification_dict.prepend) {
this.element.classList.add('ui-input-has-prependinx');
tmp = document.createElement('i');
tmp.appendChild(document.createTextNode(modification_dict.append));
this.element.insertBefore(tmp, textarea);
tmp = undefined;
}
})
.declareService(function () {
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.1644.62757.27801</string> </value>
<value> <string>961.40519.18664.56814</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1501232763.54</float>
<float>1503560196.31</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment