From cbaf02034c916e0e3ea1f1f5c21d08c41efd0b3e Mon Sep 17 00:00:00 2001 From: Mstislav Zhivodkov Date: Thu, 20 Apr 2017 17:38:28 +0700 Subject: [PATCH] Remove global L usage (#5463) --- src/control/Control.Layers.js | 2 +- src/core/Class.js | 2 +- src/layer/VideoOverlay.js | 16 +++++++++------- src/layer/vector/Canvas.js | 8 ++++---- src/layer/vector/SVG.js | 10 ++++++---- src/map/Map.js | 6 +++--- src/map/handler/Map.BoxZoom.js | 2 +- 7 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/control/Control.Layers.js b/src/control/Control.Layers.js index a396ba6c..cfb89833 100644 --- a/src/control/Control.Layers.js +++ b/src/control/Control.Layers.js @@ -108,7 +108,7 @@ export var Layers = Control.extend({ }, addTo: function (map) { - L.Control.prototype.addTo.call(this, map); + Control.prototype.addTo.call(this, map); // Trigger expand after Layers Control has been inserted into DOM so that is now has an actual height. return this._expandIfNotCollapsed(); }, diff --git a/src/core/Class.js b/src/core/Class.js index 32e9463f..639d2f81 100644 --- a/src/core/Class.js +++ b/src/core/Class.js @@ -114,7 +114,7 @@ Class.addInitHook = function (fn) { // (Function) || (String, args...) function checkDeprecatedMixinEvents(includes) { if (!L || !L.Mixin) { return; } - includes = L.Util.isArray(includes) ? includes : [includes]; + includes = Util.isArray(includes) ? includes : [includes]; for (var i = 0; i < includes.length; i++) { if (includes[i] === L.Mixin.Events) { diff --git a/src/layer/VideoOverlay.js b/src/layer/VideoOverlay.js index 811729ab..7a12c927 100644 --- a/src/layer/VideoOverlay.js +++ b/src/layer/VideoOverlay.js @@ -1,4 +1,6 @@ import {ImageOverlay} from './ImageOverlay'; +import * as DomUtil from '../dom/DomUtil'; +import * as Util from '../core/Util'; /* * @class VideoOverlay @@ -34,22 +36,22 @@ export var VideoOverlay = ImageOverlay.extend({ }, _initImage: function () { - var vid = this._image = L.DomUtil.create('video', + var vid = this._image = DomUtil.create('video', 'leaflet-image-layer ' + (this._zoomAnimated ? 'leaflet-zoom-animated' : '')); - vid.onselectstart = L.Util.falseFn; - vid.onmousemove = L.Util.falseFn; + vid.onselectstart = Util.falseFn; + vid.onmousemove = Util.falseFn; // @event load: Event // Fired when the video has finished loading the first frame - vid.onloadeddata = L.bind(this.fire, this, 'load'); + vid.onloadeddata = Util.bind(this.fire, this, 'load'); - if (!L.Util.isArray(this._url)) { this._url = [this._url]; } + if (!Util.isArray(this._url)) { this._url = [this._url]; } vid.autoplay = !!this.options.autoplay; vid.loop = !!this.options.loop; for (var i = 0; i < this._url.length; i++) { - var source = L.DomUtil.create('source'); + var source = DomUtil.create('source'); source.src = this._url[i]; vid.appendChild(source); } @@ -65,5 +67,5 @@ export var VideoOverlay = ImageOverlay.extend({ // Instantiates an image overlay object given the URL of the video (or array of URLs) and the // geographical bounds it is tied to. export function videoOverlay(url, bounds, options) { - return new L.VideoOverlay(url, bounds, options); + return new VideoOverlay(url, bounds, options); } diff --git a/src/layer/vector/Canvas.js b/src/layer/vector/Canvas.js index c1171ae0..428efd0e 100644 --- a/src/layer/vector/Canvas.js +++ b/src/layer/vector/Canvas.js @@ -39,7 +39,7 @@ import {Bounds} from '../../geometry/Bounds'; export var Canvas = Renderer.extend({ getEvents: function () { - var events = L.Renderer.prototype.getEvents.call(this); + var events = Renderer.prototype.getEvents.call(this); events.viewprereset = this._onViewPreReset; return events; }, @@ -69,8 +69,8 @@ export var Canvas = Renderer.extend({ _destroyContainer: function () { delete this._ctx; - L.DomUtil.remove(this._container); - L.DomEvent.off(this._container); + DomUtil.remove(this._container); + DomEvent.off(this._container); delete this._container; }, @@ -118,7 +118,7 @@ export var Canvas = Renderer.extend({ }, _reset: function () { - L.Renderer.prototype._reset.call(this); + Renderer.prototype._reset.call(this); if (this._postponeUpdatePaths) { this._postponeUpdatePaths = false; diff --git a/src/layer/vector/SVG.js b/src/layer/vector/SVG.js index 562e8336..3cb20c5d 100644 --- a/src/layer/vector/SVG.js +++ b/src/layer/vector/SVG.js @@ -1,6 +1,8 @@ import {Renderer} from './Renderer'; import * as DomUtil from '../../dom/DomUtil'; +import * as DomEvent from '../../dom/DomEvent'; import * as Browser from '../../core/Browser'; +import {stamp} from '../../core/Util'; import {svgCreate, pointsToPath} from './SVG.Util'; export {pointsToPath}; import {vmlMixin, vmlCreate} from './SVG.VML'; @@ -62,8 +64,8 @@ export var SVG = Renderer.extend({ }, _destroyContainer: function () { - L.DomUtil.remove(this._container); - L.DomEvent.off(this._container); + DomUtil.remove(this._container); + DomEvent.off(this._container); delete this._container; delete this._rootGroup; }, @@ -115,7 +117,7 @@ export var SVG = Renderer.extend({ } this._updateStyle(layer); - this._layers[L.stamp(layer)] = layer; + this._layers[stamp(layer)] = layer; }, _addPath: function (layer) { @@ -127,7 +129,7 @@ export var SVG = Renderer.extend({ _removePath: function (layer) { DomUtil.remove(layer._path); layer.removeInteractiveTarget(layer._path); - delete this._layers[L.stamp(layer)]; + delete this._layers[stamp(layer)]; }, _updatePath: function (layer) { diff --git a/src/map/Map.js b/src/map/Map.js index ec4400ac..8da16f3b 100644 --- a/src/map/Map.js +++ b/src/map/Map.js @@ -721,7 +721,7 @@ export var Map = Evented.extend({ this._layers[i].remove(); } for (i in this._panes) { - L.DomUtil.remove(this._panes[i]); + DomUtil.remove(this._panes[i]); } this._layers = []; @@ -955,7 +955,7 @@ export var Map = Evented.extend({ // value is between -180 and +180 degrees, and the majority of the bounds // overlaps the CRS's bounds. wrapLatLngBounds: function (latlng) { - return this.options.crs.wrapLatLngBounds(L.latLngBounds(latlng)); + return this.options.crs.wrapLatLngBounds(toLatLngBounds(latlng)); }, // @method distance(latlng1: LatLng, latlng2: LatLng): Number @@ -1538,7 +1538,7 @@ export var Map = Evented.extend({ }, _destroyAnimProxy: function () { - L.DomUtil.remove(this._proxy); + DomUtil.remove(this._proxy); delete this._proxy; }, diff --git a/src/map/handler/Map.BoxZoom.js b/src/map/handler/Map.BoxZoom.js index 2d2275b9..aae1b92b 100644 --- a/src/map/handler/Map.BoxZoom.js +++ b/src/map/handler/Map.BoxZoom.js @@ -41,7 +41,7 @@ export var BoxZoom = Handler.extend({ }, _destroy: function () { - L.DomUtil.remove(this._pane); + DomUtil.remove(this._pane); delete this._pane; },