diff --git a/src/pretix/static/pretixpresale/js/ui/main.js b/src/pretix/static/pretixpresale/js/ui/main.js index f757c0481..72204ba62 100644 --- a/src/pretix/static/pretixpresale/js/ui/main.js +++ b/src/pretix/static/pretixpresale/js/ui/main.js @@ -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