#= require medivo/models ########## Lab model ############## class window.Lab map_tooltip_template: Handlebars.compile("{{titleize name}}\n{{address_without_comma 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')