Sha256: af5a2c4e12cac93c7f493207df08d51a59b837b15520b11818407cbd6e853879

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

$ ->
  initialize = ->
    widgets = $('.google-maps')

    widgets.each ->
      if google?
        widget = $(this)
        canvas = widget.find('.map')

        unless canvas.data('map')
          googleMapsWidget.initialize()

        map = canvas.data('map')
        infoWindow = canvas.data('infoWindow')
        marker = canvas.data('marker')

        input = widget.find('input')
        input.show()

        content = canvas.attr('data-location')
        input.attr('value', content)

        map.controls[google.maps.ControlPosition.TOP_LEFT] = new Array(input[0])

        autocomplete = new google.maps.places.Autocomplete(input[0])
        autocomplete.bindTo('bounds', map)

        google.maps.event.addListener(autocomplete, 'place_changed', ->
          place = autocomplete.getPlace()
          googleMapsWidget.placeMarker(map, infoWindow, marker, place)
          input.scrivito('save', place.formatted_address)
        )
      else
        widgets.html('Google API is not initialized')

  scrivito.on 'content', ->
    if scrivito.in_editable_view()
      initialize()

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scrivito_google_maps_widget-0.1.11 app/assets/javascripts/scrivito_google_maps_widget/editing.js.coffee