diff options
| author | Florian Eckert <fe@dev.tdt.de> | 2020-12-18 15:33:52 +0100 |
|---|---|---|
| committer | Florian Eckert <fe@dev.tdt.de> | 2021-01-13 11:59:02 +0100 |
| commit | e951236e3634924e2a26bf5d0890b3f25d39115d (patch) | |
| tree | 8188b6dddec3f09720ff32540e9cef00b0aecb84 /modules/luci-base/htdocs/luci-static/resources/form.js | |
| parent | bcb489a74dfd6d748fd7dd1f90b92f03a40ca17d (diff) | |
luci-base: add tooltip handling
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static/resources/form.js')
| -rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/form.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/form.js b/modules/luci-base/htdocs/luci-static/resources/form.js index 1588bc7bfb..4a4536bb94 100644 --- a/modules/luci-base/htdocs/luci-static/resources/form.js +++ b/modules/luci-base/htdocs/luci-static/resources/form.js @@ -3602,13 +3602,35 @@ var CBIFlagValue = CBIValue.extend(/** @lends LuCI.form.FlagValue.prototype */ { * @default 0 */ + /** + * Set a tooltip for the flag option. + * + * If set to a string, it will be used as-is as a tooltip. + * + * If set to a function, the function will be invoked and the return + * value will be shown as a tooltip. If the return value of the function + * is `null` no tooltip will be set. + * + * @name LuCI.form.TypedSection.prototype#tooltip + * @type string|function + * @default null + */ + /** @private */ renderWidget: function(section_id, option_index, cfgvalue) { + var tooltip = null; + + if (typeof(this.tooltip) == 'function') + tooltip = this.tooltip.apply(this, [section_id]); + else if (typeof(this.tooltip) == 'string') + tooltip = (arguments.length > 1) ? ''.format.apply(this.tooltip, this.varargs(arguments, 1)) : this.tooltip; + var widget = new ui.Checkbox((cfgvalue != null) ? cfgvalue : this.default, { id: this.cbid(section_id), value_enabled: this.enabled, value_disabled: this.disabled, validate: L.bind(this.validate, this, section_id), + tooltip: tooltip, disabled: (this.readonly != null) ? this.readonly : this.map.readonly }); |
