summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs/luci-static
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-08-03 15:17:40 +0200
committerJo-Philipp Wich <jo@mein.io>2020-08-05 13:51:16 +0200
commitf2965b759ad26c5f11b1cea43c5e4e6c5ac3b3b8 (patch)
tree0eb0bba81f0dd33e40097f3470e6807596c95581 /modules/luci-base/htdocs/luci-static
parent1c879bbcc479a82a2f1479f5a080e937b5f9b44c (diff)
luci-base: ui.js: implement AbstractElement.setPlaceholder()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/ui.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js
index 91a93b9e90..7823182f04 100644
--- a/modules/luci-base/htdocs/luci-static/resources/ui.js
+++ b/modules/luci-base/htdocs/luci-static/resources/ui.js
@@ -102,6 +102,32 @@ var UIElement = baseclass.extend(/** @lends LuCI.ui.AbstractElement.prototype */
},
/**
+ * Set the current placeholder value of the input widget.
+ *
+ * @instance
+ * @memberof LuCI.ui.AbstractElement
+ * @param {string|string[]|null} value
+ * The placeholder to set for the input element. Only applicable to text
+ * inputs, not to radio buttons, selects or similar.
+ */
+ setPlaceholder: function(value) {
+ var node = this.node ? this.node.querySelector('input,textarea') : null;
+ if (node) {
+ switch (node.getAttribute('type') || 'text') {
+ case 'password':
+ case 'search':
+ case 'tel':
+ case 'text':
+ case 'url':
+ if (value != null && value != '')
+ node.setAttribute('placeholder', value);
+ else
+ node.removeAttribute('placeholder');
+ }
+ }
+ },
+
+ /**
* Check whether the current input value is valid.
*
* @instance