 root = exports ? this
 
 class root.Autocomplete
-  source: ()->
+  source: ()=>
     []
-  select: ()->
-    ()->
-  change: ()->
-    ()->
+  select: ()=>
+  change: ()=>
   minChars: 2
 
   constructor: (@selector)->

    @gmap.onSucceed.push (address)=>
      $(@selector).val address

  source: ()->
    (request, response) =>
      @gmap.searchGeocodes request.term, (results)->
        response $.map results, (item) ->
          label: item.formatted_address
          value: item.formatted_address
          geocode: item

  select: ()->
    (event, ui) =>
      @gmap.update ui.item.geocode

  afterApply: ()->
    @syncWithMap()


  apply: ()->
    $(@selector).autocomplete
      source: @source
      select: @select
      change: @change
    this.afterApply()

  afterApply: ()->
