From 5eaf4cc489c0e8cd1ffdfde4355866cb5a481d96 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 18 Jan 2016 19:34:02 +0100 Subject: [PATCH] luci-base: cbi: refactor event handling js Signed-off-by: Jo-Philipp Wich --- .../luci-base/htdocs/luci-static/resources/cbi.js | 9 +++++++++ modules/luci-base/luasrc/view/cbi/dynlist.htm | 2 +- .../luasrc/view/cbi/firewall_zonelist.htm | 8 ++++---- modules/luci-base/luasrc/view/cbi/fvalue.htm | 2 +- modules/luci-base/luasrc/view/cbi/lvalue.htm | 4 ++-- modules/luci-base/luasrc/view/cbi/mvalue.htm | 4 ++-- .../luasrc/view/cbi/network_ifacelist.htm | 4 ++-- .../luci-base/luasrc/view/cbi/network_netlist.htm | 6 +++--- modules/luci-base/luasrc/view/cbi/tblsection.htm | 2 +- modules/luci-base/luasrc/view/cbi/tvalue.htm | 2 +- modules/luci-base/luasrc/view/cbi/upload.htm | 4 ++-- modules/luci-base/luasrc/view/cbi/value.htm | 14 ++++++++++---- 12 files changed, 38 insertions(+), 23 deletions(-) diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index 8bf94a6c5..fcf87adcb 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -515,6 +515,15 @@ function cbi_init() { } } + nodes = document.querySelectorAll('[data-change]'); + + for (var i = 0, node; (node = nodes[i]) !== undefined; i++) { + var events = node.getAttribute('data-change').split(' '); + for (var j = 0, event; (event = events[j]) !== undefined; j++) { + cbi_bind(node, event, cbi_d_update); + } + } + cbi_d_update(); } diff --git a/modules/luci-base/luasrc/view/cbi/dynlist.htm b/modules/luci-base/luasrc/view/cbi/dynlist.htm index e936c0c39..80cbee839 100644 --- a/modules/luci-base/luasrc/view/cbi/dynlist.htm +++ b/modules/luci-base/luasrc/view/cbi/dynlist.htm @@ -6,7 +6,7 @@ local val = vals[i] if (val and #val > 0) or (i == 1) then %> - />
diff --git a/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm b/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm index 7973437f4..b3b454008 100644 --- a/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm +++ b/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm @@ -27,7 +27,7 @@