From 932fcbc78c0cda23f4f99f6bf34dbe439496a812 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Fri, 15 Jan 2016 00:05:02 +0000 Subject: [PATCH] Align planner view to weeks --- calendar/js/app.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/calendar/js/app.js b/calendar/js/app.js index f380b36523..be8c76cb55 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -3582,11 +3582,18 @@ jQuery.extend(app.classes.calendar,{ { return state.first; } + // Start here, in case we can't find anything better var d = app.calendar.View.start_date.call(this, state); + if(state.sortby && state.sortby === 'month' || [28,30,31].indexOf(state.planner_days||0) >= 0) { - d.setUTCDate(1); + d = app.classes.calendar.views.month.start_date.call(this,state); + } + else if (state.planner_days % 7 == 0) + { + // Week + d = app.classes.calendar.views.week.start_date.call(this,state); } else if (state.days) { @@ -3640,11 +3647,17 @@ jQuery.extend(app.classes.calendar,{ if([28,30,31].indexOf(state.planner_days||0) >= 0) { // Month view - d = new Date(d.getFullYear(),d.getUTCMonth() + 1, 0); + d = app.classes.calendar.views.month.end_date.call(this,state); } else { + d = new Date(state.first); d.setUTCDate(d.getUTCDate() + parseInt(state.planner_days)-1); + if (state.planner_days % 7 == 0) + { + // Week + d = app.calendar.date.end_of_week(d); + } } delete state.planner_days; }