Sha256: 761d3d5a9ee424136fb8e7c87ae5e752724844e84c5cfed039e87e6f84809a18

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

$(document).ready ->

  map_view  = null
  lab_list = null
  data = $('#lab_list_container').data('labs')
  if data
    # can limit the number of labs to show with option show_labs in LabList constructor
    lab_list = new window.LabList( data.labs )
    map_view = new window.MapView( lab_list, data.zip_location )
    lab_list_view = new window.LabListView( lab_list )
    map_view.render()
  else
    console.log('no data')

  ###### handle ajax lab data search ########
  $("form#lab_data_search")
    .bind('ajax:beforeSend', (event, data)->
      zip_code = $(this).find('#zip_code').val()
      if (!zip_code.match(/\d{5}/))
        span = $('<span>Zip code should be 5 digits</span>')
        $('form#lab_data_search .error_message').append(span)
        span.fadeOut(4000)
        false
    )
    .bind('ajax:success', (event, data)->
      lab_list.setLabs(data.labs)
      map_view.center_point = data.zip_location
      map_view.render()
      $('form#lab_data_search input[type=submit]').prop("disabled", false)
    )
    .bind('ajax:complete', (event, data)->
    )

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
medivo-0.0.4 app/assets/javascripts/medivo/show_labs.coffee
medivo-0.0.3 app/assets/javascripts/medivo/show_labs.coffee