Sha256: cd15d99c7ca4003f9bf0a402df1800634d940c9db77e2a6a4202835be064a5d1

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 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)
      lab_list_view.render()
      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

1 entries across 1 versions & 1 rubygems

Version Path
medivo-0.0.7 app/assets/javascripts/medivo/show_labs.coffee