diff options
author | Azul <azul@riseup.net> | 2022-01-10 14:54:29 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2022-01-11 10:34:44 +0000 |
commit | 08016ac02d428eb5a0053e10de85422a9f6bdd7d (patch) | |
tree | 61a2c7d4301a37cfbadd1ef22d92a48a4a5ace97 /core/js | |
parent | 67fcbacd4f17b0da12adf80f90a4aa30a2a4e784 (diff) | |
download | nextcloud-server-08016ac02d428eb5a0053e10de85422a9f6bdd7d.tar.gz nextcloud-server-08016ac02d428eb5a0053e10de85422a9f6bdd7d.zip |
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.
Signed-off-by: Azul <azul@riseup.net>
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/public/publicpage.js | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/core/js/public/publicpage.js b/core/js/public/publicpage.js index f74cba669ed..7cca96e1d01 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'); - } }); |