plugins/calendar

Thomas Brüderli bruederli at kolabsys.com
Sun Dec 28 14:27:21 CET 2014


 plugins/calendar/calendar_ui.js |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

New commits:
commit 39a12a43e284cb7f94b131b71dabed996e2f5306
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Sun Dec 28 14:27:10 2014 +0100

    Fix calendar week selector when crossing year boundary (#3915)

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);
           }




More information about the commits mailing list