Sha256: fa8a50f3414507d08b4c71cd0278771db1f15e9867e5686d71e84e06c9346bc0

Contents?: true

Size: 1.91 KB

Versions: 1

Compression:

Stored size: 1.91 KB

Contents

#= require medivo/models

##########  Lab model ##############
class window.Lab
  map_tooltip_template: Handlebars.compile("{{lab_name}}\n{{titleize address}}\n{{titleize city}},{{state}} ")
  index = null
  marker = null
  point = null

  constructor: (@data) ->

  clearMarker: ->
    if @marker
      @marker.setMap(null)
      @marker = null

  setMarker: (map, markerBounds, index) ->
    @point = new google.maps.LatLng(@data.lat, @data.lng)
    @marker = this.makeMarker(map, index)
    if markerBounds
      markerBounds.extend(@point)

  makeMarker: (map, index) ->
    new google.maps.Marker({
      position: @point
      map: map
      title: this.map_tooltip_template(@data)
      icon: this.makeIcon(index)
    })

  makeIcon: ->
    "/assets/medivo/lab.png"

  icon: ->
    return @marker.icon if @marker
    this.makeIcon()


##########  OrderedLab model ##############
class window.OrderedLab extends Lab
  constructor: (@data, index) -> @index = index

  makeIcon: ->
    super() unless window.isNumber(@index)
    "/assets/medivo/marker" + this.makeLetter(@index) + ".png"

  makeLetter: (number) ->
    if (number >= 0 && number <= 26)
      return String.fromCharCode(number + 65)
    return ''

  icon: ->
    return @marker.icon if @marker
    this.makeIcon(@index)


##########  LabList model ##############
class window.LabList extends List

  constructor: (lab_info, show_number, model, tracker_id)->
    model = Lab unless model
    tracker_id = 'lab_list_tracker' unless tracker_id
    super( lab_info, show_number, model, tracker_id)

  # use this method to set new lab info
  setList: (lab_info)->
    this.clearMarkers()
    super(lab_info)

  clearMarkers: ->
    $.each( @list, (index, lab)-> lab.clearMarker() )


##########  OrderedLabList model ##############
class window.OrderedLabList extends LabList
  constructor: (lab_info, show_number)->
    super( lab_info, show_number, OrderedLab, 'ordered_lab_list_tracker')


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
medivo-0.2.24 app/assets/javascripts/medivo/lab_list/models.coffee