#= require ./behavior

class window.DateRangeValidator extends window.Behavior

  init: ->
    @startDom().change =>
      @endDom().datepicker("option", "minDate", @startDate())

    @endDom().change =>
      @startDom().datepicker("option", "maxDate", @endDate())

  startDom: ->
    @$startDom ?= @domData('date-range-start-target')

  endDom: ->
    @$endDom ?= @domData('date-range-end-target')

  startDate: ->
    @startDom().datepicker('getDate')

  endDate: ->
    @endDom().datepicker('getDate')
