Commit 5a15482b authored by Tomáš Peterka's avatar Tomáš Peterka Committed by Tomáš Peterka

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

parent 25ae891b
...@@ -9,10 +9,13 @@ ...@@ -9,10 +9,13 @@
value: undefined, value: undefined,
checked: undefined, checked: undefined,
title: '', title: '',
name: '',
type: 'text', type: 'text',
required: false, required: false, // mandatory field
trim: false, trim: false, // trim content for spaces
focus: undefined 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) { .declareMethod('render', function (options) {
...@@ -27,13 +30,17 @@ ...@@ -27,13 +30,17 @@
focus: options.focus, focus: options.focus,
step: options.step, step: options.step,
hidden: options.hidden, hidden: options.hidden,
trim: options.trim || false trim: options.trim || false,
append: options.append,
prepend: options.prepend
}; };
return this.changeState(state_dict); return this.changeState(state_dict);
}) })
.onStateChange(function () { .onStateChange(function (modification_dict) {
var textarea = this.element.querySelector('input'); var textarea = this.element.querySelector('input'),
tmp; // general use short-scope variable
if (this.state.type === 'checkbox') { if (this.state.type === 'checkbox') {
textarea.checked = this.state.checked; textarea.checked = this.state.checked;
} else { } else {
...@@ -81,6 +88,22 @@ ...@@ -81,6 +88,22 @@
textarea.autofocus = false; textarea.autofocus = false;
textarea.blur(); 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 () { .declareService(function () {
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.1644.62757.27801</string> </value> <value> <string>961.40519.18664.56814</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1501232763.54</float> <float>1503560196.31</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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