Sha256: 2e9e6fcabddca4019b1f42f9986fcd29745d4f3c2d99f179cbe4d9270d9ca0c9

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

$(document).ready ->

  ####### value of the selected time ##########
  $('input:radio[name=appointment_time]:checked').val()

  ###### handle ajax appointment data search ########
  $("form#appointment_data_search")
    .bind('ajax:beforeSend', (event, data)->
      form = $(this)
      messages = []
      date = form.find('input#appointment_date').val()
      valid_date = Date.parseExact(date, "M/d/yyyy")
      messages.push("Date is invalid, must be mm/dd/yyyy format") unless valid_date
      # find the selected lab from the lab list and get the lab code
      selected_lab = $('#lab_list_container input:radio:checked')
      lab_code = $('#lab_list_container input:radio:checked').parent('li').find('form > input#lab_code').val()
      # set the value in this forms lab_code input field
      form.find('input#lab_code').val(lab_code)
      messages.push("Labcode is missing") unless lab_code
      if (messages.length > 0)
        span = $("<span>#{messages.join("<br>")}</span>")
        form.find('.error_message').append(span)
        span.fadeOut(4000)
        false
    )
    .bind('ajax:success', (event, data)->
      window.appointment_list.setList(data.times)
      # set the first appointment time as selected
      $('input:radio[name=appointment_time]:first').prop('checked',true)
      # re enable searching for appointment times
      $('form#appointment_data_search input[type=submit]').prop("disabled", false)
    )
    .bind('ajax:complete', (event, data)->
      # nothing here for now
    )

  ###### handle toggle to show more appointments ########
  $("#more_appointments_list_toggler").live("click", ->
    window.appointment_list.setShowNumber(window.max_appointment_show_number)
    $('input:radio[name=appointment_time]:first').prop('checked',true)
    $("#more_appointments_list_toggler").hide()
  )

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
medivo-0.1.4 app/assets/javascripts/medivo/lab_appointment/handlers.coffee