scrivito_google_maps_widget 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1e0bd44b7bbef9f5f919b797e4bb9b8278e2d1a
4
- data.tar.gz: 70df14fa77df3149cd5b10ae5e5291d4eaaf19ff
3
+ metadata.gz: a17fdea7f586d62408848b4b405d3a16d8edac61
4
+ data.tar.gz: d99b0798a8fe8b954282e5b258d0bd84619d326f
5
5
  SHA512:
6
- metadata.gz: 4941baa587f9a1f54e3bae0cd8c3a0a5ecf52e2272c0a29781c8e2332908e6dca189f146f89caef33e5cfd8f7c4623379da13cbb6dfc3e00a04f143288d401b3
7
- data.tar.gz: fc2339de74960c94e93455345d3e9154affac71379884d8ebc0fd70e31ee8529e6e23716dbf330bb2665cea643f6761ed6eb2f7d3af7892b3a5287a6d246f9ab
6
+ metadata.gz: 458137d6fec25a0c88404e5b88f8e13fb5a0cdca1a18e95f2c786bcfb6cb8d0ff11ad5d4a3c7f43a595e98dfa3b999c6daded8cc969d367096d4c1af1843177c
7
+ data.tar.gz: f1f8b9f2e9a25ddc7d2dfe2716958613c50b36e0175b075e16c11a30b248503fc717908295bb3a34ffa3aee95a29999efb91e8b6ac902e91816b274f258a4570
@@ -20,38 +20,41 @@ $ ->
20
20
  widgets = $('.google-maps')
21
21
 
22
22
  widgets.each ->
23
- widget = $(this)
24
- canvas = widget.find('.map')
25
-
26
- # Make sure not to initalize a map twice, which can happen if a new
27
- # map is added dynamically.
28
- if canvas.data('map')
29
- return
30
-
31
- mapOptions =
32
- center: new google.maps.LatLng(-33.8688, 151.2195)
33
- zoom: parseInt(canvas.data('zoom'))
34
- scrollwheel: false
35
-
36
- map = new google.maps.Map(canvas[0], mapOptions)
37
- canvas.data('map', map)
38
-
39
- infoWindow = new google.maps.InfoWindow()
40
- canvas.data('infoWindow', infoWindow)
41
-
42
- marker = new google.maps.Marker
43
- map: map
44
- anchorPoint: new google.maps.Point(0, -29)
45
- canvas.data('marker', marker)
46
-
47
- if content = canvas.attr('data-location')
48
- request =
49
- query: content
50
-
51
- service = new google.maps.places.PlacesService(map)
52
- service.textSearch request, (results, status) ->
53
- if status == google.maps.places.PlacesServiceStatus.OK
54
- place = results[0] # only interested in the first place found
55
- googleMapsWidget.placeMarker(map, infoWindow, marker, place)
56
-
57
- google.maps.event.addDomListener(window, 'load', googleMapsWidget.initialize)
23
+ if google?
24
+ widget = $(this)
25
+ canvas = widget.find('.map')
26
+
27
+ # Make sure not to initalize a map twice, which can happen if a new
28
+ # map is added dynamically.
29
+ if canvas.data('map')
30
+ return
31
+
32
+ mapOptions =
33
+ center: new google.maps.LatLng(-33.8688, 151.2195)
34
+ zoom: parseInt(canvas.data('zoom'))
35
+ scrollwheel: false
36
+
37
+ map = new google.maps.Map(canvas[0], mapOptions)
38
+ canvas.data('map', map)
39
+
40
+ infoWindow = new google.maps.InfoWindow()
41
+ canvas.data('infoWindow', infoWindow)
42
+
43
+ marker = new google.maps.Marker
44
+ map: map
45
+ anchorPoint: new google.maps.Point(0, -29)
46
+ canvas.data('marker', marker)
47
+
48
+ if content = canvas.attr('data-location')
49
+ request =
50
+ query: content
51
+
52
+ service = new google.maps.places.PlacesService(map)
53
+ service.textSearch request, (results, status) ->
54
+ if status == google.maps.places.PlacesServiceStatus.OK
55
+ place = results[0] # only interested in the first place found
56
+ googleMapsWidget.placeMarker(map, infoWindow, marker, place)
57
+ else
58
+ widgets.html('Google API is not initialized')
59
+
60
+ google?.maps.event.addDomListener(window, 'load', googleMapsWidget.initialize)
@@ -3,32 +3,35 @@ $ ->
3
3
  widgets = $('.google-maps')
4
4
 
5
5
  widgets.each ->
6
- widget = $(this)
7
- canvas = widget.find('.map')
6
+ if google?
7
+ widget = $(this)
8
+ canvas = widget.find('.map')
8
9
 
9
- unless canvas.data('map')
10
- googleMapsWidget.initialize()
10
+ unless canvas.data('map')
11
+ googleMapsWidget.initialize()
11
12
 
12
- map = canvas.data('map')
13
- infoWindow = canvas.data('infoWindow')
14
- marker = canvas.data('marker')
13
+ map = canvas.data('map')
14
+ infoWindow = canvas.data('infoWindow')
15
+ marker = canvas.data('marker')
15
16
 
16
- input = widget.find('input')
17
- input.show()
17
+ input = widget.find('input')
18
+ input.show()
18
19
 
19
- content = canvas.attr('data-location')
20
- input.attr('value', content)
20
+ content = canvas.attr('data-location')
21
+ input.attr('value', content)
21
22
 
22
- map.controls[google.maps.ControlPosition.TOP_LEFT] = new Array(input[0])
23
+ map.controls[google.maps.ControlPosition.TOP_LEFT] = new Array(input[0])
23
24
 
24
- autocomplete = new google.maps.places.Autocomplete(input[0])
25
- autocomplete.bindTo('bounds', map)
25
+ autocomplete = new google.maps.places.Autocomplete(input[0])
26
+ autocomplete.bindTo('bounds', map)
26
27
 
27
- google.maps.event.addListener(autocomplete, 'place_changed', ->
28
- place = autocomplete.getPlace()
29
- googleMapsWidget.placeMarker(map, infoWindow, marker, place)
30
- input.scrivito('save', place.formatted_address)
31
- )
28
+ google.maps.event.addListener(autocomplete, 'place_changed', ->
29
+ place = autocomplete.getPlace()
30
+ googleMapsWidget.placeMarker(map, infoWindow, marker, place)
31
+ input.scrivito('save', place.formatted_address)
32
+ )
33
+ else
34
+ widgets.html('Google API is not initialized')
32
35
 
33
36
  scrivito.on 'content', ->
34
37
  if scrivito.in_editable_view()
@@ -1,3 +1,3 @@
1
1
  module ScrivitoGoogleMapsWidget
2
- VERSION = '0.1.10'
2
+ VERSION = '0.1.11'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrivito_google_maps_widget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scrivito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-30 00:00:00.000000000 Z
11
+ date: 2017-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: scrivito_sdk
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  version: '0'
69
69
  requirements: []
70
70
  rubyforge_project:
71
- rubygems_version: 2.4.5
71
+ rubygems_version: 2.5.1
72
72
  signing_key:
73
73
  specification_version: 4
74
74
  summary: Scrivito Google Maps Widget.