<commit_before>class LocalSupport.MarkerBuilder extends Gmaps.Google.Builders.Marker
  create_marker: ->
    @type = this.args.type
    options = _.extend @marker_options(), @rich_marker_options()
    @serviceObject = new RichMarker options
    
  rich_marker_options: ->
    marker = document.createElement("div")
    marker.setAttribute('class', 'custom_marker_content')
    marker.innerHTML = this.args.custom_marker
    {
      content: marker
      flat: true
      zIndex: this.args.index
    }

  create_infowindow: ->
    return null unless _.isString @args.custom_infowindow

    boxText = document.createElement("div")
    klass = if (@type == 'vol_op') then 'arrow_box_vol_op' else 'arrow_box'
    boxText.setAttribute("class", klass)
    boxText.innerHTML = @args.custom_infowindow
    @infowindow = new InfoBox(@infobox(boxText))
    @addCloseHandler(@infowindow)


  addCloseHandler: (infowindow) ->
    $(infowindow.content_).find('.close').click(->
      infowindow.close()
    )
    infowindow

  infobox: (boxText)->
    offset = switch @type
      when 'large_org' then new google.maps.Size(-151, -102)
      when 'small_org' then new google.maps.Size(-151, -84)
      when 'vol_op' then new google.maps.Size(-151,10)
    content: boxText
    pixelOffset: offset<commit_msg>Factor out infowindow logic into strategy object<commit_after>class LocalSupport.LargeOrgInfoWindowBuilder
  infobox: (boxText)->
    content: boxText
    pixelOffset: new google.maps.Size(-151,-102)
  klass: ->
    "arrow_box"

class LocalSupport.SmallOrgInfoWindowBuilder
  infobox: (boxText)->
    content: boxText
    pixelOffset: new google.maps.Size(-151,-84)
  klass: ->
    "arrow_box"

class LocalSupport.VolOpInfoWindowBuilder
  infobox: (boxText)->
    content: boxText
    pixelOffset: new google.maps.Size(-151,10)
  klass: ->
    "arrow_box_vol_op"


class LocalSupport.MarkerBuilder extends Gmaps.Google.Builders.Marker
  create_marker: ->
    @infoWindowBuilder = switch this.args.type
      when 'vol_op' then new LocalSupport.VolOpInfoWindowBuilder
      when 'small_org' then new LocalSupport.SmallOrgInfoWindowBuilder
      when 'large_org' then new LocalSupport.LargeOrgInfoWindowBuilder
    options = _.extend @marker_options(), @rich_marker_options()
    @serviceObject = new RichMarker options
    
  rich_marker_options: ->
    marker = document.createElement("div")
    marker.setAttribute('class', 'custom_marker_content')
    marker.innerHTML = this.args.custom_marker
    {
      content: marker
      flat: true
      zIndex: this.args.index
    }

  create_infowindow: ->
    return null unless _.isString @args.custom_infowindow

    boxText = document.createElement("div")
    boxText.setAttribute("class", @infoWindowBuilder.klass())
    boxText.innerHTML = @args.custom_infowindow
    @infowindow = new InfoBox(@infobox(boxText))
    @addCloseHandler(@infowindow)


  addCloseHandler: (infowindow) ->
    $(infowindow.content_).find('.close').click(->
      infowindow.close()
    )
    infowindow

  infobox: (boxText)->
    @infoWindowBuilder.infobox boxText 
{'fraction_non_alphanumeric': 0.11136290061508579, 'fraction_numerical': 0.010359339592101004, 'mean_word_length': 3.7031963470319633, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6611723', 'n_tokens_mistral': 978, 'n_tokens_neox': 944, 'n_words': 190}