From 9a675784a6c6d86c474d4f52bcf3d9310761c33f Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 10 Jan 2022 14:54:29 +0100 Subject: [PATCH] fix: only use jquery once it is available publicpage.js is loaded very early and cannot rely on jquery being loaded already. Move the use of `$` into the `DomContentLoaded` handler. --- core/js/public/publicpage.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/core/js/public/publicpage.js b/core/js/public/publicpage.js index f74cba669ed09..7cca96e1d019c 100644 --- a/core/js/public/publicpage.js +++ b/core/js/public/publicpage.js @@ -31,16 +31,17 @@ window.addEventListener('DOMContentLoaded', function () { $('#remote_address').focus(); }); -}); -$(document).mouseup(function(e) { - var toggle = $('#body-public').find('.header-right .menutoggle'); - var container = toggle.next('.popovermenu'); + $(document).mouseup(function(e) { + var toggle = $('#body-public').find('.header-right .menutoggle'); + var container = toggle.next('.popovermenu'); + + // if the target of the click isn't the menu toggle, nor a descendant of the + // menu toggle, nor the container nor a descendant of the container + if (!toggle.is(e.target) && toggle.has(e.target).length === 0 && + !container.is(e.target) && container.has(e.target).length === 0) { + container.removeClass('open'); + } + }); - // if the target of the click isn't the menu toggle, nor a descendant of the - // menu toggle, nor the container nor a descendant of the container - if (!toggle.is(e.target) && toggle.has(e.target).length === 0 && - !container.is(e.target) && container.has(e.target).length === 0) { - container.removeClass('open'); - } });