Sha256: 65980510475ef279b4c8e183425b204feb747cd444581b2797e7aa65070518dd

Contents?: true

Size: 1 KB

Versions: 5

Compression:

Stored size: 1 KB

Contents

$(document).ready(function() {
  $('.datepicker_input').datepicker({
    timepicker: true,
    onShow(dp, animationCompleted){
      if (!animationCompleted) {
        $('.datepicker_input').removeClass('active');
        $(dp.el).addClass('active');;
      }
    }
  });

  $('.datepicker_input').each(function(i, el){
    $(el).data('datepicker').selectDate(parseFilterDate($(el).val()));
  });

  $('.sample-filter__clear-form').on('click', function(e) {
    e.preventDefault();
    document.location.href = $(this).parents('form').attr('action');
  });
})

function parseFilterDate(date_string) {
  var dateTimeReg = /(\d{2}).(\d{2}).(\d{4}) (\d{2}):(\d{2})/;
  var dateReg = /(\d{2}).(\d{2}).(\d{4})/;
  var dateTimeArray = dateTimeReg.exec(date_string);
  var dateArray = dateReg.exec(date_string);

  if(dateTimeArray){
    return new Date(dateTimeArray[3],dateTimeArray[2]-1,dateTimeArray[1],dateTimeArray[4],dateTimeArray[5]);
  } else if(dateArray){
    return new Date(dateArray[3],dateArray[2]-1,dateArray[1]);
  }
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sample_filter-0.1.4 lib/assets/javascripts/sample_filter/script.js
sample_filter-0.1.3 lib/assets/javascripts/sample_filter/script.js
sample_filter-0.1.2 lib/assets/javascripts/sample_filter/script.js
sample_filter-0.1.1 lib/assets/javascripts/sample_filter/script.js
sample_filter-0.1.0 lib/assets/javascripts/sample_filter/script.js