From: Jo-Philipp Wich Date: Tue, 24 Mar 2020 20:57:21 +0000 (+0100) Subject: luci-base: form.js / ui.js: tie form labels to widgets X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ceea8b7d5e90295c3e62bb1363b8a8114f5e629e;p=oweals%2Fluci.git luci-base: form.js / ui.js: tie form labels to widgets Signed-off-by: Jo-Philipp Wich (cherry picked from commit 22ba6fc40933bee02c3ea93bbda952bb44bf3af1) (cherry picked from commit 82fb5a67d39d965595d2ad833dbf930e559c0202) --- diff --git a/modules/luci-base/htdocs/luci-static/resources/form.js b/modules/luci-base/htdocs/luci-static/resources/form.js index 51893925f..e547260e4 100644 --- a/modules/luci-base/htdocs/luci-static/resources/form.js +++ b/modules/luci-base/htdocs/luci-static/resources/form.js @@ -1642,7 +1642,16 @@ var CBIValue = CBIAbstractValue.extend({ if (typeof(this.title) === 'string' && this.title !== '') { optionEl.appendChild(E('label', { 'class': 'cbi-value-title', - 'for': 'widget.cbid.%s.%s.%s'.format(config_name, section_id, this.option) + 'for': 'widget.cbid.%s.%s.%s'.format(config_name, section_id, this.option), + 'click': function(ev) { + var node = ev.currentTarget, + elem = node.nextElementSibling.querySelector('#' + node.getAttribute('for')) || node.nextElementSibling.querySelector('[data-widget-id="' + node.getAttribute('for') + '"]'); + + if (elem) { + elem.click(); + elem.focus(); + } + } }, this.titleref ? E('a', { 'class': 'cbi-title-ref', diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js index 97cdbf391..dfc3dbdf0 100644 --- a/modules/luci-base/htdocs/luci-static/resources/ui.js +++ b/modules/luci-base/htdocs/luci-static/resources/ui.js @@ -556,7 +556,8 @@ var UICheckbox = UIElement.extend(/** @lends LuCI.ui.Checkbox.prototype */ { 'name': this.options.name, 'type': 'checkbox', 'value': this.options.value_enabled, - 'checked': (this.value == this.options.value_enabled) ? '' : null + 'checked': (this.value == this.options.value_enabled) ? '' : null, + 'data-widget-id': this.options.id ? 'widget.' + this.options.id : null })); frameEl.appendChild(E('label', { 'for': id }));