Files
growstuff/app/assets/javascripts/finish_planting.js.coffee
2015-07-23 23:22:45 +01:00

20 lines
491 B
CoffeeScript

# Clears the finished at date field when
# a planting is marked unfinished, and
# repopulates the field with a cached value
# marking unfinished is undone.
jQuery ->
previousValue = ''
$('#planting_finished').on('click', ->
finished = $('#planting_finished_at')
if @checked
if previousValue.length
date = previousValue
finished.val(date)
else
finished.trigger('focus')
else
previousValue = finished.val()
finished.val('')
)