From f4137a9225393668bb666c0bd3cd2a21ac6d5fb0 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 27 Mar 2020 17:57:48 +0100 Subject: [PATCH] luci-theme-bootstrap: dynamically adjust body margin Fixes: #3722 Signed-off-by: Jo-Philipp Wich (cherry picked from commit c99684dff73b4d0ca6f73cd3cde667f685aa5b4b) --- .../luasrc/view/themes/bootstrap/json-menu.htm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/json-menu.htm b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/json-menu.htm index b38406f65..02b81b881 100644 --- a/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/json-menu.htm +++ b/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/json-menu.htm @@ -98,6 +98,13 @@ ul.style.display = ''; } + function adjust_body_margin(ev) { + var body = document.querySelector('body'), + head = document.querySelector('header'); + + body.style.marginTop = head.offsetHeight + 'px'; + } + document.addEventListener('luci-loaded', function(ev) { var tree = <%= luci.http.write_json(luci.dispatcher.context.authsession and luci.dispatcher.menu_json() or {}) %>, node = tree, @@ -114,6 +121,14 @@ if (node) render_tabmenu(node, url); } + + document.addEventListener('poll-start', adjust_body_margin); + document.addEventListener('poll-stop', adjust_body_margin); + document.addEventListener('uci-new-changes', adjust_body_margin); + document.addEventListener('uci-clear-changes', adjust_body_margin); + window.addEventListener('resize', adjust_body_margin); + + adjust_body_margin(ev); }); })(); -- 2.25.1