Skip to content

Commit

Permalink
fix: only use jquery once it is available
Browse files Browse the repository at this point in the history
publicpage.js is loaded very early and cannot rely on jquery being loaded already.

Move the use of `$` into the `DomContentLoaded` handler.
  • Loading branch information
azul committed Jan 10, 2022
1 parent 6572f80 commit 9a67578
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions core/js/public/publicpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
});

0 comments on commit 9a67578

Please sign in to comment.