From 91ffe91f7d8fba85f249fbdce28ef166f701be59 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 28 Sep 2015 15:31:16 +0200 Subject: [PATCH] [IMP] web_calendar: calendar dimension/scroll/resize The calendar has now a minimum height so that it appears bigger in mobile. In mobile the height cannot be computed to maximum because the webclient has not 100% fixed height. The height has been set so that in appears maximum on a 720p android mobile on chrome at the time of this commit. The calendar is now also resizing itself correctly after a window resize. Before this commit, it was impossible to scroll the calendar horizontally if needed. Notice that the solution breaks the full calendar layout and require JS scrolling so that the events are still positionned correctly. --- addons/web_calendar/static/src/js/web_calendar.js | 15 ++++++++++++++- .../static/src/less/web_calendar.less | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/addons/web_calendar/static/src/js/web_calendar.js b/addons/web_calendar/static/src/js/web_calendar.js index 2a49464a99e..b6934d83349 100644 --- a/addons/web_calendar/static/src/js/web_calendar.js +++ b/addons/web_calendar/static/src/js/web_calendar.js @@ -288,7 +288,16 @@ var CalendarView = View.extend({ var title = self.title + ' (' + ((mode === "week")? _t("Week ") : "") + view.title + ")"; self.set({'title': title}); - self.$calendar.fullCalendar('option', 'height', parseInt(self.$('.o_calendar_view').height())); + self.$calendar.fullCalendar('option', 'height', Math.max(290, parseInt(self.$('.o_calendar_view').height()))); + + setTimeout(function() { + var $fc_view = self.$calendar.find('.fc-view'); + var width = $fc_view.find('> table').width(); + $fc_view.find('> div').css('width', (width > $fc_view.width())? width : '100%'); // 100% = fullCalendar default + }, 0); + }, + windowResize: function() { + self.$calendar.fullCalendar('render'); }, eventDrop: function (event, _day_delta, _minute_delta, _all_day, _revertFunc) { var data = self.get_event_data(event); @@ -416,7 +425,11 @@ var CalendarView = View.extend({ }); self.$calendar.fullCalendar('updateEvent', event_obj); } else { // New event object to create + var $fc_view = self.$calendar.find('.fc-view'); + var scrollPosition = $fc_view.scrollLeft(); + $fc_view.scrollLeft(0); self.$calendar.fullCalendar('renderEvent', new_event); + $fc_view.scrollLeft(scrollPosition); // By forcing attribution of this event to this source, we // make sure that the event will be removed when the source // will be removed (which occurs at each do_search) diff --git a/addons/web_calendar/static/src/less/web_calendar.less b/addons/web_calendar/static/src/less/web_calendar.less index 275ad04c3ca..d9eb5f1f9d2 100644 --- a/addons/web_calendar/static/src/less/web_calendar.less +++ b/addons/web_calendar/static/src/less/web_calendar.less @@ -45,6 +45,9 @@ width: 18px; height: 18px; } + .fc-view { + overflow-x: auto; + } } }