2021-03-11 05:43:45 +01:00
|
|
|
import $ from "jquery";
|
|
|
|
|
2020-07-02 01:45:54 +02:00
|
|
|
$(() => {
|
2020-07-15 01:29:15 +02:00
|
|
|
$(".portico-header li.logout").on("click", () => {
|
2020-07-20 21:24:26 +02:00
|
|
|
$("#logout_form").trigger("submit");
|
2017-09-29 01:31:55 +02:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2021-08-05 02:14:15 +02:00
|
|
|
$(".dropdown").on("click", (e) => {
|
2019-11-02 00:06:25 +01:00
|
|
|
const $this = $(e.target);
|
2021-07-16 14:33:52 +02:00
|
|
|
const dropdown_is_shown = $this.closest("ul .dropdown").hasClass("show");
|
2017-09-29 01:31:55 +02:00
|
|
|
|
2021-08-05 02:14:15 +02:00
|
|
|
if (!dropdown_is_shown) {
|
2021-06-23 23:00:05 +02:00
|
|
|
$this.closest("ul .dropdown").addClass("show");
|
2021-08-05 02:14:15 +02:00
|
|
|
} else if (dropdown_is_shown) {
|
2021-06-23 23:00:05 +02:00
|
|
|
$this.closest("ul .dropdown").removeClass("show");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$(".nav-dropdown").on("mouseover", (e) => {
|
|
|
|
const $this = $(e.target);
|
2021-08-05 02:14:15 +02:00
|
|
|
// We switch to a vertical sidebar menu at width <= 1024px
|
|
|
|
const in_vertical_orientation = window.matchMedia("(max-width: 1024px)").matches;
|
|
|
|
// We only support mouseover events if we are in a horizontal
|
|
|
|
// orientation (width > 1024px) and if the primary input mechanism
|
|
|
|
// can hover over elements.
|
|
|
|
const hover_supported = window.matchMedia("(hover: hover)").matches;
|
2021-07-16 14:33:52 +02:00
|
|
|
const dropdown_is_shown = $this.closest("ul .dropdown").hasClass("show");
|
|
|
|
|
2021-08-05 02:14:15 +02:00
|
|
|
if (!dropdown_is_shown && !in_vertical_orientation && hover_supported) {
|
2021-06-23 23:00:05 +02:00
|
|
|
$this.closest("ul .dropdown").addClass("show");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$(".nav-dropdown").on("mouseout", (e) => {
|
|
|
|
const $this = $(e.target);
|
2021-08-05 02:14:15 +02:00
|
|
|
// We switch to a vertical sidebar menu at width <= 1024px
|
|
|
|
const in_vertical_orientation = window.matchMedia("(max-width: 1024px)").matches;
|
|
|
|
// We only support mouseout events if we are in a horizontal
|
|
|
|
// orientation (width > 1024px) and if the primary input mechanism
|
|
|
|
// can hover over elements.
|
|
|
|
const hover_supported = window.matchMedia("(hover: hover)").matches;
|
2021-07-16 14:33:52 +02:00
|
|
|
const dropdown_is_shown = $this.closest("ul .dropdown").hasClass("show");
|
|
|
|
|
2021-08-05 02:14:15 +02:00
|
|
|
if (dropdown_is_shown && !in_vertical_orientation && hover_supported) {
|
2021-06-23 23:00:05 +02:00
|
|
|
$this.closest("ul .dropdown").removeClass("show");
|
2017-09-29 01:31:55 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|