Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 0a828a5a

Přidáno uživatelem Martin Sebela před asi 4 roky(ů)

Re #8076 - finishing new datepicker

Zobrazit rozdíly:

website/public/css/bootstrap-datepicker3.css
5 5
 */
6 6

  
7 7
.datepicker {
8
  border-radius: 4px;
9 8
  direction: ltr;
10 9
  z-index: 1000;
11 10
}
......
87 86
  text-align: center;
88 87
  width: 35px;
89 88
  height: 30px;
90
  border-radius: 4px;
91 89
  border: none;
92 90
}
93 91
.table-striped .datepicker table tr td,
website/public/js/zcu-heatmap.js
279 279
  $('#submit-btn').prop('disabled', isOptionEnabled);
280 280

  
281 281
}
282

  
283

  
284
function formatDate(date) {
285
  var day = String(date.getDate());
286
  var month = String(date.getMonth() + 1);
287

  
288
  if (day.length === 1) {
289
    day = '0' + day;
290
  }
291

  
292
  if (month.length === 1) {
293
    month = '0' + month;
294
  }
295

  
296
  return date.getFullYear() + '-' + month + '-' + day;
297
}
298

  
299
function initDatepicker(availableDatesSource) {
300
  var availableDates = '';
301

  
302
  $.ajax({
303
    type: 'GET',
304
    url: availableDatesSource,
305
    success: function(result) {
306
      availableDates = String(result).split(',');
307
    }
308
  });
309
  
310
  $('#date').datepicker({
311
    format: 'yyyy-mm-dd',
312
    language: 'cs',
313
    beforeShowDay: function(date) {
314
      if (availableDates.indexOf(formatDate(date)) < 0) {
315
        return {enabled: false, tooltip: 'Žádná data'}
316
      }
317
      else {
318
        return {enabled: true}
319
      }
320
    },
321
    autoclose: true
322
  });
323
}
website/templates/heatmap.html.twig
34 34
                  'type' : 'text',
35 35
                  'id' : 'date',
36 36
                  'attr' : {
37
                    'class' : 'form-control',                 
37
                    'class' : 'form-control',
38 38
                    'onChange' : 'checkDataSetsAvailability("' ~ path('available') ~ '")'
39 39
                  }
40 40
                })
......
47 47
                form_widget(form.time, {
48 48
                  'id' : 'time',
49 49
                  'attr' : {
50
                    'class' : "custom-select"
50
                    'class' : 'custom-select'
51 51
                  }
52 52
                })
53 53
              }}             
......
59 59
                form_widget(form.type, {
60 60
                  'id' : 'type',
61 61
                  'attr' : {
62
                    'class' : "custom-select"                 
62
                    'class' : 'custom-select'
63 63
                  }
64 64
                })
65 65
              }}  
......
157 157
    <script src="{{ asset('js/leaflet-heat.js') }}"></script>
158 158
    <script src="{{ asset('js/zcu-heatmap.js') }}"></script>
159 159
    <script>
160
        initDatepicker("{{ path('dates') }}");
160 161
        initMap();
161 162
        checkDataSetsAvailability("{{ path('available') }}")
162 163
        {% if submitted %}
163 164
          loadCurrentTimeHeatmap("{{ path('opendata') }}", "{{ path('positions') }}");
164 165
        {% endif %}
165
      
166
        var datesetDates = '23-04-2019,24-04-2019,25-04-2019,24-05-2020,27-05-2020'.split(',');
167

  
168
        function formatDate(date) {
169
          var day = String(date.getDate());
170
          var month = String(date.getMonth() + 1);
171

  
172
          if (day.length === 1) {
173
            day = '0' + day;
174
          }
175

  
176
          if (month.length === 1) {
177
            month = '0' + month;
178
          }
179

  
180
          return day + '-' + month + '-' + date.getFullYear();
181
        }
182

  
183
        $(function () {
184
          $('#date').datepicker({
185
            format: 'yyyy-mm-dd',
186
            language: 'cs',
187
            beforeShowDay: function(date) {
188
              if (datesetDates.indexOf(formatDate(date)) < 0) {
189
                return {enabled: false, tooltip: 'Žádná data'}
190
              }
191
              else {
192
                return {enabled: true}
193
              }
194
            },
195
            autoclose: true
196
          })
197
        });
198 166
  </script>
199 167

  
200 168
{% endblock %}

Také k dispozici: Unified diff