decidim 0.26.9 → 0.26.10

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.
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,57 @@
1
+ import {Class} from './Class';
2
+
3
+ /*
4
+ L.Handler is a base class for handler classes that are used internally to inject
5
+ interaction features like dragging to classes like Map and Marker.
6
+ */
7
+
8
+ // @class Handler
9
+ // @aka L.Handler
10
+ // Abstract class for map interaction handlers
11
+
12
+ export var Handler = Class.extend({
13
+ initialize: function (map) {
14
+ this._map = map;
15
+ },
16
+
17
+ // @method enable(): this
18
+ // Enables the handler
19
+ enable: function () {
20
+ if (this._enabled) { return this; }
21
+
22
+ this._enabled = true;
23
+ this.addHooks();
24
+ return this;
25
+ },
26
+
27
+ // @method disable(): this
28
+ // Disables the handler
29
+ disable: function () {
30
+ if (!this._enabled) { return this; }
31
+
32
+ this._enabled = false;
33
+ this.removeHooks();
34
+ return this;
35
+ },
36
+
37
+ // @method enabled(): Boolean
38
+ // Returns `true` if the handler is enabled
39
+ enabled: function () {
40
+ return !!this._enabled;
41
+ }
42
+
43
+ // @section Extension methods
44
+ // Classes inheriting from `Handler` must implement the two following methods:
45
+ // @method addHooks()
46
+ // Called when the handler is enabled, should add event hooks.
47
+ // @method removeHooks()
48
+ // Called when the handler is disabled, should remove the event hooks added previously.
49
+ });
50
+
51
+ // @section There is static function which can be called without instantiating L.Handler:
52
+ // @function addTo(map: Map, name: String): this
53
+ // Adds a new Handler to the given map with the given name.
54
+ Handler.addTo = function (map, name) {
55
+ map.addHandler(name, this);
56
+ return this;
57
+ };
@@ -0,0 +1,241 @@
1
+ /*
2
+ * @namespace Util
3
+ *
4
+ * Various utility functions, used by Leaflet internally.
5
+ */
6
+
7
+ // @function extend(dest: Object, src?: Object): Object
8
+ // Merges the properties of the `src` object (or multiple objects) into `dest` object and returns the latter. Has an `L.extend` shortcut.
9
+ export function extend(dest) {
10
+ var i, j, len, src;
11
+
12
+ for (j = 1, len = arguments.length; j < len; j++) {
13
+ src = arguments[j];
14
+ for (i in src) {
15
+ dest[i] = src[i];
16
+ }
17
+ }
18
+ return dest;
19
+ }
20
+
21
+ // @function create(proto: Object, properties?: Object): Object
22
+ // Compatibility polyfill for [Object.create](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/create)
23
+ export var create = Object.create || (function () {
24
+ function F() {}
25
+ return function (proto) {
26
+ F.prototype = proto;
27
+ return new F();
28
+ };
29
+ })();
30
+
31
+ // @function bind(fn: Function, …): Function
32
+ // Returns a new function bound to the arguments passed, like [Function.prototype.bind](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).
33
+ // Has a `L.bind()` shortcut.
34
+ export function bind(fn, obj) {
35
+ var slice = Array.prototype.slice;
36
+
37
+ if (fn.bind) {
38
+ return fn.bind.apply(fn, slice.call(arguments, 1));
39
+ }
40
+
41
+ var args = slice.call(arguments, 2);
42
+
43
+ return function () {
44
+ return fn.apply(obj, args.length ? args.concat(slice.call(arguments)) : arguments);
45
+ };
46
+ }
47
+
48
+ // @property lastId: Number
49
+ // Last unique ID used by [`stamp()`](#util-stamp)
50
+ export var lastId = 0;
51
+
52
+ // @function stamp(obj: Object): Number
53
+ // Returns the unique ID of an object, assigning it one if it doesn't have it.
54
+ export function stamp(obj) {
55
+ if (!('_leaflet_id' in obj)) {
56
+ obj['_leaflet_id'] = ++lastId;
57
+ }
58
+ return obj._leaflet_id;
59
+ }
60
+
61
+ // @function throttle(fn: Function, time: Number, context: Object): Function
62
+ // Returns a function which executes function `fn` with the given scope `context`
63
+ // (so that the `this` keyword refers to `context` inside `fn`'s code). The function
64
+ // `fn` will be called no more than one time per given amount of `time`. The arguments
65
+ // received by the bound function will be any arguments passed when binding the
66
+ // function, followed by any arguments passed when invoking the bound function.
67
+ // Has an `L.throttle` shortcut.
68
+ export function throttle(fn, time, context) {
69
+ var lock, args, wrapperFn, later;
70
+
71
+ later = function () {
72
+ // reset lock and call if queued
73
+ lock = false;
74
+ if (args) {
75
+ wrapperFn.apply(context, args);
76
+ args = false;
77
+ }
78
+ };
79
+
80
+ wrapperFn = function () {
81
+ if (lock) {
82
+ // called too soon, queue to call later
83
+ args = arguments;
84
+
85
+ } else {
86
+ // call and lock until later
87
+ fn.apply(context, arguments);
88
+ setTimeout(later, time);
89
+ lock = true;
90
+ }
91
+ };
92
+
93
+ return wrapperFn;
94
+ }
95
+
96
+ // @function wrapNum(num: Number, range: Number[], includeMax?: Boolean): Number
97
+ // Returns the number `num` modulo `range` in such a way so it lies within
98
+ // `range[0]` and `range[1]`. The returned value will be always smaller than
99
+ // `range[1]` unless `includeMax` is set to `true`.
100
+ export function wrapNum(x, range, includeMax) {
101
+ var max = range[1],
102
+ min = range[0],
103
+ d = max - min;
104
+ return x === max && includeMax ? x : ((x - min) % d + d) % d + min;
105
+ }
106
+
107
+ // @function falseFn(): Function
108
+ // Returns a function which always returns `false`.
109
+ export function falseFn() { return false; }
110
+
111
+ // @function formatNum(num: Number, precision?: Number|false): Number
112
+ // Returns the number `num` rounded with specified `precision`.
113
+ // The default `precision` value is 6 decimal places.
114
+ // `false` can be passed to skip any processing (can be useful to avoid round-off errors).
115
+ export function formatNum(num, precision) {
116
+ if (precision === false) { return num; }
117
+ var pow = Math.pow(10, precision === undefined ? 6 : precision);
118
+ return Math.round(num * pow) / pow;
119
+ }
120
+
121
+ // @function trim(str: String): String
122
+ // Compatibility polyfill for [String.prototype.trim](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim)
123
+ export function trim(str) {
124
+ return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
125
+ }
126
+
127
+ // @function splitWords(str: String): String[]
128
+ // Trims and splits the string on whitespace and returns the array of parts.
129
+ export function splitWords(str) {
130
+ return trim(str).split(/\s+/);
131
+ }
132
+
133
+ // @function setOptions(obj: Object, options: Object): Object
134
+ // Merges the given properties to the `options` of the `obj` object, returning the resulting options. See `Class options`. Has an `L.setOptions` shortcut.
135
+ export function setOptions(obj, options) {
136
+ if (!Object.prototype.hasOwnProperty.call(obj, 'options')) {
137
+ obj.options = obj.options ? create(obj.options) : {};
138
+ }
139
+ for (var i in options) {
140
+ obj.options[i] = options[i];
141
+ }
142
+ return obj.options;
143
+ }
144
+
145
+ // @function getParamString(obj: Object, existingUrl?: String, uppercase?: Boolean): String
146
+ // Converts an object into a parameter URL string, e.g. `{a: "foo", b: "bar"}`
147
+ // translates to `'?a=foo&b=bar'`. If `existingUrl` is set, the parameters will
148
+ // be appended at the end. If `uppercase` is `true`, the parameter names will
149
+ // be uppercased (e.g. `'?A=foo&B=bar'`)
150
+ export function getParamString(obj, existingUrl, uppercase) {
151
+ var params = [];
152
+ for (var i in obj) {
153
+ params.push(encodeURIComponent(uppercase ? i.toUpperCase() : i) + '=' + encodeURIComponent(obj[i]));
154
+ }
155
+ return ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&');
156
+ }
157
+
158
+ var templateRe = /\{ *([\w_ -]+) *\}/g;
159
+
160
+ // @function template(str: String, data: Object): String
161
+ // Simple templating facility, accepts a template string of the form `'Hello {a}, {b}'`
162
+ // and a data object like `{a: 'foo', b: 'bar'}`, returns evaluated string
163
+ // `('Hello foo, bar')`. You can also specify functions instead of strings for
164
+ // data values — they will be evaluated passing `data` as an argument.
165
+ export function template(str, data) {
166
+ return str.replace(templateRe, function (str, key) {
167
+ var value = data[key];
168
+
169
+ if (value === undefined) {
170
+ throw new Error('No value provided for variable ' + str);
171
+
172
+ } else if (typeof value === 'function') {
173
+ value = value(data);
174
+ }
175
+ return value;
176
+ });
177
+ }
178
+
179
+ // @function isArray(obj): Boolean
180
+ // Compatibility polyfill for [Array.isArray](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray)
181
+ export var isArray = Array.isArray || function (obj) {
182
+ return (Object.prototype.toString.call(obj) === '[object Array]');
183
+ };
184
+
185
+ // @function indexOf(array: Array, el: Object): Number
186
+ // Compatibility polyfill for [Array.prototype.indexOf](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)
187
+ export function indexOf(array, el) {
188
+ for (var i = 0; i < array.length; i++) {
189
+ if (array[i] === el) { return i; }
190
+ }
191
+ return -1;
192
+ }
193
+
194
+ // @property emptyImageUrl: String
195
+ // Data URI string containing a base64-encoded empty GIF image.
196
+ // Used as a hack to free memory from unused images on WebKit-powered
197
+ // mobile devices (by setting image `src` to this string).
198
+ export var emptyImageUrl = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';
199
+
200
+ // inspired by https://paulirish.com/2011/requestanimationframe-for-smart-animating/
201
+
202
+ function getPrefixed(name) {
203
+ return window['webkit' + name] || window['moz' + name] || window['ms' + name];
204
+ }
205
+
206
+ var lastTime = 0;
207
+
208
+ // fallback for IE 7-8
209
+ function timeoutDefer(fn) {
210
+ var time = +new Date(),
211
+ timeToCall = Math.max(0, 16 - (time - lastTime));
212
+
213
+ lastTime = time + timeToCall;
214
+ return window.setTimeout(fn, timeToCall);
215
+ }
216
+
217
+ export var requestFn = window.requestAnimationFrame || getPrefixed('RequestAnimationFrame') || timeoutDefer;
218
+ export var cancelFn = window.cancelAnimationFrame || getPrefixed('CancelAnimationFrame') ||
219
+ getPrefixed('CancelRequestAnimationFrame') || function (id) { window.clearTimeout(id); };
220
+
221
+ // @function requestAnimFrame(fn: Function, context?: Object, immediate?: Boolean): Number
222
+ // Schedules `fn` to be executed when the browser repaints. `fn` is bound to
223
+ // `context` if given. When `immediate` is set, `fn` is called immediately if
224
+ // the browser doesn't have native support for
225
+ // [`window.requestAnimationFrame`](https://developer.mozilla.org/docs/Web/API/window/requestAnimationFrame),
226
+ // otherwise it's delayed. Returns a request ID that can be used to cancel the request.
227
+ export function requestAnimFrame(fn, context, immediate) {
228
+ if (immediate && requestFn === timeoutDefer) {
229
+ fn.call(context);
230
+ } else {
231
+ return requestFn.call(window, bind(fn, context));
232
+ }
233
+ }
234
+
235
+ // @function cancelAnimFrame(id: Number): undefined
236
+ // Cancels a previous `requestAnimFrame`. See also [window.cancelAnimationFrame](https://developer.mozilla.org/docs/Web/API/window/cancelAnimationFrame).
237
+ export function cancelAnimFrame(id) {
238
+ if (id) {
239
+ cancelFn.call(window, id);
240
+ }
241
+ }
@@ -0,0 +1,15 @@
1
+ import Browser from './Browser';
2
+ export {Browser};
3
+
4
+ export {Class} from './Class';
5
+
6
+ import {Evented} from './Events';
7
+ import {Events} from './Events';
8
+ export {Evented};
9
+ export var Mixin = {Events: Events};
10
+
11
+ export {Handler} from './Handler';
12
+
13
+ import * as Util from './Util';
14
+ export {Util};
15
+ export {extend, bind, stamp, setOptions} from './Util';
@@ -0,0 +1,91 @@
1
+ import * as DomEvent from './DomEvent';
2
+
3
+ /*
4
+ * Extends the event handling code with double tap support for mobile browsers.
5
+ *
6
+ * Note: currently most browsers fire native dblclick, with only a few exceptions
7
+ * (see https://github.com/Leaflet/Leaflet/issues/7012#issuecomment-595087386)
8
+ */
9
+
10
+ function makeDblclick(event) {
11
+ // in modern browsers `type` cannot be just overridden:
12
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only
13
+ var newEvent = {},
14
+ prop, i;
15
+ for (i in event) {
16
+ prop = event[i];
17
+ newEvent[i] = prop && prop.bind ? prop.bind(event) : prop;
18
+ }
19
+ event = newEvent;
20
+ newEvent.type = 'dblclick';
21
+ newEvent.detail = 2;
22
+ newEvent.isTrusted = false;
23
+ newEvent._simulated = true; // for debug purposes
24
+ return newEvent;
25
+ }
26
+
27
+ var delay = 200;
28
+ export function addDoubleTapListener(obj, handler) {
29
+ // Most browsers handle double tap natively
30
+ obj.addEventListener('dblclick', handler);
31
+
32
+ // On some platforms the browser doesn't fire native dblclicks for touch events.
33
+ // It seems that in all such cases `detail` property of `click` event is always `1`.
34
+ // So here we rely on that fact to avoid excessive 'dblclick' simulation when not needed.
35
+ var last = 0,
36
+ detail;
37
+ function simDblclick(e) {
38
+ if (e.detail !== 1) {
39
+ detail = e.detail; // keep in sync to avoid false dblclick in some cases
40
+ return;
41
+ }
42
+
43
+ if (e.pointerType === 'mouse' ||
44
+ (e.sourceCapabilities && !e.sourceCapabilities.firesTouchEvents)) {
45
+
46
+ return;
47
+ }
48
+
49
+ // When clicking on an <input>, the browser generates a click on its
50
+ // <label> (and vice versa) triggering two clicks in quick succession.
51
+ // This ignores clicks on elements which are a label with a 'for'
52
+ // attribute (or children of such a label), but not children of
53
+ // a <input>.
54
+ var path = DomEvent.getPropagationPath(e);
55
+ if (path.some(function (el) {
56
+ return el instanceof HTMLLabelElement && el.attributes.for;
57
+ }) &&
58
+ !path.some(function (el) {
59
+ return (
60
+ el instanceof HTMLInputElement ||
61
+ el instanceof HTMLSelectElement
62
+ );
63
+ })
64
+ ) {
65
+ return;
66
+ }
67
+
68
+ var now = Date.now();
69
+ if (now - last <= delay) {
70
+ detail++;
71
+ if (detail === 2) {
72
+ handler(makeDblclick(e));
73
+ }
74
+ } else {
75
+ detail = 1;
76
+ }
77
+ last = now;
78
+ }
79
+
80
+ obj.addEventListener('click', simDblclick);
81
+
82
+ return {
83
+ dblclick: handler,
84
+ simDblclick: simDblclick
85
+ };
86
+ }
87
+
88
+ export function removeDoubleTapListener(obj, handlers) {
89
+ obj.removeEventListener('dblclick', handlers.dblclick);
90
+ obj.removeEventListener('click', handlers.simDblclick);
91
+ }
@@ -0,0 +1,97 @@
1
+ import * as DomEvent from './DomEvent';
2
+ import Browser from '../core/Browser';
3
+ import {falseFn} from '../core/Util';
4
+
5
+ /*
6
+ * Extends L.DomEvent to provide touch support for Internet Explorer and Windows-based devices.
7
+ */
8
+
9
+ var POINTER_DOWN = Browser.msPointer ? 'MSPointerDown' : 'pointerdown';
10
+ var POINTER_MOVE = Browser.msPointer ? 'MSPointerMove' : 'pointermove';
11
+ var POINTER_UP = Browser.msPointer ? 'MSPointerUp' : 'pointerup';
12
+ var POINTER_CANCEL = Browser.msPointer ? 'MSPointerCancel' : 'pointercancel';
13
+ var pEvent = {
14
+ touchstart : POINTER_DOWN,
15
+ touchmove : POINTER_MOVE,
16
+ touchend : POINTER_UP,
17
+ touchcancel : POINTER_CANCEL
18
+ };
19
+ var handle = {
20
+ touchstart : _onPointerStart,
21
+ touchmove : _handlePointer,
22
+ touchend : _handlePointer,
23
+ touchcancel : _handlePointer
24
+ };
25
+ var _pointers = {};
26
+ var _pointerDocListener = false;
27
+
28
+ // Provides a touch events wrapper for (ms)pointer events.
29
+ // ref https://www.w3.org/TR/pointerevents/ https://www.w3.org/Bugs/Public/show_bug.cgi?id=22890
30
+
31
+ export function addPointerListener(obj, type, handler) {
32
+ if (type === 'touchstart') {
33
+ _addPointerDocListener();
34
+ }
35
+ if (!handle[type]) {
36
+ console.warn('wrong event specified:', type);
37
+ return falseFn;
38
+ }
39
+ handler = handle[type].bind(this, handler);
40
+ obj.addEventListener(pEvent[type], handler, false);
41
+ return handler;
42
+ }
43
+
44
+ export function removePointerListener(obj, type, handler) {
45
+ if (!pEvent[type]) {
46
+ console.warn('wrong event specified:', type);
47
+ return;
48
+ }
49
+ obj.removeEventListener(pEvent[type], handler, false);
50
+ }
51
+
52
+ function _globalPointerDown(e) {
53
+ _pointers[e.pointerId] = e;
54
+ }
55
+
56
+ function _globalPointerMove(e) {
57
+ if (_pointers[e.pointerId]) {
58
+ _pointers[e.pointerId] = e;
59
+ }
60
+ }
61
+
62
+ function _globalPointerUp(e) {
63
+ delete _pointers[e.pointerId];
64
+ }
65
+
66
+ function _addPointerDocListener() {
67
+ // need to keep track of what pointers and how many are active to provide e.touches emulation
68
+ if (!_pointerDocListener) {
69
+ // we listen document as any drags that end by moving the touch off the screen get fired there
70
+ document.addEventListener(POINTER_DOWN, _globalPointerDown, true);
71
+ document.addEventListener(POINTER_MOVE, _globalPointerMove, true);
72
+ document.addEventListener(POINTER_UP, _globalPointerUp, true);
73
+ document.addEventListener(POINTER_CANCEL, _globalPointerUp, true);
74
+
75
+ _pointerDocListener = true;
76
+ }
77
+ }
78
+
79
+ function _handlePointer(handler, e) {
80
+ if (e.pointerType === (e.MSPOINTER_TYPE_MOUSE || 'mouse')) { return; }
81
+
82
+ e.touches = [];
83
+ for (var i in _pointers) {
84
+ e.touches.push(_pointers[i]);
85
+ }
86
+ e.changedTouches = [e];
87
+
88
+ handler(e);
89
+ }
90
+
91
+ function _onPointerStart(handler, e) {
92
+ // IE10 specific: MsTouch needs preventDefault. See #2000
93
+ if (e.MSPOINTER_TYPE_TOUCH && e.pointerType === e.MSPOINTER_TYPE_TOUCH) {
94
+ DomEvent.preventDefault(e);
95
+ }
96
+ _handlePointer(handler, e);
97
+ }