summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-12-28 13:27:10 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2014-12-28 13:27:10 (GMT)
commit39a12a43e284cb7f94b131b71dabed996e2f5306 (patch)
tree0d86f6dfdf9d3457a558a0ba3cd765cfbaa109fc
parentff87ed69f8216c259bba6ccde4162615c2f452e0 (diff)
downloadroundcubemail-plugins-kolab-39a12a43e284cb7f94b131b71dabed996e2f5306.tar.gz
Fix calendar week selector when crossing year boundary (#3915)
-rw-r--r--plugins/calendar/calendar_ui.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/plugins/calendar/calendar_ui.js b/plugins/calendar/calendar_ui.js
index 6590f0e..a2dc39c 100644
--- a/plugins/calendar/calendar_ui.js
+++ b/plugins/calendar/calendar_ui.js
@@ -3882,12 +3882,16 @@ function rcube_calendar_ui(settings)
base_date.setYear(minical.data('year'));
base_date.setHours(12);
base_date.setDate(base_date.getDate() - ((base_date.getDay() + 6) % 7) + datepicker_settings.firstDay);
- var day_off = base_date.getDay() - datepicker_settings.firstDay;
- var base_kw = iso8601Week(base_date);
- var target_kw = parseInt(cell.html());
- var diff = (target_kw - base_kw) * 7 * DAY_MS;
+ var base_kw = iso8601Week(base_date),
+ target_kw = parseInt(cell.html()),
+ wdiff = target_kw - base_kw;
+ if (wdiff > 10) // year jump
+ base_date.setYear(base_date.getFullYear() - 1);
+ else if (wdiff < -10)
+ base_date.setYear(base_date.getFullYear() + 1);
// select monday of the chosen calendar week
- var date = new Date(base_date.getTime() - day_off * DAY_MS + diff);
+ var day_off = base_date.getDay() - datepicker_settings.firstDay,
+ date = new Date(base_date.getTime() - day_off * DAY_MS + wdiff * 7 * DAY_MS);
fc.fullCalendar('gotoDate', date).fullCalendar('setDate', date).fullCalendar('changeView', 'agendaWeek');
minical.datepicker('setDate', date);
}