jekyll-maps 1.1.4 → 1.1.5

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: f78a665bd5372843570e3b7ce2fdc259372d3b42
4
- data.tar.gz: ab275cb5b36e62a4486ee46dd4497b8b8cdd26a9
3
+ metadata.gz: e1a432ee547d3a2d9f4b6ae0b2e22c848b39014a
4
+ data.tar.gz: 9d6697299c275ac9e41dd50255621d4447d52c78
5
5
  SHA512:
6
- metadata.gz: e76302ce186d29bb54201505f164da6883bb09e6ca0765a89fe3bfee79f97114d46cfcc643159cc1ef080b92297190c95118ab3a541976f00b5c8cd82431e2da
7
- data.tar.gz: b58410fca8011e807fe11f1f433e97d5a3f4a2fa20f3fc91fbe2e8c35857d8cd146a5db8423eceaf7c85ed815514deff1a1cda324de6927237f46bae023d498e
6
+ metadata.gz: 8ca56f5cb9c366f96e6dfe82122eb01c7a353db4c06dfbecd25b7223d320621d78b5f0856f79d8cdde12a5d7f7560e465eca0ae5191f3af8a34b27d8faf51055
7
+ data.tar.gz: 8d7de844e79b31633f71472b07567d555140d7d85835070ab73ccfc493539154f5fb0d26680384c76b17ea1574d1532a6b5c0268ad8e54db4c9e1f71f6fc137b
data/History.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.1.5 / 2016-09-03
2
+
3
+ * allow to disable marker popup on the map
4
+
1
5
  ## 1.1.4 / 2016-07-31
2
6
 
3
7
  * open info window when marker is clicked
data/README.md CHANGED
@@ -99,7 +99,7 @@ If you have any questions or proposals - open up an [issue](https://github.com/a
99
99
 
100
100
  ## Examples
101
101
 
102
- Want to see it in action? Check out [Demo Page](https://ayastreb.github.io/jekyll-maps/#examples)!
102
+ Want to see it in action? Check out [Demo Page](https://ayastreb.me/jekyll-maps/#examples)!
103
103
 
104
104
  ## Contributing
105
105
 
@@ -2,13 +2,13 @@ var jekyllMaps = (function () {
2
2
  'use strict';
3
3
 
4
4
  return {
5
- data: [],
6
- maps: [],
7
- initializeMap: initializeMap,
5
+ data: [],
6
+ maps: [],
7
+ initializeMap: initializeMap,
8
8
  initializeCluster: initializeCluster,
9
- register: register,
10
- render: render,
11
- processCluster: processCluster
9
+ register: register,
10
+ render: render,
11
+ processCluster: processCluster
12
12
  };
13
13
 
14
14
  /**
@@ -17,8 +17,8 @@ var jekyllMaps = (function () {
17
17
  function initializeMap() {
18
18
  this.options = {
19
19
  mapTypeId: google.maps.MapTypeId.ROADMAP,
20
- center: new google.maps.LatLng(0, 0),
21
- zoom: 12
20
+ center: new google.maps.LatLng(0, 0),
21
+ zoom: 12
22
22
  }
23
23
  this.mapReady = true;
24
24
  this.render();
@@ -29,10 +29,10 @@ var jekyllMaps = (function () {
29
29
  *
30
30
  * @param String id
31
31
  * @param Array locations
32
- * @param Boolean useCluster
32
+ * @param Object settings
33
33
  */
34
- function register(id, locations, useCluster) {
35
- this.data.push({id: id, locations: locations, useCluster: useCluster});
34
+ function register(id, locations, settings) {
35
+ this.data.push({id: id, locations: locations, settings: settings});
36
36
  this.render();
37
37
  }
38
38
 
@@ -43,46 +43,50 @@ var jekyllMaps = (function () {
43
43
  if (!this.mapReady) return;
44
44
 
45
45
  while (this.data.length > 0) {
46
- var data = this.data.pop(),
47
- bounds = new google.maps.LatLngBounds(),
48
- options = this.options,
49
- map = new google.maps.Map(document.getElementById(data.id), options),
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
50
  infoWindow = new google.maps.InfoWindow(),
51
- markers = data.locations.map(createMarker);
51
+ markers = data.locations.map(function (location) {
52
+ return createMarker(location, options.showMarkerPopup);
53
+ });
52
54
 
53
55
  map.fitBounds(bounds);
54
56
  google.maps.event.addListenerOnce(map, 'bounds_changed', onBoundsChanged);
55
- if (data.useCluster) {
57
+ if (options.useCluster) {
56
58
  this.maps.push({map: map, markers: markers});
57
59
  this.processCluster();
58
60
  }
59
61
  }
60
62
 
61
- function createMarker(location) {
63
+ function createMarker(location, showMarkerPopup) {
62
64
  var position = new google.maps.LatLng(location.latitude, location.longitude),
63
- marker = new google.maps.Marker({
65
+ marker = new google.maps.Marker({
64
66
  position: position,
65
- title: location.title,
66
- image: location.image,
67
- url: location.url,
68
- map: map
67
+ title: location.title,
68
+ image: location.image,
69
+ url: location.url,
70
+ map: map
69
71
  });
70
72
 
71
73
  bounds.extend(position);
72
- marker.addListener('click', function () {
73
- var contentString = '<div class="map-info-window"><h5>' + this.title + '</h5>',
74
- link = 'View';
75
- if (this.image.length > 0) {
76
- link = '<img src="' + this.image + '" alt="' + this.title + '"/>';
77
- }
78
- contentString += '<a href="' + this.url + '">' + link + '</a></div>';
79
- infoWindow.setContent(contentString);
80
- infoWindow.open(map, this);
81
- });
74
+ if (showMarkerPopup) marker.addListener('click', markerPopup);
82
75
 
83
76
  return marker;
84
77
  }
85
78
 
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
+
86
90
  function onBoundsChanged() {
87
91
  if (this.getZoom() > options.zoom) {
88
92
  this.setZoom(options.zoom);
@@ -102,9 +106,31 @@ var jekyllMaps = (function () {
102
106
  while (this.maps.length > 0) {
103
107
  var obj = this.maps.pop();
104
108
  new MarkerClusterer(obj.map, obj.markers, {
105
- gridSize: this.clusterSettings.grid_size || 25,
109
+ gridSize: this.clusterSettings.grid_size || 25,
106
110
  imagePath: 'https://cdn.rawgit.com/googlemaps/js-marker-clusterer/gh-pages/images/m'
107
111
  });
108
112
  }
109
113
  }
114
+
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
+ };
135
+ }
110
136
  }());
@@ -31,7 +31,7 @@ HTML
31
31
  .fetch("google", {})
32
32
  .fetch("api_key", "")
33
33
  <<HTML
34
- <script async defer src='https://maps.googleapis.com/maps/api/js?key=#{api_key}&callback=jekyllMaps.initializeMap'></script>
34
+ <script async defer src='https://maps.googleapis.com/maps/api/js?key=#{api_key}&callback=#{Jekyll::Maps::GoogleMapTag::JS_LIB_NAME}.initializeMap'></script>
35
35
  HTML
36
36
  end
37
37
 
@@ -43,7 +43,7 @@ HTML
43
43
  return unless settings.fetch("enabled", true)
44
44
  <<HTML
45
45
  <script async defer src='https://cdn.rawgit.com/googlemaps/js-marker-clusterer/gh-pages/src/markerclusterer.js'
46
- onload='jekyllMaps.initializeCluster(#{settings.to_json})'></script>
46
+ onload='#{Jekyll::Maps::GoogleMapTag::JS_LIB_NAME}.initializeCluster(#{settings.to_json})'></script>
47
47
  HTML
48
48
  end
49
49
 
@@ -12,14 +12,17 @@ module Jekyll
12
12
  end
13
13
 
14
14
  def render(context)
15
- locations = @finder.find(context.registers[:site], context.registers[:page])
16
- use_cluster = @args[:flags][:no_cluster] ? "false" : "true"
15
+ locations = @finder.find(context.registers[:site], context.registers[:page])
17
16
  @args[:attributes][:id] ||= SecureRandom.uuid
18
17
 
19
18
  <<HTML
20
19
  <div #{render_attributes}></div>
21
20
  <script type='text/javascript'>
22
- #{JS_LIB_NAME}.register('#{@args[:attributes][:id]}', #{locations.to_json}, #{use_cluster});
21
+ #{JS_LIB_NAME}.register(
22
+ '#{@args[:attributes][:id]}',
23
+ #{locations.to_json},
24
+ #{map_settings.to_json}
25
+ );
23
26
  </script>
24
27
  HTML
25
28
  end
@@ -48,6 +51,14 @@ HTML
48
51
  css = css.join(" ") if css.is_a?(Array)
49
52
  %(class='#{css}')
50
53
  end
54
+
55
+ private
56
+ def map_settings
57
+ {
58
+ useCluster: !@args[:flags][:no_cluster],
59
+ showMarkerPopup: @args[:attributes][:show_popup] != 'false'
60
+ }
61
+ end
51
62
  end
52
63
  end
53
64
  end
@@ -14,15 +14,7 @@ module Jekyll
14
14
  site.data.each { |_, docs| filter(docs) }
15
15
  end
16
16
 
17
- @documents.map do |document|
18
- {
19
- :latitude => document["location"]["latitude"],
20
- :longitude => document["location"]["longitude"],
21
- :title => document["title"],
22
- :url => document["url"] || document.url,
23
- :image => document["image"] || ""
24
- }
25
- end
17
+ convert
26
18
  end
27
19
 
28
20
  private
@@ -43,6 +35,19 @@ module Jekyll
43
35
  return false if doc[key].nil? || doc[key] != value
44
36
  end
45
37
  end
38
+
39
+ private
40
+ def convert
41
+ @documents.map do |document|
42
+ {
43
+ :latitude => document["location"]["latitude"],
44
+ :longitude => document["location"]["longitude"],
45
+ :title => document["title"],
46
+ :url => document["url"] || document.url,
47
+ :image => document["image"] || ""
48
+ }
49
+ end
50
+ end
46
51
  end
47
52
  end
48
53
  end
@@ -11,6 +11,7 @@ module Jekyll
11
11
  width
12
12
  height
13
13
  class
14
+ show_popup
14
15
  ).freeze
15
16
 
16
17
  class << self
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Maps
3
- VERSION = "1.1.4".freeze
3
+ VERSION = "1.1.5".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.4
4
+ version: 1.1.5
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-07-31 00:00:00.000000000 Z
11
+ date: 2016-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll