jekyll-maps 1.1.5 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1a432ee547d3a2d9f4b6ae0b2e22c848b39014a
4
- data.tar.gz: 9d6697299c275ac9e41dd50255621d4447d52c78
3
+ metadata.gz: 3bf3fffa8b6a67a476bdbe5fc43b4448098bb365
4
+ data.tar.gz: a2907b6e1a100ed5ed7d66bdbfcd2278b2316127
5
5
  SHA512:
6
- metadata.gz: 8ca56f5cb9c366f96e6dfe82122eb01c7a353db4c06dfbecd25b7223d320621d78b5f0856f79d8cdde12a5d7f7560e465eca0ae5191f3af8a34b27d8faf51055
7
- data.tar.gz: 8d7de844e79b31633f71472b07567d555140d7d85835070ab73ccfc493539154f5fb0d26680384c76b17ea1574d1532a6b5c0268ad8e54db4c9e1f71f6fc137b
6
+ metadata.gz: a326efc82dd3efa73f3c140137c0f87f29f86e93d8d795883cd4a83f57d7064ee8868e3e250932c04cda356fa784eada946ea9ba612ad9a85c107a8d5dfcaf38
7
+ data.tar.gz: f7bb0962ad9a89794a2c767b88a92870bb995048b313c678e92fe8ed71fd7bb8672ca3dee3b14bdefbfab2168a9929f903b3473b9e7575b6c8581ca1d125b612
data/History.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.1.6 / 2016-09-07
2
+ * fix #15 - broken page if there is <header> tag used
3
+ * allow setting custom zoom level with `zoom:10` attribute
4
+
1
5
  ## 1.1.5 / 2016-09-03
2
6
 
3
7
  * allow to disable marker popup on the map
data/jekyll-maps.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.authors = ["Anatoliy Yastreb"]
12
12
  spec.email = ["anatoliy.yastreb@gmail.com"]
13
13
 
14
- spec.homepage = "https://github.com/ayastreb/jekyll-google-maps"
14
+ spec.homepage = "https://github.com/ayastreb/jekyll-maps"
15
15
  spec.licenses = ["MIT"]
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
17
17
  spec.require_paths = ["lib"]
@@ -1,136 +1,135 @@
1
+ /* global google */
2
+ /* global MarkerClusterer */
3
+ // eslint-disable-next-line no-unused-vars
1
4
  var jekyllMaps = (function () {
2
- 'use strict';
3
-
4
- return {
5
- data: [],
6
- maps: [],
7
- initializeMap: initializeMap,
8
- initializeCluster: initializeCluster,
9
- register: register,
10
- render: render,
11
- processCluster: processCluster
12
- };
13
-
14
- /**
15
- * Setup Google Maps options and call renderer.
16
- */
17
- function initializeMap() {
18
- this.options = {
19
- mapTypeId: google.maps.MapTypeId.ROADMAP,
20
- center: new google.maps.LatLng(0, 0),
21
- zoom: 12
22
- }
23
- this.mapReady = true;
24
- this.render();
5
+ 'use strict'
6
+ var clusterSettings = {}
7
+ var clusterReady = false
8
+ var mapReady = false
9
+ var options = {}
10
+ var data = []
11
+ var maps = []
12
+
13
+ return {
14
+ initializeMap: initializeMap,
15
+ initializeCluster: initializeCluster,
16
+ register: register
17
+ }
18
+
19
+ /**
20
+ * Setup Google Maps options and call renderer.
21
+ */
22
+ function initializeMap () {
23
+ options = {
24
+ mapTypeId: google.maps.MapTypeId.ROADMAP,
25
+ center: new google.maps.LatLng(0, 0)
25
26
  }
26
-
27
- /**
28
- * Register map data to be rendered once Google Maps API is loaded.
29
- *
30
- * @param String id
31
- * @param Array locations
32
- * @param Object settings
33
- */
34
- function register(id, locations, settings) {
35
- this.data.push({id: id, locations: locations, settings: settings});
36
- this.render();
27
+ mapReady = true
28
+ render()
29
+ }
30
+
31
+ /**
32
+ * Register map data to be rendered once Google Maps API is loaded.
33
+ *
34
+ * @param string id
35
+ * @param Array locations
36
+ * @param Object settings
37
+ */
38
+ function register (id, locations, options) {
39
+ data.push({ id: id, locations: locations, options: options })
40
+ render()
41
+ }
42
+
43
+ /**
44
+ * Render maps data if Google Maps API is loaded.
45
+ */
46
+ function render () {
47
+ if (!mapReady) return
48
+
49
+ while (data.length > 0) {
50
+ var item = data.pop()
51
+ var bounds = new google.maps.LatLngBounds()
52
+ var mapOptions = Object.assign({}, options, item.options)
53
+ var map = new google.maps.Map(document.getElementById(item.id), mapOptions)
54
+ var infoWindow = new google.maps.InfoWindow()
55
+ var markers = item.locations.map(createMarker)
56
+
57
+ map.fitBounds(bounds)
58
+ google.maps.event.addListenerOnce(map, 'bounds_changed', function() {
59
+ if (this.customZoom) this.setZoom(this.customZoom)
60
+ })
61
+ if (mapOptions.useCluster) {
62
+ maps.push({ map: map, markers: markers })
63
+ processCluster()
64
+ }
37
65
  }
38
66
 
39
- /**
40
- * Render maps data if Google Maps API is loaded.
41
- */
42
- function render() {
43
- if (!this.mapReady) return;
44
-
45
- while (this.data.length > 0) {
46
- var data = this.data.pop(),
47
- bounds = new google.maps.LatLngBounds(),
48
- options = Object.assign({}, this.options, data.settings),
49
- map = new google.maps.Map(document.getElementById(data.id), options),
50
- infoWindow = new google.maps.InfoWindow(),
51
- markers = data.locations.map(function (location) {
52
- return createMarker(location, options.showMarkerPopup);
53
- });
67
+ function createMarker (location) {
68
+ var position = new google.maps.LatLng(location.latitude, location.longitude)
69
+ var marker = new google.maps.Marker({
70
+ position: position,
71
+ title: location.title,
72
+ image: location.image,
73
+ url: location.url,
74
+ map: map
75
+ })
54
76
 
55
- map.fitBounds(bounds);
56
- google.maps.event.addListenerOnce(map, 'bounds_changed', onBoundsChanged);
57
- if (options.useCluster) {
58
- this.maps.push({map: map, markers: markers});
59
- this.processCluster();
60
- }
61
- }
62
-
63
- function createMarker(location, showMarkerPopup) {
64
- var position = new google.maps.LatLng(location.latitude, location.longitude),
65
- marker = new google.maps.Marker({
66
- position: position,
67
- title: location.title,
68
- image: location.image,
69
- url: location.url,
70
- map: map
71
- });
72
-
73
- bounds.extend(position);
74
- if (showMarkerPopup) marker.addListener('click', markerPopup);
75
-
76
- return marker;
77
- }
77
+ bounds.extend(position)
78
+ if (mapOptions.showMarkerPopup) marker.addListener('click', markerPopup)
78
79
 
79
- function markerPopup() {
80
- var contentString = '<div class="map-info-window"><h5>' + this.title + '</h5>',
81
- link = 'View';
82
- if (this.image.length > 0) {
83
- link = '<img src="' + this.image + '" alt="' + this.title + '"/>';
84
- }
85
- contentString += '<a href="' + this.url + '">' + link + '</a></div>';
86
- infoWindow.setContent(contentString);
87
- infoWindow.open(map, this);
88
- }
89
-
90
- function onBoundsChanged() {
91
- if (this.getZoom() > options.zoom) {
92
- this.setZoom(options.zoom);
93
- }
94
- }
80
+ return marker
95
81
  }
96
82
 
97
- function initializeCluster(settings) {
98
- this.clusterReady = true;
99
- this.clusterSettings = settings || {};
100
- this.processCluster();
83
+ function markerPopup () {
84
+ var contentString = '<div class="map-info-window"><h5>' + this.title + '</h5>'
85
+ var link = 'View'
86
+ if (this.image.length > 0) {
87
+ link = '<img src="' + this.image + '" alt="' + this.title + '"/>'
88
+ }
89
+ contentString += '<a href="' + this.url + '">' + link + '</a></div>'
90
+ infoWindow.setContent(contentString)
91
+ infoWindow.open(map, this)
101
92
  }
102
-
103
- function processCluster() {
104
- if (!this.clusterReady) return;
105
-
106
- while (this.maps.length > 0) {
107
- var obj = this.maps.pop();
108
- new MarkerClusterer(obj.map, obj.markers, {
109
- gridSize: this.clusterSettings.grid_size || 25,
110
- imagePath: 'https://cdn.rawgit.com/googlemaps/js-marker-clusterer/gh-pages/images/m'
111
- });
112
- }
93
+ }
94
+
95
+ function initializeCluster (settings) {
96
+ clusterReady = true
97
+ clusterSettings = settings || {}
98
+ processCluster()
99
+ }
100
+
101
+ function processCluster () {
102
+ if (!clusterReady) return
103
+
104
+ while (maps.length > 0) {
105
+ var obj = maps.pop()
106
+ // eslint-disable-next-line no-new
107
+ new MarkerClusterer(obj.map, obj.markers, {
108
+ gridSize: clusterSettings.grid_size || 25,
109
+ imagePath: 'https://cdn.rawgit.com/googlemaps/js-marker-clusterer/gh-pages/images/m'
110
+ })
111
+ }
112
+ }
113
+ }())
114
+ /* Object.assign polyfill */
115
+ if (typeof Object.assign !== 'function') {
116
+ Object.assign = function (target) {
117
+ 'use strict'
118
+ if (target == null) {
119
+ throw new TypeError('Cannot convert undefined or null to object')
113
120
  }
114
121
 
115
- if (typeof Object.assign != 'function') {
116
- Object.assign = function (target) {
117
- 'use strict';
118
- if (target == null) {
119
- throw new TypeError('Cannot convert undefined or null to object');
120
- }
121
-
122
- target = Object(target);
123
- for (var index = 1; index < arguments.length; index++) {
124
- var source = arguments[index];
125
- if (source != null) {
126
- for (var key in source) {
127
- if (Object.prototype.hasOwnProperty.call(source, key)) {
128
- target[key] = source[key];
129
- }
130
- }
131
- }
132
- }
133
- return target;
134
- };
122
+ target = Object(target)
123
+ for (var index = 1; index < arguments.length; index++) {
124
+ var source = arguments[ index ]
125
+ if (source != null) {
126
+ for (var key in source) {
127
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
128
+ target[ key ] = source[ key ]
129
+ }
130
+ }
131
+ }
135
132
  }
136
- }());
133
+ return target
134
+ }
135
+ }
@@ -1,7 +1,7 @@
1
1
  module Jekyll
2
2
  module Maps
3
3
  class GoogleMapApi
4
- HEAD_END_TAG = %r!</.*head.*>!
4
+ HEAD_END_TAG = %r!</.*head>!
5
5
 
6
6
  class << self
7
7
  def prepend_api_code(doc)
@@ -21,7 +21,7 @@ module Jekyll
21
21
  #{JS_LIB_NAME}.register(
22
22
  '#{@args[:attributes][:id]}',
23
23
  #{locations.to_json},
24
- #{map_settings.to_json}
24
+ #{map_options.to_json}
25
25
  );
26
26
  </script>
27
27
  HTML
@@ -53,11 +53,15 @@ HTML
53
53
  end
54
54
 
55
55
  private
56
- def map_settings
57
- {
58
- useCluster: !@args[:flags][:no_cluster],
59
- showMarkerPopup: @args[:attributes][:show_popup] != 'false'
56
+ def map_options
57
+ opts = {
58
+ :useCluster => !@args[:flags][:no_cluster],
59
+ :showMarkerPopup => @args[:attributes][:show_popup] != "false"
60
60
  }
61
+ if @args[:attributes][:zoom]
62
+ opts[:customZoom] = @args[:attributes][:zoom].to_i
63
+ end
64
+ opts
61
65
  end
62
66
  end
63
67
  end
@@ -12,6 +12,7 @@ module Jekyll
12
12
  height
13
13
  class
14
14
  show_popup
15
+ zoom
15
16
  ).freeze
16
17
 
17
18
  class << self
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Maps
3
- VERSION = "1.1.5".freeze
3
+ VERSION = "1.1.6".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-maps
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatoliy Yastreb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-03 00:00:00.000000000 Z
11
+ date: 2016-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -92,7 +92,7 @@ files:
92
92
  - lib/jekyll-maps/version.rb
93
93
  - script/bootstrap
94
94
  - script/cibuild
95
- homepage: https://github.com/ayastreb/jekyll-google-maps
95
+ homepage: https://github.com/ayastreb/jekyll-maps
96
96
  licenses:
97
97
  - MIT
98
98
  metadata: {}