Week calendar: Fix interference between mobile mode and widget

This commit is contained in:
Raphael Michel
2022-05-25 17:29:56 +02:00
parent 3790d04ed2
commit 64aca08d34

View File

@@ -232,6 +232,16 @@ function setup_basics(el) {
});
}
function setup_week_calendar() {
// Week calendar
// On mobile, auto-collapse all days except today, if we have more than 15 events in total
if ($(window).width() < 992 && $(".week-calendar .event").length > 15) {
$(".week-calendar .weekday:not(.today)").each(function () {
$(this).prop("open", false);
});
}
}
$(function () {
"use strict";
@@ -528,12 +538,11 @@ $(function () {
}
});
// Week calendar
// On mobile, auto-collapse all days except today, if we have more than 15 events in total
if ($(window).width() < 992 && $(".week-calendar .event").length > 15) {
$(".week-calendar .weekday:not(.today)").each(function () {
$(this).prop("open", false);
});
// For a very weird reason, window width is 0 on an initial load of the widget
if ($(window).width() > 0) {
setup_week_calendar()
} else {
$(window).on('resize', setup_week_calendar)
}
// Day calendar