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:53 (GMT)
commitb5e962391796235996d6c42534d3de3bbe89ae92 (patch)
tree37c6247aef4b3061fc934d4b47a6c627ac0331b8
parentf0a3f9cdf8ced773f70f837ea0dd47e4427cec83 (diff)
downloadroundcubemail-plugins-kolab-b5e962391796235996d6c42534d3de3bbe89ae92.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 855bacb..c36184a 100644
--- a/plugins/calendar/calendar_ui.js
+++ b/plugins/calendar/calendar_ui.js
@@ -2754,12 +2754,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);
}