From 8b5e0312e7975d935bcfacb70ebbdbe9d2e87e50 Mon Sep 17 00:00:00 2001
From: Carlos Vega <carlos.vega@uni.lu>
Date: Thu, 11 Oct 2018 11:59:29 +0200
Subject: [PATCH] added auto resize of calendar and horizontal scroll

---
 smash/web/static/js/daily_planning.js | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/smash/web/static/js/daily_planning.js b/smash/web/static/js/daily_planning.js
index ffee4f88..1f8265a0 100644
--- a/smash/web/static/js/daily_planning.js
+++ b/smash/web/static/js/daily_planning.js
@@ -408,6 +408,10 @@ $(document).ready(function () {
             $(this).remove();
         },
         eventAfterAllRender: function(view){
+            //RESIZE COLUMNS AND ENABLE HORIZONTAL SCROLL
+            window.onresize = function(event) {
+                resizeCalendarColumns();
+            };
             
             //ADD EDIT BUTTONS
             $('.fc-resource-cell').not('.anchored').each(function(resourceColumn){
@@ -427,4 +431,16 @@ $(document).ready(function () {
         }
     });
 })
-;
\ No newline at end of file
+;
+
+//RESIZE COLUMNS AND ENABLE HORIZONTAL SCROLL
+function resizeCalendarColumns(){
+    if($('.fc-resource-cell').width() <= 150){
+        $('.fc-view-container').width(200*$('.fc-resource-cell').length);
+        $('#calendar').css('overflow-x', 'scroll');
+    }
+    if($('#calendar').width() > 200*$('.fc-resource-cell').length){
+        $('.fc-view-container').width("100%");
+        $('#calendar').css('overflow-x', 'null');
+    }
+}
-- 
GitLab