Improved responsiveness of /mealplan and /calendar (closes #372 and closes #373)

This commit is contained in:
Bernd Bestel
2019-09-24 09:21:57 +02:00
parent 6bb9d2c51d
commit 2a9f927a13
3 changed files with 39 additions and 9 deletions

View File

@@ -4,14 +4,15 @@ if (!Grocy.CalendarFirstDayOfWeek.isEmpty())
firstDay = parseInt(Grocy.CalendarFirstDayOfWeek);
}
$("#calendar").fullCalendar({
var calendar = $("#calendar").fullCalendar({
"themeSystem": "bootstrap4",
"header": {
"left": "month,basicWeek,listWeek",
"left": "month,agendaWeek,agendaDay,listWeek",
"center": "title",
"right": "prev,next"
},
"weekNumbers": Grocy.CalendarShowWeekNumbers,
"defaultView": ($(window).width() < 768) ? "agendaDay" : "month",
"firstDay": firstDay,
"eventLimit": true,
"eventSources": fullcalendarEventSources
@@ -35,3 +36,17 @@ $("#ical-button").on("click", function(e)
}
);
});
$(window).on("resize", function()
{
// Automatically switch the calendar to "basicDay" view on small screens
// and to "month" otherwise
if ($(window).width() < 768)
{
calendar.fullCalendar("changeView", "agendaDay");
}
else
{
calendar.fullCalendar("changeView", "month");
}
});