scrivito_google_maps_widget 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b1eacef576221e409b3a776f3c50e71374e73b93
4
+ data.tar.gz: aacd68790d3ba6e0aadc3f10825b2f74510110bf
5
+ SHA512:
6
+ metadata.gz: e4b7a7cd5a9abc8d442a8441f3a11579508657a226065505ce597a9abc235a6e02ead1adacc493620797befcc9da2cee415a7bc28008cffa1446234ce61cd486
7
+ data.tar.gz: d8d780a7dfa02b863e09389e2b52b11811ee09ce5565e3889208fea1bf0ccdf07e4ca8f187c0174940cd475576ef62caf96229a8883d1310f79ac9c2b0711c3d
data/LICENSE ADDED
@@ -0,0 +1,4 @@
1
+ Copyright (c) 2009 - 2014 Infopark AG (http://www.infopark.com)
2
+
3
+ This software can be used and modified under the LGPL-3.0. Please refer to
4
+ http://www.gnu.org/licenses/lgpl-3.0.html for the license text.
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # Scrivito: Google Maps Widget
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/scrivito_google_maps_widget.svg)](http://badge.fury.io/rb/scrivito_google_maps_widget)
4
+ [![Code Climate](https://codeclimate.com/github/Scrivito/scrivito_google_maps_widget.png)](https://codeclimate.com/github/Scrivito/scrivito_google_maps_widget)
5
+ [![Dependency Status](https://gemnasium.com/Scrivito/scrivito_google_maps_widget.png)](https://gemnasium.com/Scrivito/scrivito_google_maps_widget)
6
+
7
+ The google maps widget is based on the
8
+ [Google Places JavaScript API](https://developers.google.com/maps/documentation/javascript/places).
9
+ It displays a single location marker for an adress that editors can configure in an easy to use
10
+ input field with location suggestions.
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's `Gemfile`:
15
+
16
+ gem 'scrivito_google_maps_widget'
17
+
18
+ Include the Google Maps Places JavaScript library in your application layout:
19
+
20
+ javascript_include_tag('//maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places')
21
+
22
+ Add this line to your application JavaScript manifest:
23
+
24
+ //= require google_maps_widget/application
25
+
26
+ Add this line to your editing JavaScript manifest:
27
+
28
+ //= require google_maps_widget/editing
29
+
30
+ Add this line to your application Stylesheet manifest:
31
+
32
+ *= require google_maps_widget/application
33
+
34
+ Add this line to your editing Stylesheet manifest:
35
+
36
+ *= require google_maps_widget/editing
37
+
38
+ And then execute:
39
+
40
+ $ bundle
41
+ $ rake cms:migrate:install
42
+ $ rake cms:migrate
43
+ $ rake cms:migrate:publish
44
+
45
+
46
+ ## Usage
47
+
48
+ If you followed the installation instructions, you have now successfully integrated the Google Maps
49
+ widget into your project und published the new CMS object class. Editors of your webpage can now
50
+ select the widget from the **Widget Browser** and immediately choose a location.
51
+
52
+ In case you want to adopt the styles of the widget, feel free to redefine the `.google-maps .map`
53
+ CSS class, which is the container the map gets rendered to.
54
+
55
+
56
+ ## Contributing
57
+
58
+ 1. Fork it ( https://github.com/Scrivito/scrivito_google_maps/merge_tags/fork )
59
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
61
+ 4. Push to the branch (`git push origin my-new-feature`)
62
+ 5. Create a new Pull Request
63
+
64
+
65
+ ## License
66
+ Copyright (c) 2009 - 2014 Infopark AG (http://www.infopark.com)
67
+
68
+ This software can be used and modified under the LGPL-3.0. Please refer to
69
+ http://www.gnu.org/licenses/lgpl-3.0.html for the license text.
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'bundler/gem_tasks'
@@ -0,0 +1,57 @@
1
+ $ ->
2
+ window.googleMapsWidget =
3
+ placeMarker: (map, infoWindow, marker, place) ->
4
+ infoWindow.close()
5
+ marker.setVisible(false)
6
+
7
+ unless place.geometry
8
+ return
9
+
10
+ map.setCenter(place.geometry.location)
11
+ map.setZoom(17)
12
+
13
+ marker.setPosition(place.geometry.location)
14
+ marker.setVisible(true)
15
+
16
+ content = '<div><strong>' + place.name + '</strong></br>' + place.formatted_address
17
+ infoWindow.setContent(content)
18
+ infoWindow.open(map, marker)
19
+
20
+ initialize: () ->
21
+ widgets = $('.google-maps')
22
+
23
+ widgets.each ->
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: 13
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)
@@ -0,0 +1,35 @@
1
+ $ ->
2
+ initialize = ->
3
+ widgets = $('.google-maps')
4
+
5
+ widgets.each ->
6
+ widget = $(this)
7
+ canvas = widget.find('.map')
8
+
9
+ unless canvas.data('map')
10
+ googleMapsWidget.initialize()
11
+
12
+ map = canvas.data('map')
13
+ infoWindow = canvas.data('infoWindow')
14
+ marker = canvas.data('marker')
15
+
16
+ input = widget.find('input')
17
+ input.show()
18
+
19
+ content = canvas.attr('data-location')
20
+ input.attr('value', content)
21
+
22
+ map.controls[google.maps.ControlPosition.TOP_LEFT] = new Array(input[0])
23
+
24
+ autocomplete = new google.maps.places.Autocomplete(input[0])
25
+ autocomplete.bindTo('bounds', map)
26
+
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
+ )
32
+
33
+ scrivito.on 'content', ->
34
+ if scrivito.in_editable_view()
35
+ initialize()
@@ -0,0 +1,4 @@
1
+ .google-maps .map {
2
+ height: 500px;
3
+ width: 100%;
4
+ }
@@ -0,0 +1,15 @@
1
+ .google-maps input {
2
+ display: none;
3
+ background-color: #fff;
4
+ border: 1px solid transparent;
5
+ border-radius: 2px 0 0 2px;
6
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
7
+ height: 32px;
8
+ margin-top: 16px;
9
+ padding: 0 11px 0 13px;
10
+ font-size: 15px;
11
+ font-weight: 300;
12
+ outline: none;
13
+ text-overflow: ellipsis;
14
+ width: 400px;
15
+ }
@@ -0,0 +1,2 @@
1
+ class GoogleMapsWidget < Widget
2
+ end
@@ -0,0 +1,7 @@
1
+ <div class="google-maps">
2
+ <% if scrivito_in_editable_view? %>
3
+ <%= scrivito_tag(:input, widget, :address, type: 'text', data: { editor: 'google-maps' }) %>
4
+ <% end %>
5
+
6
+ <div class="map" data-location="<%= widget.address %>"></div>
7
+ </div>
@@ -0,0 +1,13 @@
1
+ <div class="editing-dialog-thumbnail">
2
+ <div class="visualization">
3
+ <span class="icon editing-icon-map"></span>
4
+ </div>
5
+
6
+ <div class="title">
7
+ Google Maps
8
+ </div>
9
+
10
+ <div class="description">
11
+ Integrates a map that displays a pin for a given address.
12
+ </div>
13
+ </div>
@@ -0,0 +1,4 @@
1
+ require 'scrivito_google_maps_widget/engine'
2
+
3
+ module ScrivitoGoogleMaps
4
+ end
@@ -0,0 +1,5 @@
1
+ module ScrivitoGoogleMapsWidget
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace ScrivitoGoogleMapsWidget
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module ScrivitoGoogleMapsWidget
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,15 @@
1
+ class CreateGoogleMapsWidget < ::Scrivito::Migration
2
+ def up
3
+ create_obj_class(
4
+ name: 'GoogleMapsWidget',
5
+ type: 'publication',
6
+ title: 'Google Maps',
7
+ attributes: [
8
+ {
9
+ name: 'address',
10
+ type: :string,
11
+ },
12
+ ]
13
+ )
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scrivito_google_maps_widget
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Scrivito
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: scrivito_sdk
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Scrivito Google Maps Widget.
56
+ email:
57
+ - support@scrivito.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - app/assets/javascripts/google_maps_widget/application.js.coffee
66
+ - app/assets/javascripts/google_maps_widget/editing.js.coffee
67
+ - app/assets/stylesheets/google_maps_widget/application.css
68
+ - app/assets/stylesheets/google_maps_widget/editing.css
69
+ - app/models/google_maps_widget.rb
70
+ - app/views/google_maps_widget/show.html.erb
71
+ - app/views/google_maps_widget/thumbnail.html.erb
72
+ - lib/scrivito_google_maps_widget.rb
73
+ - lib/scrivito_google_maps_widget/engine.rb
74
+ - lib/scrivito_google_maps_widget/version.rb
75
+ - scrivito/migrate/0_create_google_maps_widget.rb
76
+ homepage: https://www.scrivito.com
77
+ licenses:
78
+ - LGPL-3.0
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.3.0
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Scrivito Google Maps Widget.
100
+ test_files: []