commit 0a828a5a985df92bbc0e2f34706e83fc08be1d8c
Author: Martin Sebela <msebela@zcu.cz>
Date:   Sat May 16 17:30:23 2020 +0200

    Re #8076 - finishing new datepicker

diff --git a/website/public/css/bootstrap-datepicker3.css b/website/public/css/bootstrap-datepicker3.css
index b188379..3a760a4 100755
--- a/website/public/css/bootstrap-datepicker3.css
+++ b/website/public/css/bootstrap-datepicker3.css
@@ -5,7 +5,6 @@
  */
 
 .datepicker {
-  border-radius: 4px;
   direction: ltr;
   z-index: 1000;
 }
@@ -87,7 +86,6 @@
   text-align: center;
   width: 35px;
   height: 30px;
-  border-radius: 4px;
   border: none;
 }
 .table-striped .datepicker table tr td,
diff --git a/website/public/js/zcu-heatmap.js b/website/public/js/zcu-heatmap.js
index cad0abe..84deec9 100644
--- a/website/public/js/zcu-heatmap.js
+++ b/website/public/js/zcu-heatmap.js
@@ -279,3 +279,45 @@ function updateAvailableDataSets(available) {
   $('#submit-btn').prop('disabled', isOptionEnabled);
 
 }
+
+
+function formatDate(date) {
+  var day = String(date.getDate());
+  var month = String(date.getMonth() + 1);
+
+  if (day.length === 1) {
+    day = '0' + day;
+  }
+
+  if (month.length === 1) {
+    month = '0' + month;
+  }
+
+  return date.getFullYear() + '-' + month + '-' + day;
+}
+
+function initDatepicker(availableDatesSource) {
+  var availableDates = '';
+
+  $.ajax({
+    type: 'GET',
+    url: availableDatesSource,
+    success: function(result) {
+      availableDates = String(result).split(',');
+    }
+  });
+  
+  $('#date').datepicker({
+    format: 'yyyy-mm-dd',
+    language: 'cs',
+    beforeShowDay: function(date) {
+      if (availableDates.indexOf(formatDate(date)) < 0) {
+        return {enabled: false, tooltip: 'Žádná data'}
+      }
+      else {
+        return {enabled: true}
+      }
+    },
+    autoclose: true
+  });
+}
\ No newline at end of file
diff --git a/website/templates/heatmap.html.twig b/website/templates/heatmap.html.twig
index 736dada..da78b53 100644
--- a/website/templates/heatmap.html.twig
+++ b/website/templates/heatmap.html.twig
@@ -34,7 +34,7 @@
                   'type' : 'text',
                   'id' : 'date',
                   'attr' : {
-                    'class' : 'form-control',                 
+                    'class' : 'form-control',
                     'onChange' : 'checkDataSetsAvailability("' ~ path('available') ~ '")'
                   }
                 })
@@ -47,7 +47,7 @@
                 form_widget(form.time, {
                   'id' : 'time',
                   'attr' : {
-                    'class' : "custom-select"
+                    'class' : 'custom-select'
                   }
                 })
               }}             
@@ -59,7 +59,7 @@
                 form_widget(form.type, {
                   'id' : 'type',
                   'attr' : {
-                    'class' : "custom-select"                 
+                    'class' : 'custom-select'
                   }
                 })
               }}  
@@ -157,44 +157,12 @@
     <script src="{{ asset('js/leaflet-heat.js') }}"></script>
     <script src="{{ asset('js/zcu-heatmap.js') }}"></script>
     <script>
+        initDatepicker("{{ path('dates') }}");
         initMap();
         checkDataSetsAvailability("{{ path('available') }}")
         {% if submitted %}
           loadCurrentTimeHeatmap("{{ path('opendata') }}", "{{ path('positions') }}");
         {% endif %}
-      
-        var datesetDates = '23-04-2019,24-04-2019,25-04-2019,24-05-2020,27-05-2020'.split(',');
-
-        function formatDate(date) {
-          var day = String(date.getDate());
-          var month = String(date.getMonth() + 1);
-
-          if (day.length === 1) {
-            day = '0' + day;
-          }
-
-          if (month.length === 1) {
-            month = '0' + month;
-          }
-
-          return day + '-' + month + '-' + date.getFullYear();
-        }
-
-        $(function () {
-          $('#date').datepicker({
-            format: 'yyyy-mm-dd',
-            language: 'cs',
-            beforeShowDay: function(date) {
-              if (datesetDates.indexOf(formatDate(date)) < 0) {
-                return {enabled: false, tooltip: 'Žádná data'}
-              }
-              else {
-                return {enabled: true}
-              }
-            },
-            autoclose: true
-          })
-        });
   </script>
 
 {% endblock %}
\ No newline at end of file
