Sha256: 13aa7bd8130542d8280ba81fd425d528a6e215b3d2bc021b006b80723c856921
Contents?: true
Size: 1.74 KB
Versions: 1
Compression:
Stored size: 1.74 KB
Contents
########## handlebars helpers ############## String.prototype.capitalize = -> this.charAt(0).toUpperCase() + this.substring(1).toLowerCase() String.prototype.titleize = -> res = [] parts = this.split(" ") $.each(parts, (index, part)-> res.push(part.capitalize()) ) res.join(" ") Handlebars.registerHelper("rounded", (number)-> if (number != undefined) parseFloat(number).toFixed(2) ) Handlebars.registerHelper("titleize", (string)-> if (string != undefined) string.titleize() ) Handlebars.registerHelper("address_without_comma", (lab)-> if (this.address != undefined) this.address.replace(/(\s*,\s*$)/g, "").titleize() ) ########## Lab model ############## class window.Lab constructor: (@data)-> marker: null map_tooltip_template: Handlebars.compile("{{titleize name}}\n{{address_without_comma address}}\n{{titleize city}},{{state}} ") clearMarker: -> if this.marker this.marker.setMap(null) this.marker = null setMarker: (map, markerBounds)-> this.point = new google.maps.LatLng(@data.lat, @data.lng) this.marker = this.makeMarker(map) if markerBounds markerBounds.extend(this.point) makeMarker: (map)-> new google.maps.Marker({ position: this.point map: map title: this.map_tooltip_template(@data) icon: this.makeIcon() }) makeIcon: -> new google.maps.MarkerImage("/assets/medivo/lab.png") ########## LabList model ############## class window.LabList constructor: (lab_info)-> @labs = [] this.setLabs(lab_info) setLabs: (lab_info)-> this.clearMarkers() labs = @labs = [] $.each( lab_info, (index, lab_data)-> labs.push(new Lab(lab_data)) ) clearMarkers: -> $.each( @labs, (index, lab)-> lab.clearMarker() )
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
medivo-0.0.2 | app/assets/javascripts/medivo/models.coffee |