From 8d9e9775ecd1cfc5b7139f71db19fec09d610a5e Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 17 May 2022 15:07:48 +0200 Subject: [PATCH] luci-base: form.js: minor tweaks for mobile styling - Annotate gridsection textvalue cells as CBI.DummyValue widgets - Replace `
` elements with newlines in `stripTags()` Signed-off-by: Jo-Philipp Wich (cherry picked from commit 9c136c9beaa7639aecc351c5725de33cfe4d2e5c) --- modules/luci-base/htdocs/luci-static/resources/form.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/luci-base/htdocs/luci-static/resources/form.js b/modules/luci-base/htdocs/luci-static/resources/form.js index 54bc3d4fc5..7970bc1876 100644 --- a/modules/luci-base/htdocs/luci-static/resources/form.js +++ b/modules/luci-base/htdocs/luci-static/resources/form.js @@ -287,9 +287,13 @@ var CBIAbstractElement = baseclass.extend(/** @lends LuCI.form.AbstractElement.p if (typeof(s) == 'string' && !s.match(/[<>]/)) return s; - var x = dom.parse('
' + s + '
'); + var x = dom.elem(s) ? s : dom.parse('
' + s + '
'); - return x.textContent || x.innerText || ''; + x.querySelectorAll('br').forEach(function(br) { + x.replaceChild(document.createTextNode('\n'), br); + }); + + return (x.textContent || x.innerText || '').replace(/([ \t]*\n)+/g, '\n'); }, /** @@ -3363,7 +3367,7 @@ var CBIGridSection = CBITableSection.extend(/** @lends LuCI.form.GridSection.pro 'data-title': (title != '') ? title : null, 'data-description': (descr != '') ? descr : null, 'data-name': opt.option, - 'data-widget': opt.typename || opt.__name__ + 'data-widget': 'CBI.DummyValue' }, (value != null) ? value : E('em', _('none'))); }, -- 2.30.2