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/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
}

Také k dispozici: Unified diff