decidim 0.26.9 → 0.26.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/lib/decidim/version.rb +1 -1
  3. data/package-lock.json +7 -7
  4. data/packages/browserslist-config/package.json +1 -1
  5. data/packages/core/node_modules/leaflet/CHANGELOG.md +2191 -0
  6. data/packages/core/node_modules/leaflet/LICENSE +26 -0
  7. data/packages/core/node_modules/leaflet/README.md +55 -0
  8. data/packages/core/node_modules/leaflet/dist/images/layers-2x.png +0 -0
  9. data/packages/core/node_modules/leaflet/dist/images/layers.png +0 -0
  10. data/packages/core/node_modules/leaflet/dist/images/marker-icon-2x.png +0 -0
  11. data/packages/core/node_modules/leaflet/dist/images/marker-icon.png +0 -0
  12. data/packages/core/node_modules/leaflet/dist/images/marker-shadow.png +0 -0
  13. data/packages/core/node_modules/leaflet/dist/leaflet-src.esm.js +14419 -0
  14. data/packages/core/node_modules/leaflet/dist/leaflet-src.esm.js.map +1 -0
  15. data/packages/core/node_modules/leaflet/dist/leaflet-src.js +14512 -0
  16. data/packages/core/node_modules/leaflet/dist/leaflet-src.js.map +1 -0
  17. data/packages/core/node_modules/leaflet/dist/leaflet.css +661 -0
  18. data/packages/core/node_modules/leaflet/dist/leaflet.js +6 -0
  19. data/packages/core/node_modules/leaflet/dist/leaflet.js.map +1 -0
  20. data/packages/core/node_modules/leaflet/package.json +149 -0
  21. data/packages/core/node_modules/leaflet/src/Leaflet.js +24 -0
  22. data/packages/core/node_modules/leaflet/src/control/Control.Attribution.js +148 -0
  23. data/packages/core/node_modules/leaflet/src/control/Control.Layers.js +443 -0
  24. data/packages/core/node_modules/leaflet/src/control/Control.Scale.js +132 -0
  25. data/packages/core/node_modules/leaflet/src/control/Control.Zoom.js +146 -0
  26. data/packages/core/node_modules/leaflet/src/control/Control.js +174 -0
  27. data/packages/core/node_modules/leaflet/src/control/index.js +17 -0
  28. data/packages/core/node_modules/leaflet/src/core/Browser.js +220 -0
  29. data/packages/core/node_modules/leaflet/src/core/Class.js +135 -0
  30. data/packages/core/node_modules/leaflet/src/core/Class.leafdoc +197 -0
  31. data/packages/core/node_modules/leaflet/src/core/Events.js +344 -0
  32. data/packages/core/node_modules/leaflet/src/core/Events.leafdoc +143 -0
  33. data/packages/core/node_modules/leaflet/src/core/Handler.js +57 -0
  34. data/packages/core/node_modules/leaflet/src/core/Util.js +241 -0
  35. data/packages/core/node_modules/leaflet/src/core/index.js +15 -0
  36. data/packages/core/node_modules/leaflet/src/dom/DomEvent.DoubleTap.js +91 -0
  37. data/packages/core/node_modules/leaflet/src/dom/DomEvent.Pointer.js +97 -0
  38. data/packages/core/node_modules/leaflet/src/dom/DomEvent.js +315 -0
  39. data/packages/core/node_modules/leaflet/src/dom/DomUtil.js +349 -0
  40. data/packages/core/node_modules/leaflet/src/dom/Draggable.js +220 -0
  41. data/packages/core/node_modules/leaflet/src/dom/PosAnimation.js +113 -0
  42. data/packages/core/node_modules/leaflet/src/dom/index.js +9 -0
  43. data/packages/core/node_modules/leaflet/src/geo/LatLng.js +137 -0
  44. data/packages/core/node_modules/leaflet/src/geo/LatLngBounds.js +251 -0
  45. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG3395.js +20 -0
  46. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG3857.js +27 -0
  47. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG4326.js +23 -0
  48. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.Earth.js +33 -0
  49. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.Simple.js +36 -0
  50. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.js +139 -0
  51. data/packages/core/node_modules/leaflet/src/geo/crs/index.js +15 -0
  52. data/packages/core/node_modules/leaflet/src/geo/index.js +7 -0
  53. data/packages/core/node_modules/leaflet/src/geo/projection/Projection.LonLat.js +28 -0
  54. data/packages/core/node_modules/leaflet/src/geo/projection/Projection.Mercator.js +49 -0
  55. data/packages/core/node_modules/leaflet/src/geo/projection/Projection.SphericalMercator.js +44 -0
  56. data/packages/core/node_modules/leaflet/src/geo/projection/index.js +26 -0
  57. data/packages/core/node_modules/leaflet/src/geometry/Bounds.js +219 -0
  58. data/packages/core/node_modules/leaflet/src/geometry/LineUtil.js +306 -0
  59. data/packages/core/node_modules/leaflet/src/geometry/Point.js +222 -0
  60. data/packages/core/node_modules/leaflet/src/geometry/PolyUtil.js +129 -0
  61. data/packages/core/node_modules/leaflet/src/geometry/Transformation.js +79 -0
  62. data/packages/core/node_modules/leaflet/src/geometry/index.js +8 -0
  63. data/packages/core/node_modules/leaflet/src/images/layers.svg +1 -0
  64. data/packages/core/node_modules/leaflet/src/images/logo.svg +1 -0
  65. data/packages/core/node_modules/leaflet/src/images/marker.svg +1 -0
  66. data/packages/core/node_modules/leaflet/src/layer/DivOverlay.js +348 -0
  67. data/packages/core/node_modules/leaflet/src/layer/FeatureGroup.js +94 -0
  68. data/packages/core/node_modules/leaflet/src/layer/GeoJSON.js +452 -0
  69. data/packages/core/node_modules/leaflet/src/layer/ImageOverlay.js +270 -0
  70. data/packages/core/node_modules/leaflet/src/layer/Layer.Interactive.leafdoc +39 -0
  71. data/packages/core/node_modules/leaflet/src/layer/Layer.js +275 -0
  72. data/packages/core/node_modules/leaflet/src/layer/LayerGroup.js +159 -0
  73. data/packages/core/node_modules/leaflet/src/layer/Popup.js +506 -0
  74. data/packages/core/node_modules/leaflet/src/layer/SVGOverlay.js +50 -0
  75. data/packages/core/node_modules/leaflet/src/layer/Tooltip.js +444 -0
  76. data/packages/core/node_modules/leaflet/src/layer/VideoOverlay.js +106 -0
  77. data/packages/core/node_modules/leaflet/src/layer/index.js +24 -0
  78. data/packages/core/node_modules/leaflet/src/layer/marker/DivIcon.js +74 -0
  79. data/packages/core/node_modules/leaflet/src/layer/marker/Icon.Default.js +66 -0
  80. data/packages/core/node_modules/leaflet/src/layer/marker/Icon.js +165 -0
  81. data/packages/core/node_modules/leaflet/src/layer/marker/Marker.Drag.js +161 -0
  82. data/packages/core/node_modules/leaflet/src/layer/marker/Marker.js +419 -0
  83. data/packages/core/node_modules/leaflet/src/layer/marker/index.js +8 -0
  84. data/packages/core/node_modules/leaflet/src/layer/tile/GridLayer.js +923 -0
  85. data/packages/core/node_modules/leaflet/src/layer/tile/TileLayer.WMS.js +137 -0
  86. data/packages/core/node_modules/leaflet/src/layer/tile/TileLayer.js +289 -0
  87. data/packages/core/node_modules/leaflet/src/layer/tile/index.js +6 -0
  88. data/packages/core/node_modules/leaflet/src/layer/vector/Canvas.js +492 -0
  89. data/packages/core/node_modules/leaflet/src/layer/vector/Circle.js +113 -0
  90. data/packages/core/node_modules/leaflet/src/layer/vector/CircleMarker.js +109 -0
  91. data/packages/core/node_modules/leaflet/src/layer/vector/Path.js +148 -0
  92. data/packages/core/node_modules/leaflet/src/layer/vector/Polygon.js +159 -0
  93. data/packages/core/node_modules/leaflet/src/layer/vector/Polyline.js +307 -0
  94. data/packages/core/node_modules/leaflet/src/layer/vector/Rectangle.js +57 -0
  95. data/packages/core/node_modules/leaflet/src/layer/vector/Renderer.getRenderer.js +45 -0
  96. data/packages/core/node_modules/leaflet/src/layer/vector/Renderer.js +133 -0
  97. data/packages/core/node_modules/leaflet/src/layer/vector/SVG.Util.js +39 -0
  98. data/packages/core/node_modules/leaflet/src/layer/vector/SVG.VML.js +144 -0
  99. data/packages/core/node_modules/leaflet/src/layer/vector/SVG.js +207 -0
  100. data/packages/core/node_modules/leaflet/src/layer/vector/index.js +14 -0
  101. data/packages/core/node_modules/leaflet/src/map/Map.js +1751 -0
  102. data/packages/core/node_modules/leaflet/src/map/Map.methodOptions.leafdoc +112 -0
  103. data/packages/core/node_modules/leaflet/src/map/handler/Map.BoxZoom.js +152 -0
  104. data/packages/core/node_modules/leaflet/src/map/handler/Map.DoubleClickZoom.js +55 -0
  105. data/packages/core/node_modules/leaflet/src/map/handler/Map.Drag.js +235 -0
  106. data/packages/core/node_modules/leaflet/src/map/handler/Map.Keyboard.js +183 -0
  107. data/packages/core/node_modules/leaflet/src/map/handler/Map.ScrollWheelZoom.js +91 -0
  108. data/packages/core/node_modules/leaflet/src/map/handler/Map.TapHold.js +102 -0
  109. data/packages/core/node_modules/leaflet/src/map/handler/Map.TouchZoom.js +130 -0
  110. data/packages/core/node_modules/leaflet/src/map/index.js +17 -0
  111. data/packages/core/package.json +1 -1
  112. data/packages/dev/package.json +1 -1
  113. data/packages/elections/package.json +1 -1
  114. data/packages/eslint-config/package.json +1 -1
  115. data/packages/stylelint-config/package.json +1 -1
  116. data/packages/webpacker/package.json +1 -1
  117. metadata +148 -42
@@ -0,0 +1,159 @@
1
+
2
+ import {Layer} from './Layer';
3
+ import * as Util from '../core/Util';
4
+
5
+ /*
6
+ * @class LayerGroup
7
+ * @aka L.LayerGroup
8
+ * @inherits Interactive layer
9
+ *
10
+ * Used to group several layers and handle them as one. If you add it to the map,
11
+ * any layers added or removed from the group will be added/removed on the map as
12
+ * well. Extends `Layer`.
13
+ *
14
+ * @example
15
+ *
16
+ * ```js
17
+ * L.layerGroup([marker1, marker2])
18
+ * .addLayer(polyline)
19
+ * .addTo(map);
20
+ * ```
21
+ */
22
+
23
+ export var LayerGroup = Layer.extend({
24
+
25
+ initialize: function (layers, options) {
26
+ Util.setOptions(this, options);
27
+
28
+ this._layers = {};
29
+
30
+ var i, len;
31
+
32
+ if (layers) {
33
+ for (i = 0, len = layers.length; i < len; i++) {
34
+ this.addLayer(layers[i]);
35
+ }
36
+ }
37
+ },
38
+
39
+ // @method addLayer(layer: Layer): this
40
+ // Adds the given layer to the group.
41
+ addLayer: function (layer) {
42
+ var id = this.getLayerId(layer);
43
+
44
+ this._layers[id] = layer;
45
+
46
+ if (this._map) {
47
+ this._map.addLayer(layer);
48
+ }
49
+
50
+ return this;
51
+ },
52
+
53
+ // @method removeLayer(layer: Layer): this
54
+ // Removes the given layer from the group.
55
+ // @alternative
56
+ // @method removeLayer(id: Number): this
57
+ // Removes the layer with the given internal ID from the group.
58
+ removeLayer: function (layer) {
59
+ var id = layer in this._layers ? layer : this.getLayerId(layer);
60
+
61
+ if (this._map && this._layers[id]) {
62
+ this._map.removeLayer(this._layers[id]);
63
+ }
64
+
65
+ delete this._layers[id];
66
+
67
+ return this;
68
+ },
69
+
70
+ // @method hasLayer(layer: Layer): Boolean
71
+ // Returns `true` if the given layer is currently added to the group.
72
+ // @alternative
73
+ // @method hasLayer(id: Number): Boolean
74
+ // Returns `true` if the given internal ID is currently added to the group.
75
+ hasLayer: function (layer) {
76
+ var layerId = typeof layer === 'number' ? layer : this.getLayerId(layer);
77
+ return layerId in this._layers;
78
+ },
79
+
80
+ // @method clearLayers(): this
81
+ // Removes all the layers from the group.
82
+ clearLayers: function () {
83
+ return this.eachLayer(this.removeLayer, this);
84
+ },
85
+
86
+ // @method invoke(methodName: String, …): this
87
+ // Calls `methodName` on every layer contained in this group, passing any
88
+ // additional parameters. Has no effect if the layers contained do not
89
+ // implement `methodName`.
90
+ invoke: function (methodName) {
91
+ var args = Array.prototype.slice.call(arguments, 1),
92
+ i, layer;
93
+
94
+ for (i in this._layers) {
95
+ layer = this._layers[i];
96
+
97
+ if (layer[methodName]) {
98
+ layer[methodName].apply(layer, args);
99
+ }
100
+ }
101
+
102
+ return this;
103
+ },
104
+
105
+ onAdd: function (map) {
106
+ this.eachLayer(map.addLayer, map);
107
+ },
108
+
109
+ onRemove: function (map) {
110
+ this.eachLayer(map.removeLayer, map);
111
+ },
112
+
113
+ // @method eachLayer(fn: Function, context?: Object): this
114
+ // Iterates over the layers of the group, optionally specifying context of the iterator function.
115
+ // ```js
116
+ // group.eachLayer(function (layer) {
117
+ // layer.bindPopup('Hello');
118
+ // });
119
+ // ```
120
+ eachLayer: function (method, context) {
121
+ for (var i in this._layers) {
122
+ method.call(context, this._layers[i]);
123
+ }
124
+ return this;
125
+ },
126
+
127
+ // @method getLayer(id: Number): Layer
128
+ // Returns the layer with the given internal ID.
129
+ getLayer: function (id) {
130
+ return this._layers[id];
131
+ },
132
+
133
+ // @method getLayers(): Layer[]
134
+ // Returns an array of all the layers added to the group.
135
+ getLayers: function () {
136
+ var layers = [];
137
+ this.eachLayer(layers.push, layers);
138
+ return layers;
139
+ },
140
+
141
+ // @method setZIndex(zIndex: Number): this
142
+ // Calls `setZIndex` on every layer contained in this group, passing the z-index.
143
+ setZIndex: function (zIndex) {
144
+ return this.invoke('setZIndex', zIndex);
145
+ },
146
+
147
+ // @method getLayerId(layer: Layer): Number
148
+ // Returns the internal ID for a layer
149
+ getLayerId: function (layer) {
150
+ return Util.stamp(layer);
151
+ }
152
+ });
153
+
154
+
155
+ // @factory L.layerGroup(layers?: Layer[], options?: Object)
156
+ // Create a layer group, optionally given an initial set of layers and an `options` object.
157
+ export var layerGroup = function (layers, options) {
158
+ return new LayerGroup(layers, options);
159
+ };
@@ -0,0 +1,506 @@
1
+ import {DivOverlay} from './DivOverlay';
2
+ import * as DomEvent from '../dom/DomEvent';
3
+ import * as DomUtil from '../dom/DomUtil';
4
+ import {Point, toPoint} from '../geometry/Point';
5
+ import {Map} from '../map/Map';
6
+ import {Layer} from './Layer';
7
+ import {Path} from './vector/Path';
8
+ import {FeatureGroup} from './FeatureGroup';
9
+
10
+ /*
11
+ * @class Popup
12
+ * @inherits DivOverlay
13
+ * @aka L.Popup
14
+ * Used to open popups in certain places of the map. Use [Map.openPopup](#map-openpopup) to
15
+ * open popups while making sure that only one popup is open at one time
16
+ * (recommended for usability), or use [Map.addLayer](#map-addlayer) to open as many as you want.
17
+ *
18
+ * @example
19
+ *
20
+ * If you want to just bind a popup to marker click and then open it, it's really easy:
21
+ *
22
+ * ```js
23
+ * marker.bindPopup(popupContent).openPopup();
24
+ * ```
25
+ * Path overlays like polylines also have a `bindPopup` method.
26
+ *
27
+ * A popup can be also standalone:
28
+ *
29
+ * ```js
30
+ * var popup = L.popup()
31
+ * .setLatLng(latlng)
32
+ * .setContent('<p>Hello world!<br />This is a nice popup.</p>')
33
+ * .openOn(map);
34
+ * ```
35
+ * or
36
+ * ```js
37
+ * var popup = L.popup(latlng, {content: '<p>Hello world!<br />This is a nice popup.</p>')
38
+ * .openOn(map);
39
+ * ```
40
+ */
41
+
42
+
43
+ // @namespace Popup
44
+ export var Popup = DivOverlay.extend({
45
+
46
+ // @section
47
+ // @aka Popup options
48
+ options: {
49
+ // @option pane: String = 'popupPane'
50
+ // `Map pane` where the popup will be added.
51
+ pane: 'popupPane',
52
+
53
+ // @option offset: Point = Point(0, 7)
54
+ // The offset of the popup position.
55
+ offset: [0, 7],
56
+
57
+ // @option maxWidth: Number = 300
58
+ // Max width of the popup, in pixels.
59
+ maxWidth: 300,
60
+
61
+ // @option minWidth: Number = 50
62
+ // Min width of the popup, in pixels.
63
+ minWidth: 50,
64
+
65
+ // @option maxHeight: Number = null
66
+ // If set, creates a scrollable container of the given height
67
+ // inside a popup if its content exceeds it.
68
+ // The scrollable container can be styled using the
69
+ // `leaflet-popup-scrolled` CSS class selector.
70
+ maxHeight: null,
71
+
72
+ // @option autoPan: Boolean = true
73
+ // Set it to `false` if you don't want the map to do panning animation
74
+ // to fit the opened popup.
75
+ autoPan: true,
76
+
77
+ // @option autoPanPaddingTopLeft: Point = null
78
+ // The margin between the popup and the top left corner of the map
79
+ // view after autopanning was performed.
80
+ autoPanPaddingTopLeft: null,
81
+
82
+ // @option autoPanPaddingBottomRight: Point = null
83
+ // The margin between the popup and the bottom right corner of the map
84
+ // view after autopanning was performed.
85
+ autoPanPaddingBottomRight: null,
86
+
87
+ // @option autoPanPadding: Point = Point(5, 5)
88
+ // Equivalent of setting both top left and bottom right autopan padding to the same value.
89
+ autoPanPadding: [5, 5],
90
+
91
+ // @option keepInView: Boolean = false
92
+ // Set it to `true` if you want to prevent users from panning the popup
93
+ // off of the screen while it is open.
94
+ keepInView: false,
95
+
96
+ // @option closeButton: Boolean = true
97
+ // Controls the presence of a close button in the popup.
98
+ closeButton: true,
99
+
100
+ // @option autoClose: Boolean = true
101
+ // Set it to `false` if you want to override the default behavior of
102
+ // the popup closing when another popup is opened.
103
+ autoClose: true,
104
+
105
+ // @option closeOnEscapeKey: Boolean = true
106
+ // Set it to `false` if you want to override the default behavior of
107
+ // the ESC key for closing of the popup.
108
+ closeOnEscapeKey: true,
109
+
110
+ // @option closeOnClick: Boolean = *
111
+ // Set it if you want to override the default behavior of the popup closing when user clicks
112
+ // on the map. Defaults to the map's [`closePopupOnClick`](#map-closepopuponclick) option.
113
+
114
+ // @option className: String = ''
115
+ // A custom CSS class name to assign to the popup.
116
+ className: ''
117
+ },
118
+
119
+ // @namespace Popup
120
+ // @method openOn(map: Map): this
121
+ // Alternative to `map.openPopup(popup)`.
122
+ // Adds the popup to the map and closes the previous one.
123
+ openOn: function (map) {
124
+ map = arguments.length ? map : this._source._map; // experimental, not the part of public api
125
+
126
+ if (!map.hasLayer(this) && map._popup && map._popup.options.autoClose) {
127
+ map.removeLayer(map._popup);
128
+ }
129
+ map._popup = this;
130
+
131
+ return DivOverlay.prototype.openOn.call(this, map);
132
+ },
133
+
134
+ onAdd: function (map) {
135
+ DivOverlay.prototype.onAdd.call(this, map);
136
+
137
+ // @namespace Map
138
+ // @section Popup events
139
+ // @event popupopen: PopupEvent
140
+ // Fired when a popup is opened in the map
141
+ map.fire('popupopen', {popup: this});
142
+
143
+ if (this._source) {
144
+ // @namespace Layer
145
+ // @section Popup events
146
+ // @event popupopen: PopupEvent
147
+ // Fired when a popup bound to this layer is opened
148
+ this._source.fire('popupopen', {popup: this}, true);
149
+ // For non-path layers, we toggle the popup when clicking
150
+ // again the layer, so prevent the map to reopen it.
151
+ if (!(this._source instanceof Path)) {
152
+ this._source.on('preclick', DomEvent.stopPropagation);
153
+ }
154
+ }
155
+ },
156
+
157
+ onRemove: function (map) {
158
+ DivOverlay.prototype.onRemove.call(this, map);
159
+
160
+ // @namespace Map
161
+ // @section Popup events
162
+ // @event popupclose: PopupEvent
163
+ // Fired when a popup in the map is closed
164
+ map.fire('popupclose', {popup: this});
165
+
166
+ if (this._source) {
167
+ // @namespace Layer
168
+ // @section Popup events
169
+ // @event popupclose: PopupEvent
170
+ // Fired when a popup bound to this layer is closed
171
+ this._source.fire('popupclose', {popup: this}, true);
172
+ if (!(this._source instanceof Path)) {
173
+ this._source.off('preclick', DomEvent.stopPropagation);
174
+ }
175
+ }
176
+ },
177
+
178
+ getEvents: function () {
179
+ var events = DivOverlay.prototype.getEvents.call(this);
180
+
181
+ if (this.options.closeOnClick !== undefined ? this.options.closeOnClick : this._map.options.closePopupOnClick) {
182
+ events.preclick = this.close;
183
+ }
184
+
185
+ if (this.options.keepInView) {
186
+ events.moveend = this._adjustPan;
187
+ }
188
+
189
+ return events;
190
+ },
191
+
192
+ _initLayout: function () {
193
+ var prefix = 'leaflet-popup',
194
+ container = this._container = DomUtil.create('div',
195
+ prefix + ' ' + (this.options.className || '') +
196
+ ' leaflet-zoom-animated');
197
+
198
+ var wrapper = this._wrapper = DomUtil.create('div', prefix + '-content-wrapper', container);
199
+ this._contentNode = DomUtil.create('div', prefix + '-content', wrapper);
200
+
201
+ DomEvent.disableClickPropagation(container);
202
+ DomEvent.disableScrollPropagation(this._contentNode);
203
+ DomEvent.on(container, 'contextmenu', DomEvent.stopPropagation);
204
+
205
+ this._tipContainer = DomUtil.create('div', prefix + '-tip-container', container);
206
+ this._tip = DomUtil.create('div', prefix + '-tip', this._tipContainer);
207
+
208
+ if (this.options.closeButton) {
209
+ var closeButton = this._closeButton = DomUtil.create('a', prefix + '-close-button', container);
210
+ closeButton.setAttribute('role', 'button'); // overrides the implicit role=link of <a> elements #7399
211
+ closeButton.setAttribute('aria-label', 'Close popup');
212
+ closeButton.href = '#close';
213
+ closeButton.innerHTML = '<span aria-hidden="true">&#215;</span>';
214
+
215
+ DomEvent.on(closeButton, 'click', function (ev) {
216
+ DomEvent.preventDefault(ev);
217
+ this.close();
218
+ }, this);
219
+ }
220
+ },
221
+
222
+ _updateLayout: function () {
223
+ var container = this._contentNode,
224
+ style = container.style;
225
+
226
+ style.width = '';
227
+ style.whiteSpace = 'nowrap';
228
+
229
+ var width = container.offsetWidth;
230
+ width = Math.min(width, this.options.maxWidth);
231
+ width = Math.max(width, this.options.minWidth);
232
+
233
+ style.width = (width + 1) + 'px';
234
+ style.whiteSpace = '';
235
+
236
+ style.height = '';
237
+
238
+ var height = container.offsetHeight,
239
+ maxHeight = this.options.maxHeight,
240
+ scrolledClass = 'leaflet-popup-scrolled';
241
+
242
+ if (maxHeight && height > maxHeight) {
243
+ style.height = maxHeight + 'px';
244
+ DomUtil.addClass(container, scrolledClass);
245
+ } else {
246
+ DomUtil.removeClass(container, scrolledClass);
247
+ }
248
+
249
+ this._containerWidth = this._container.offsetWidth;
250
+ },
251
+
252
+ _animateZoom: function (e) {
253
+ var pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center),
254
+ anchor = this._getAnchor();
255
+ DomUtil.setPosition(this._container, pos.add(anchor));
256
+ },
257
+
258
+ _adjustPan: function () {
259
+ if (!this.options.autoPan) { return; }
260
+ if (this._map._panAnim) { this._map._panAnim.stop(); }
261
+
262
+ // We can endlessly recurse if keepInView is set and the view resets.
263
+ // Let's guard against that by exiting early if we're responding to our own autopan.
264
+ if (this._autopanning) {
265
+ this._autopanning = false;
266
+ return;
267
+ }
268
+
269
+ var map = this._map,
270
+ marginBottom = parseInt(DomUtil.getStyle(this._container, 'marginBottom'), 10) || 0,
271
+ containerHeight = this._container.offsetHeight + marginBottom,
272
+ containerWidth = this._containerWidth,
273
+ layerPos = new Point(this._containerLeft, -containerHeight - this._containerBottom);
274
+
275
+ layerPos._add(DomUtil.getPosition(this._container));
276
+
277
+ var containerPos = map.layerPointToContainerPoint(layerPos),
278
+ padding = toPoint(this.options.autoPanPadding),
279
+ paddingTL = toPoint(this.options.autoPanPaddingTopLeft || padding),
280
+ paddingBR = toPoint(this.options.autoPanPaddingBottomRight || padding),
281
+ size = map.getSize(),
282
+ dx = 0,
283
+ dy = 0;
284
+
285
+ if (containerPos.x + containerWidth + paddingBR.x > size.x) { // right
286
+ dx = containerPos.x + containerWidth - size.x + paddingBR.x;
287
+ }
288
+ if (containerPos.x - dx - paddingTL.x < 0) { // left
289
+ dx = containerPos.x - paddingTL.x;
290
+ }
291
+ if (containerPos.y + containerHeight + paddingBR.y > size.y) { // bottom
292
+ dy = containerPos.y + containerHeight - size.y + paddingBR.y;
293
+ }
294
+ if (containerPos.y - dy - paddingTL.y < 0) { // top
295
+ dy = containerPos.y - paddingTL.y;
296
+ }
297
+
298
+ // @namespace Map
299
+ // @section Popup events
300
+ // @event autopanstart: Event
301
+ // Fired when the map starts autopanning when opening a popup.
302
+ if (dx || dy) {
303
+ // Track that we're autopanning, as this function will be re-ran on moveend
304
+ if (this.options.keepInView) {
305
+ this._autopanning = true;
306
+ }
307
+
308
+ map
309
+ .fire('autopanstart')
310
+ .panBy([dx, dy]);
311
+ }
312
+ },
313
+
314
+ _getAnchor: function () {
315
+ // Where should we anchor the popup on the source layer?
316
+ return toPoint(this._source && this._source._getPopupAnchor ? this._source._getPopupAnchor() : [0, 0]);
317
+ }
318
+
319
+ });
320
+
321
+ // @namespace Popup
322
+ // @factory L.popup(options?: Popup options, source?: Layer)
323
+ // Instantiates a `Popup` object given an optional `options` object that describes its appearance and location and an optional `source` object that is used to tag the popup with a reference to the Layer to which it refers.
324
+ // @alternative
325
+ // @factory L.popup(latlng: LatLng, options?: Popup options)
326
+ // Instantiates a `Popup` object given `latlng` where the popup will open and an optional `options` object that describes its appearance and location.
327
+ export var popup = function (options, source) {
328
+ return new Popup(options, source);
329
+ };
330
+
331
+
332
+ /* @namespace Map
333
+ * @section Interaction Options
334
+ * @option closePopupOnClick: Boolean = true
335
+ * Set it to `false` if you don't want popups to close when user clicks the map.
336
+ */
337
+ Map.mergeOptions({
338
+ closePopupOnClick: true
339
+ });
340
+
341
+
342
+ // @namespace Map
343
+ // @section Methods for Layers and Controls
344
+ Map.include({
345
+ // @method openPopup(popup: Popup): this
346
+ // Opens the specified popup while closing the previously opened (to make sure only one is opened at one time for usability).
347
+ // @alternative
348
+ // @method openPopup(content: String|HTMLElement, latlng: LatLng, options?: Popup options): this
349
+ // Creates a popup with the specified content and options and opens it in the given point on a map.
350
+ openPopup: function (popup, latlng, options) {
351
+ this._initOverlay(Popup, popup, latlng, options)
352
+ .openOn(this);
353
+
354
+ return this;
355
+ },
356
+
357
+ // @method closePopup(popup?: Popup): this
358
+ // Closes the popup previously opened with [openPopup](#map-openpopup) (or the given one).
359
+ closePopup: function (popup) {
360
+ popup = arguments.length ? popup : this._popup;
361
+ if (popup) {
362
+ popup.close();
363
+ }
364
+ return this;
365
+ }
366
+ });
367
+
368
+ /*
369
+ * @namespace Layer
370
+ * @section Popup methods example
371
+ *
372
+ * All layers share a set of methods convenient for binding popups to it.
373
+ *
374
+ * ```js
375
+ * var layer = L.Polygon(latlngs).bindPopup('Hi There!').addTo(map);
376
+ * layer.openPopup();
377
+ * layer.closePopup();
378
+ * ```
379
+ *
380
+ * Popups will also be automatically opened when the layer is clicked on and closed when the layer is removed from the map or another popup is opened.
381
+ */
382
+
383
+ // @section Popup methods
384
+ Layer.include({
385
+
386
+ // @method bindPopup(content: String|HTMLElement|Function|Popup, options?: Popup options): this
387
+ // Binds a popup to the layer with the passed `content` and sets up the
388
+ // necessary event listeners. If a `Function` is passed it will receive
389
+ // the layer as the first argument and should return a `String` or `HTMLElement`.
390
+ bindPopup: function (content, options) {
391
+ this._popup = this._initOverlay(Popup, this._popup, content, options);
392
+ if (!this._popupHandlersAdded) {
393
+ this.on({
394
+ click: this._openPopup,
395
+ keypress: this._onKeyPress,
396
+ remove: this.closePopup,
397
+ move: this._movePopup
398
+ });
399
+ this._popupHandlersAdded = true;
400
+ }
401
+
402
+ return this;
403
+ },
404
+
405
+ // @method unbindPopup(): this
406
+ // Removes the popup previously bound with `bindPopup`.
407
+ unbindPopup: function () {
408
+ if (this._popup) {
409
+ this.off({
410
+ click: this._openPopup,
411
+ keypress: this._onKeyPress,
412
+ remove: this.closePopup,
413
+ move: this._movePopup
414
+ });
415
+ this._popupHandlersAdded = false;
416
+ this._popup = null;
417
+ }
418
+ return this;
419
+ },
420
+
421
+ // @method openPopup(latlng?: LatLng): this
422
+ // Opens the bound popup at the specified `latlng` or at the default popup anchor if no `latlng` is passed.
423
+ openPopup: function (latlng) {
424
+ if (this._popup) {
425
+ if (!(this instanceof FeatureGroup)) {
426
+ this._popup._source = this;
427
+ }
428
+ if (this._popup._prepareOpen(latlng || this._latlng)) {
429
+ // open the popup on the map
430
+ this._popup.openOn(this._map);
431
+ }
432
+ }
433
+ return this;
434
+ },
435
+
436
+ // @method closePopup(): this
437
+ // Closes the popup bound to this layer if it is open.
438
+ closePopup: function () {
439
+ if (this._popup) {
440
+ this._popup.close();
441
+ }
442
+ return this;
443
+ },
444
+
445
+ // @method togglePopup(): this
446
+ // Opens or closes the popup bound to this layer depending on its current state.
447
+ togglePopup: function () {
448
+ if (this._popup) {
449
+ this._popup.toggle(this);
450
+ }
451
+ return this;
452
+ },
453
+
454
+ // @method isPopupOpen(): boolean
455
+ // Returns `true` if the popup bound to this layer is currently open.
456
+ isPopupOpen: function () {
457
+ return (this._popup ? this._popup.isOpen() : false);
458
+ },
459
+
460
+ // @method setPopupContent(content: String|HTMLElement|Popup): this
461
+ // Sets the content of the popup bound to this layer.
462
+ setPopupContent: function (content) {
463
+ if (this._popup) {
464
+ this._popup.setContent(content);
465
+ }
466
+ return this;
467
+ },
468
+
469
+ // @method getPopup(): Popup
470
+ // Returns the popup bound to this layer.
471
+ getPopup: function () {
472
+ return this._popup;
473
+ },
474
+
475
+ _openPopup: function (e) {
476
+ if (!this._popup || !this._map) {
477
+ return;
478
+ }
479
+ // prevent map click
480
+ DomEvent.stop(e);
481
+
482
+ var target = e.layer || e.target;
483
+ if (this._popup._source === target && !(target instanceof Path)) {
484
+ // treat it like a marker and figure out
485
+ // if we should toggle it open/closed
486
+ if (this._map.hasLayer(this._popup)) {
487
+ this.closePopup();
488
+ } else {
489
+ this.openPopup(e.latlng);
490
+ }
491
+ return;
492
+ }
493
+ this._popup._source = target;
494
+ this.openPopup(e.latlng);
495
+ },
496
+
497
+ _movePopup: function (e) {
498
+ this._popup.setLatLng(e.latlng);
499
+ },
500
+
501
+ _onKeyPress: function (e) {
502
+ if (e.originalEvent.keyCode === 13) {
503
+ this._openPopup(e);
504
+ }
505
+ }
506
+ });
@@ -0,0 +1,50 @@
1
+ import {ImageOverlay} from './ImageOverlay';
2
+ import * as DomUtil from '../dom/DomUtil';
3
+ import * as Util from '../core/Util';
4
+
5
+ /*
6
+ * @class SVGOverlay
7
+ * @aka L.SVGOverlay
8
+ * @inherits ImageOverlay
9
+ *
10
+ * Used to load, display and provide DOM access to an SVG file over specific bounds of the map. Extends `ImageOverlay`.
11
+ *
12
+ * An SVG overlay uses the [`<svg>`](https://developer.mozilla.org/docs/Web/SVG/Element/svg) element.
13
+ *
14
+ * @example
15
+ *
16
+ * ```js
17
+ * var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
18
+ * svgElement.setAttribute('xmlns', "http://www.w3.org/2000/svg");
19
+ * svgElement.setAttribute('viewBox', "0 0 200 200");
20
+ * svgElement.innerHTML = '<rect width="200" height="200"/><rect x="75" y="23" width="50" height="50" style="fill:red"/><rect x="75" y="123" width="50" height="50" style="fill:#0013ff"/>';
21
+ * var svgElementBounds = [ [ 32, -130 ], [ 13, -100 ] ];
22
+ * L.svgOverlay(svgElement, svgElementBounds).addTo(map);
23
+ * ```
24
+ */
25
+
26
+ export var SVGOverlay = ImageOverlay.extend({
27
+ _initImage: function () {
28
+ var el = this._image = this._url;
29
+
30
+ DomUtil.addClass(el, 'leaflet-image-layer');
31
+ if (this._zoomAnimated) { DomUtil.addClass(el, 'leaflet-zoom-animated'); }
32
+ if (this.options.className) { DomUtil.addClass(el, this.options.className); }
33
+
34
+ el.onselectstart = Util.falseFn;
35
+ el.onmousemove = Util.falseFn;
36
+ }
37
+
38
+ // @method getElement(): SVGElement
39
+ // Returns the instance of [`SVGElement`](https://developer.mozilla.org/docs/Web/API/SVGElement)
40
+ // used by this overlay.
41
+ });
42
+
43
+
44
+ // @factory L.svgOverlay(svg: String|SVGElement, bounds: LatLngBounds, options?: SVGOverlay options)
45
+ // Instantiates an image overlay object given an SVG element and the geographical bounds it is tied to.
46
+ // A viewBox attribute is required on the SVG element to zoom in and out properly.
47
+
48
+ export function svgOverlay(el, bounds, options) {
49
+ return new SVGOverlay(el, bounds, options);
50
+ }