add shortcuts for extend, bind, stamp and setOptions
This commit is contained in:
parent
7517cbcd53
commit
dbd4da6255
@ -33,6 +33,7 @@ An in-progress version being developed on the master branch.
|
||||
* Improved `Control.Layers` to support HTML in layer names (by [@aparshin](https://github.com/aparshin)). [#1055](https://github.com/CloudMade/Leaflet/pull/1055) [#1099](https://github.com/CloudMade/Leaflet/issues/1099)
|
||||
* Removed `Browser` `ua`, `ie`, `gecko`, `opera` properties (no longer needed).
|
||||
* Added `CRS.Simple` to the list of built-in CRS. It was added earlier but not included in the build.
|
||||
* Added `L.extend`, `L.bind`, `L.stamp`, `L.setOptions` shortcuts for corresponding `L.Util` methods.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
|
125
dist/leaflet-src.js
vendored
125
dist/leaflet-src.js
vendored
@ -99,7 +99,7 @@ L.Util = {
|
||||
},
|
||||
|
||||
setOptions: function (obj, options) {
|
||||
obj.options = L.Util.extend({}, obj.options, options);
|
||||
obj.options = L.extend({}, obj.options, options);
|
||||
return obj.options;
|
||||
},
|
||||
|
||||
@ -161,7 +161,7 @@ L.Util = {
|
||||
|
||||
|
||||
L.Util.requestAnimFrame = function (fn, context, immediate, element) {
|
||||
fn = L.Util.bind(fn, context);
|
||||
fn = L.bind(fn, context);
|
||||
|
||||
if (immediate && requestFn === timeoutDefer) {
|
||||
fn();
|
||||
@ -178,6 +178,12 @@ L.Util = {
|
||||
|
||||
}());
|
||||
|
||||
// shortcuts for most used utility functions
|
||||
L.extend = L.Util.extend;
|
||||
L.bind = L.Util.bind;
|
||||
L.stamp = L.Util.stamp;
|
||||
L.setOptions = L.Util.setOptions;
|
||||
|
||||
|
||||
/*
|
||||
* Class powers the OOP facilities of the library. Thanks to John Resig and Dean Edwards for inspiration!
|
||||
@ -212,7 +218,7 @@ L.Class.extend = function (/*Object*/ props) /*-> Class*/ {
|
||||
|
||||
// mix static properties into the class
|
||||
if (props.statics) {
|
||||
L.Util.extend(NewClass, props.statics);
|
||||
L.extend(NewClass, props.statics);
|
||||
delete props.statics;
|
||||
}
|
||||
|
||||
@ -224,11 +230,11 @@ L.Class.extend = function (/*Object*/ props) /*-> Class*/ {
|
||||
|
||||
// merge options
|
||||
if (props.options && proto.options) {
|
||||
props.options = L.Util.extend({}, proto.options, props.options);
|
||||
props.options = L.extend({}, proto.options, props.options);
|
||||
}
|
||||
|
||||
// mix given properties into the prototype
|
||||
L.Util.extend(proto, props);
|
||||
L.extend(proto, props);
|
||||
|
||||
return NewClass;
|
||||
};
|
||||
@ -236,13 +242,14 @@ L.Class.extend = function (/*Object*/ props) /*-> Class*/ {
|
||||
|
||||
// method for adding properties to prototype
|
||||
L.Class.include = function (props) {
|
||||
L.Util.extend(this.prototype, props);
|
||||
L.extend(this.prototype, props);
|
||||
};
|
||||
|
||||
L.Class.mergeOptions = function (options) {
|
||||
L.Util.extend(this.prototype.options, options);
|
||||
L.extend(this.prototype.options, options);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* L.Mixin.Events adds custom events functionality to Leaflet classes
|
||||
*/
|
||||
@ -325,7 +332,7 @@ L.Mixin.Events = {
|
||||
return this;
|
||||
}
|
||||
|
||||
var event = L.Util.extend({
|
||||
var event = L.extend({
|
||||
type: type,
|
||||
target: this
|
||||
}, data);
|
||||
@ -919,7 +926,7 @@ L.LatLng = function (rawLat, rawLng, noWrap) { // (Number, Number[, Boolean])
|
||||
this.lng = lng;
|
||||
};
|
||||
|
||||
L.Util.extend(L.LatLng, {
|
||||
L.extend(L.LatLng, {
|
||||
DEG_TO_RAD: Math.PI / 180,
|
||||
RAD_TO_DEG: 180 / Math.PI,
|
||||
MAX_MARGIN: 1.0E-9 // max margin of error for the "equals" check
|
||||
@ -1190,14 +1197,14 @@ L.CRS = {
|
||||
|
||||
|
||||
|
||||
L.CRS.Simple = L.Util.extend({}, L.CRS, {
|
||||
L.CRS.Simple = L.extend({}, L.CRS, {
|
||||
projection: L.Projection.LonLat,
|
||||
transformation: new L.Transformation(1, 0, 1, 0)
|
||||
});
|
||||
|
||||
|
||||
|
||||
L.CRS.EPSG3857 = L.Util.extend({}, L.CRS, {
|
||||
L.CRS.EPSG3857 = L.extend({}, L.CRS, {
|
||||
code: 'EPSG:3857',
|
||||
|
||||
projection: L.Projection.SphericalMercator,
|
||||
@ -1210,13 +1217,13 @@ L.CRS.EPSG3857 = L.Util.extend({}, L.CRS, {
|
||||
}
|
||||
});
|
||||
|
||||
L.CRS.EPSG900913 = L.Util.extend({}, L.CRS.EPSG3857, {
|
||||
L.CRS.EPSG900913 = L.extend({}, L.CRS.EPSG3857, {
|
||||
code: 'EPSG:900913'
|
||||
});
|
||||
|
||||
|
||||
|
||||
L.CRS.EPSG4326 = L.Util.extend({}, L.CRS, {
|
||||
L.CRS.EPSG4326 = L.extend({}, L.CRS, {
|
||||
code: 'EPSG:4326',
|
||||
|
||||
projection: L.Projection.LonLat,
|
||||
@ -1247,7 +1254,7 @@ L.Map = L.Class.extend({
|
||||
},
|
||||
|
||||
initialize: function (id, options) { // (HTMLElement or String, Object)
|
||||
options = L.Util.setOptions(this, options);
|
||||
options = L.setOptions(this, options);
|
||||
|
||||
this._initContainer(id);
|
||||
this._initLayout();
|
||||
@ -1367,7 +1374,7 @@ L.Map = L.Class.extend({
|
||||
addLayer: function (layer) {
|
||||
// TODO method is too big, refactor
|
||||
|
||||
var id = L.Util.stamp(layer);
|
||||
var id = L.stamp(layer);
|
||||
|
||||
if (this._layers[id]) { return this; }
|
||||
|
||||
@ -1397,7 +1404,7 @@ L.Map = L.Class.extend({
|
||||
},
|
||||
|
||||
removeLayer: function (layer) {
|
||||
var id = L.Util.stamp(layer);
|
||||
var id = L.stamp(layer);
|
||||
|
||||
if (!this._layers[id]) { return; }
|
||||
|
||||
@ -1416,7 +1423,7 @@ L.Map = L.Class.extend({
|
||||
},
|
||||
|
||||
hasLayer: function (layer) {
|
||||
var id = L.Util.stamp(layer);
|
||||
var id = L.stamp(layer);
|
||||
return this._layers.hasOwnProperty(id);
|
||||
},
|
||||
|
||||
@ -1441,7 +1448,7 @@ L.Map = L.Class.extend({
|
||||
this.fire('move');
|
||||
|
||||
clearTimeout(this._sizeTimer);
|
||||
this._sizeTimer = setTimeout(L.Util.bind(this.fire, this, 'moveend'), 200);
|
||||
this._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
@ -1826,7 +1833,7 @@ L.Map = L.Class.extend({
|
||||
this._tileLayersToLoad--;
|
||||
if (this._tileLayersNum && !this._tileLayersToLoad && this._tileBg) {
|
||||
clearTimeout(this._clearTileBgTimer);
|
||||
this._clearTileBgTimer = setTimeout(L.Util.bind(this._clearTileBg, this), 500);
|
||||
this._clearTileBgTimer = setTimeout(L.bind(this._clearTileBg, this), 500);
|
||||
}
|
||||
},
|
||||
|
||||
@ -1951,7 +1958,7 @@ L.Projection.Mercator = {
|
||||
|
||||
|
||||
|
||||
L.CRS.EPSG3395 = L.Util.extend({}, L.CRS, {
|
||||
L.CRS.EPSG3395 = L.extend({}, L.CRS, {
|
||||
code: 'EPSG:3395',
|
||||
|
||||
projection: L.Projection.Mercator,
|
||||
@ -1996,7 +2003,7 @@ L.TileLayer = L.Class.extend({
|
||||
},
|
||||
|
||||
initialize: function (url, options) {
|
||||
options = L.Util.setOptions(this, options);
|
||||
options = L.setOptions(this, options);
|
||||
|
||||
// detecting retina displays, adjusting tileSize and zoom levels
|
||||
if (options.detectRetina && L.Browser.retina && options.maxZoom > 0) {
|
||||
@ -2386,7 +2393,7 @@ L.TileLayer = L.Class.extend({
|
||||
getTileUrl: function (tilePoint) {
|
||||
this._adjustTilePoint(tilePoint);
|
||||
|
||||
return L.Util.template(this._url, L.Util.extend({
|
||||
return L.Util.template(this._url, L.extend({
|
||||
s: this._getSubdomain(tilePoint),
|
||||
z: this._getZoomForUrl(),
|
||||
x: tilePoint.x,
|
||||
@ -2512,7 +2519,7 @@ L.TileLayer.WMS = L.TileLayer.extend({
|
||||
|
||||
this._url = url;
|
||||
|
||||
var wmsParams = L.Util.extend({}, this.defaultWmsParams);
|
||||
var wmsParams = L.extend({}, this.defaultWmsParams);
|
||||
|
||||
if (options.detectRetina && L.Browser.retina) {
|
||||
wmsParams.width = wmsParams.height = this.options.tileSize * 2;
|
||||
@ -2529,7 +2536,7 @@ L.TileLayer.WMS = L.TileLayer.extend({
|
||||
|
||||
this.wmsParams = wmsParams;
|
||||
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
onAdd: function (map) {
|
||||
@ -2561,7 +2568,7 @@ L.TileLayer.WMS = L.TileLayer.extend({
|
||||
|
||||
setParams: function (params, noRedraw) {
|
||||
|
||||
L.Util.extend(this.wmsParams, params);
|
||||
L.extend(this.wmsParams, params);
|
||||
|
||||
if (!noRedraw) {
|
||||
this.redraw();
|
||||
@ -2582,7 +2589,7 @@ L.TileLayer.Canvas = L.TileLayer.extend({
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
redraw: function () {
|
||||
@ -2647,7 +2654,7 @@ L.ImageOverlay = L.Class.extend({
|
||||
this._url = url;
|
||||
this._bounds = L.latLngBounds(bounds);
|
||||
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
onAdd: function (map) {
|
||||
@ -2717,11 +2724,11 @@ L.ImageOverlay = L.Class.extend({
|
||||
this._updateOpacity();
|
||||
|
||||
//TODO createImage util method to remove duplication
|
||||
L.Util.extend(this._image, {
|
||||
L.extend(this._image, {
|
||||
galleryimg: 'no',
|
||||
onselectstart: L.Util.falseFn,
|
||||
onmousemove: L.Util.falseFn,
|
||||
onload: L.Util.bind(this._onImageLoad, this),
|
||||
onload: L.bind(this._onImageLoad, this),
|
||||
src: this._url
|
||||
});
|
||||
},
|
||||
@ -2782,7 +2789,7 @@ L.Icon = L.Class.extend({
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
createIcon: function () {
|
||||
@ -2926,7 +2933,7 @@ L.Marker = L.Class.extend({
|
||||
},
|
||||
|
||||
initialize: function (latlng, options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
this._latlng = L.latLng(latlng);
|
||||
},
|
||||
|
||||
@ -3218,7 +3225,7 @@ L.Popup = L.Class.extend({
|
||||
},
|
||||
|
||||
initialize: function (options, source) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
|
||||
this._source = source;
|
||||
},
|
||||
@ -3494,7 +3501,7 @@ L.Marker.include({
|
||||
anchor = anchor.add(options.offset);
|
||||
}
|
||||
|
||||
options = L.Util.extend({offset: anchor}, options);
|
||||
options = L.extend({offset: anchor}, options);
|
||||
|
||||
if (!this._popup) {
|
||||
this
|
||||
@ -3565,7 +3572,7 @@ L.LayerGroup = L.Class.extend({
|
||||
},
|
||||
|
||||
addLayer: function (layer) {
|
||||
var id = L.Util.stamp(layer);
|
||||
var id = L.stamp(layer);
|
||||
|
||||
this._layers[id] = layer;
|
||||
|
||||
@ -3577,7 +3584,7 @@ L.LayerGroup = L.Class.extend({
|
||||
},
|
||||
|
||||
removeLayer: function (layer) {
|
||||
var id = L.Util.stamp(layer);
|
||||
var id = L.stamp(layer);
|
||||
|
||||
delete this._layers[id];
|
||||
|
||||
@ -3651,7 +3658,7 @@ L.FeatureGroup = L.LayerGroup.extend({
|
||||
},
|
||||
|
||||
addLayer: function (layer) {
|
||||
if (this._layers[L.Util.stamp(layer)]) {
|
||||
if (this._layers[L.stamp(layer)]) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -3750,7 +3757,7 @@ L.Path = L.Class.extend({
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
onAdd: function (map) {
|
||||
@ -3803,7 +3810,7 @@ L.Path = L.Class.extend({
|
||||
},
|
||||
|
||||
setStyle: function (style) {
|
||||
L.Util.setOptions(this, style);
|
||||
L.setOptions(this, style);
|
||||
|
||||
if (this._container) {
|
||||
this._updateStyle();
|
||||
@ -4256,7 +4263,7 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path :
|
||||
},
|
||||
|
||||
setStyle: function (style) {
|
||||
L.Util.setOptions(this, style);
|
||||
L.setOptions(this, style);
|
||||
|
||||
if (this._map) {
|
||||
this._updateStyle();
|
||||
@ -5242,7 +5249,7 @@ L.Circle.include(!L.Path.CANVAS ? {} : {
|
||||
|
||||
L.GeoJSON = L.FeatureGroup.extend({
|
||||
initialize: function (geojson, options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
|
||||
this._layers = {};
|
||||
|
||||
@ -5301,7 +5308,7 @@ L.GeoJSON = L.FeatureGroup.extend({
|
||||
}
|
||||
});
|
||||
|
||||
L.Util.extend(L.GeoJSON, {
|
||||
L.extend(L.GeoJSON, {
|
||||
geometryToLayer: function (geojson, pointToLayer) {
|
||||
var geometry = geojson.type === 'Feature' ? geojson.geometry : geojson,
|
||||
coords = geometry.coordinates,
|
||||
@ -5386,7 +5393,7 @@ L.DomEvent = {
|
||||
/* inpired by John Resig, Dean Edwards and YUI addEvent implementations */
|
||||
addListener: function (obj, type, fn, context) { // (HTMLElement, String, Function[, Object])
|
||||
|
||||
var id = L.Util.stamp(fn),
|
||||
var id = L.stamp(fn),
|
||||
key = '_leaflet_' + type + id,
|
||||
handler, originalHandler, newType;
|
||||
|
||||
@ -5434,7 +5441,7 @@ L.DomEvent = {
|
||||
|
||||
removeListener: function (obj, type, fn) { // (HTMLElement, String, Function)
|
||||
|
||||
var id = L.Util.stamp(fn),
|
||||
var id = L.stamp(fn),
|
||||
key = '_leaflet_' + type + id,
|
||||
handler = obj[key];
|
||||
|
||||
@ -5630,7 +5637,7 @@ L.Draggable = L.Class.extend({
|
||||
|
||||
//Touch contextmenu event emulation
|
||||
if (e.touches && e.touches.length === 1 && L.Browser.touch && this._longPress) {
|
||||
this._longPressTimeout = setTimeout(L.Util.bind(function () {
|
||||
this._longPressTimeout = setTimeout(L.bind(function () {
|
||||
var dist = (this._newPos && this._newPos.distanceTo(this._startPos)) || 0;
|
||||
|
||||
if (dist < L.Draggable.TAP_TOLERANCE) {
|
||||
@ -5978,7 +5985,7 @@ L.Map.ScrollWheelZoom = L.Handler.extend({
|
||||
var left = Math.max(40 - (+new Date() - this._startTime), 0);
|
||||
|
||||
clearTimeout(this._timer);
|
||||
this._timer = setTimeout(L.Util.bind(this._performZoom, this), left);
|
||||
this._timer = setTimeout(L.bind(this._performZoom, this), left);
|
||||
|
||||
L.DomEvent.preventDefault(e);
|
||||
L.DomEvent.stopPropagation(e);
|
||||
@ -6018,7 +6025,7 @@ L.Map.ScrollWheelZoom = L.Handler.extend({
|
||||
L.Map.addInitHook('addHandler', 'scrollWheelZoom', L.Map.ScrollWheelZoom);
|
||||
|
||||
|
||||
L.Util.extend(L.DomEvent, {
|
||||
L.extend(L.DomEvent, {
|
||||
|
||||
_touchstart: L.Browser.msTouch ? 'MSPointerDown' : 'touchstart',
|
||||
_touchend: L.Browser.msTouch ? 'MSPointerUp' : 'touchend',
|
||||
@ -6111,7 +6118,7 @@ L.Util.extend(L.DomEvent, {
|
||||
});
|
||||
|
||||
|
||||
L.Util.extend(L.DomEvent, {
|
||||
L.extend(L.DomEvent, {
|
||||
|
||||
_msTouches: [],
|
||||
_msDocumentListener: false,
|
||||
@ -6683,7 +6690,7 @@ L.Handler.PolyEdit = L.Handler.extend({
|
||||
|
||||
initialize: function (poly, options) {
|
||||
this._poly = poly;
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
addHooks: function () {
|
||||
@ -6765,7 +6772,7 @@ L.Handler.PolyEdit = L.Handler.extend({
|
||||
_onMarkerDrag: function (e) {
|
||||
var marker = e.target;
|
||||
|
||||
L.Util.extend(marker._origLatLng, marker._latlng);
|
||||
L.extend(marker._origLatLng, marker._latlng);
|
||||
|
||||
if (marker._middleLeft) {
|
||||
marker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));
|
||||
@ -6904,7 +6911,7 @@ L.Control = L.Class.extend({
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
getPosition: function () {
|
||||
@ -7061,7 +7068,7 @@ L.Control.Attribution = L.Control.extend({
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
|
||||
this._attributions = {};
|
||||
},
|
||||
@ -7283,7 +7290,7 @@ L.Control.Layers = L.Control.extend({
|
||||
},
|
||||
|
||||
initialize: function (baseLayers, overlays, options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
|
||||
this._layers = {};
|
||||
this._lastZIndex = 0;
|
||||
@ -7321,7 +7328,7 @@ L.Control.Layers = L.Control.extend({
|
||||
},
|
||||
|
||||
removeLayer: function (layer) {
|
||||
var id = L.Util.stamp(layer);
|
||||
var id = L.stamp(layer);
|
||||
delete this._layers[id];
|
||||
this._update();
|
||||
return this;
|
||||
@ -7372,7 +7379,7 @@ L.Control.Layers = L.Control.extend({
|
||||
},
|
||||
|
||||
_addLayer: function (layer, name, overlay) {
|
||||
var id = L.Util.stamp(layer);
|
||||
var id = L.stamp(layer);
|
||||
|
||||
this._layers[id] = {
|
||||
layer: layer,
|
||||
@ -7438,7 +7445,7 @@ L.Control.Layers = L.Control.extend({
|
||||
input = this._createRadioElement('leaflet-base-layers', checked);
|
||||
}
|
||||
|
||||
input.layerId = L.Util.stamp(obj.layer);
|
||||
input.layerId = L.stamp(obj.layer);
|
||||
|
||||
L.DomEvent.on(input, 'click', this._onInputClick, this);
|
||||
|
||||
@ -7515,7 +7522,7 @@ L.PosAnimation = L.Class.extend({
|
||||
L.Util.falseFn(el.offsetWidth);
|
||||
|
||||
// there's no native way to track value updates of tranisitioned properties, so we imitate this
|
||||
this._stepTimer = setInterval(L.Util.bind(this.fire, this, 'step'), 50);
|
||||
this._stepTimer = setInterval(L.bind(this.fire, this, 'step'), 50);
|
||||
},
|
||||
|
||||
stop: function () {
|
||||
@ -7908,7 +7915,7 @@ L.Map.include({
|
||||
|
||||
locate: function (/*Object*/ options) {
|
||||
|
||||
options = this._locationOptions = L.Util.extend(this._defaultLocateOptions, options);
|
||||
options = this._locationOptions = L.extend(this._defaultLocateOptions, options);
|
||||
|
||||
if (!navigator.geolocation) {
|
||||
this._handleGeolocationError({
|
||||
@ -7918,8 +7925,8 @@ L.Map.include({
|
||||
return this;
|
||||
}
|
||||
|
||||
var onResponse = L.Util.bind(this._handleGeolocationResponse, this),
|
||||
onError = L.Util.bind(this._handleGeolocationError, this);
|
||||
var onResponse = L.bind(this._handleGeolocationResponse, this),
|
||||
onError = L.bind(this._handleGeolocationError, this);
|
||||
|
||||
if (options.watch) {
|
||||
this._locationWatchId =
|
||||
|
2
dist/leaflet.js
vendored
2
dist/leaflet.js
vendored
File diff suppressed because one or more lines are too long
@ -5,7 +5,7 @@ L.Control.Attribution = L.Control.extend({
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
|
||||
this._attributions = {};
|
||||
},
|
||||
|
@ -6,7 +6,7 @@ L.Control.Layers = L.Control.extend({
|
||||
},
|
||||
|
||||
initialize: function (baseLayers, overlays, options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
|
||||
this._layers = {};
|
||||
this._lastZIndex = 0;
|
||||
@ -44,7 +44,7 @@ L.Control.Layers = L.Control.extend({
|
||||
},
|
||||
|
||||
removeLayer: function (layer) {
|
||||
var id = L.Util.stamp(layer);
|
||||
var id = L.stamp(layer);
|
||||
delete this._layers[id];
|
||||
this._update();
|
||||
return this;
|
||||
@ -95,7 +95,7 @@ L.Control.Layers = L.Control.extend({
|
||||
},
|
||||
|
||||
_addLayer: function (layer, name, overlay) {
|
||||
var id = L.Util.stamp(layer);
|
||||
var id = L.stamp(layer);
|
||||
|
||||
this._layers[id] = {
|
||||
layer: layer,
|
||||
@ -161,7 +161,7 @@ L.Control.Layers = L.Control.extend({
|
||||
input = this._createRadioElement('leaflet-base-layers', checked);
|
||||
}
|
||||
|
||||
input.layerId = L.Util.stamp(obj.layer);
|
||||
input.layerId = L.stamp(obj.layer);
|
||||
|
||||
L.DomEvent.on(input, 'click', this._onInputClick, this);
|
||||
|
||||
|
@ -5,7 +5,7 @@ L.Control = L.Class.extend({
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
getPosition: function () {
|
||||
|
@ -31,7 +31,7 @@ L.Class.extend = function (/*Object*/ props) /*-> Class*/ {
|
||||
|
||||
// mix static properties into the class
|
||||
if (props.statics) {
|
||||
L.Util.extend(NewClass, props.statics);
|
||||
L.extend(NewClass, props.statics);
|
||||
delete props.statics;
|
||||
}
|
||||
|
||||
@ -43,11 +43,11 @@ L.Class.extend = function (/*Object*/ props) /*-> Class*/ {
|
||||
|
||||
// merge options
|
||||
if (props.options && proto.options) {
|
||||
props.options = L.Util.extend({}, proto.options, props.options);
|
||||
props.options = L.extend({}, proto.options, props.options);
|
||||
}
|
||||
|
||||
// mix given properties into the prototype
|
||||
L.Util.extend(proto, props);
|
||||
L.extend(proto, props);
|
||||
|
||||
return NewClass;
|
||||
};
|
||||
@ -55,9 +55,9 @@ L.Class.extend = function (/*Object*/ props) /*-> Class*/ {
|
||||
|
||||
// method for adding properties to prototype
|
||||
L.Class.include = function (props) {
|
||||
L.Util.extend(this.prototype, props);
|
||||
L.extend(this.prototype, props);
|
||||
};
|
||||
|
||||
L.Class.mergeOptions = function (options) {
|
||||
L.Util.extend(this.prototype.options, options);
|
||||
};
|
||||
L.extend(this.prototype.options, options);
|
||||
};
|
||||
|
@ -80,7 +80,7 @@ L.Mixin.Events = {
|
||||
return this;
|
||||
}
|
||||
|
||||
var event = L.Util.extend({
|
||||
var event = L.extend({
|
||||
type: type,
|
||||
target: this
|
||||
}, data);
|
||||
|
@ -73,7 +73,7 @@ L.Util = {
|
||||
},
|
||||
|
||||
setOptions: function (obj, options) {
|
||||
obj.options = L.Util.extend({}, obj.options, options);
|
||||
obj.options = L.extend({}, obj.options, options);
|
||||
return obj.options;
|
||||
},
|
||||
|
||||
@ -135,7 +135,7 @@ L.Util = {
|
||||
|
||||
|
||||
L.Util.requestAnimFrame = function (fn, context, immediate, element) {
|
||||
fn = L.Util.bind(fn, context);
|
||||
fn = L.bind(fn, context);
|
||||
|
||||
if (immediate && requestFn === timeoutDefer) {
|
||||
fn();
|
||||
@ -151,3 +151,9 @@ L.Util = {
|
||||
};
|
||||
|
||||
}());
|
||||
|
||||
// shortcuts for most used utility functions
|
||||
L.extend = L.Util.extend;
|
||||
L.bind = L.Util.bind;
|
||||
L.stamp = L.Util.stamp;
|
||||
L.setOptions = L.Util.setOptions;
|
||||
|
@ -1,4 +1,4 @@
|
||||
L.Util.extend(L.DomEvent, {
|
||||
L.extend(L.DomEvent, {
|
||||
|
||||
_touchstart: L.Browser.msTouch ? 'MSPointerDown' : 'touchstart',
|
||||
_touchend: L.Browser.msTouch ? 'MSPointerUp' : 'touchend',
|
||||
|
@ -1,4 +1,4 @@
|
||||
L.Util.extend(L.DomEvent, {
|
||||
L.extend(L.DomEvent, {
|
||||
|
||||
_msTouches: [],
|
||||
_msDocumentListener: false,
|
||||
|
@ -6,7 +6,7 @@ L.DomEvent = {
|
||||
/* inpired by John Resig, Dean Edwards and YUI addEvent implementations */
|
||||
addListener: function (obj, type, fn, context) { // (HTMLElement, String, Function[, Object])
|
||||
|
||||
var id = L.Util.stamp(fn),
|
||||
var id = L.stamp(fn),
|
||||
key = '_leaflet_' + type + id,
|
||||
handler, originalHandler, newType;
|
||||
|
||||
@ -54,7 +54,7 @@ L.DomEvent = {
|
||||
|
||||
removeListener: function (obj, type, fn) { // (HTMLElement, String, Function)
|
||||
|
||||
var id = L.Util.stamp(fn),
|
||||
var id = L.stamp(fn),
|
||||
key = '_leaflet_' + type + id,
|
||||
handler = obj[key];
|
||||
|
||||
|
@ -65,7 +65,7 @@ L.Draggable = L.Class.extend({
|
||||
|
||||
//Touch contextmenu event emulation
|
||||
if (e.touches && e.touches.length === 1 && L.Browser.touch && this._longPress) {
|
||||
this._longPressTimeout = setTimeout(L.Util.bind(function () {
|
||||
this._longPressTimeout = setTimeout(L.bind(function () {
|
||||
var dist = (this._newPos && this._newPos.distanceTo(this._startPos)) || 0;
|
||||
|
||||
if (dist < L.Draggable.TAP_TOLERANCE) {
|
||||
|
@ -22,7 +22,7 @@ L.PosAnimation = L.Class.extend({
|
||||
L.Util.falseFn(el.offsetWidth);
|
||||
|
||||
// there's no native way to track value updates of tranisitioned properties, so we imitate this
|
||||
this._stepTimer = setInterval(L.Util.bind(this.fire, this, 'step'), 50);
|
||||
this._stepTimer = setInterval(L.bind(this.fire, this, 'step'), 50);
|
||||
},
|
||||
|
||||
stop: function () {
|
||||
|
@ -19,7 +19,7 @@ L.LatLng = function (rawLat, rawLng, noWrap) { // (Number, Number[, Boolean])
|
||||
this.lng = lng;
|
||||
};
|
||||
|
||||
L.Util.extend(L.LatLng, {
|
||||
L.extend(L.LatLng, {
|
||||
DEG_TO_RAD: Math.PI / 180,
|
||||
RAD_TO_DEG: 180 / Math.PI,
|
||||
MAX_MARGIN: 1.0E-9 // max margin of error for the "equals" check
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
L.CRS.EPSG3395 = L.Util.extend({}, L.CRS, {
|
||||
L.CRS.EPSG3395 = L.extend({}, L.CRS, {
|
||||
code: 'EPSG:3395',
|
||||
|
||||
projection: L.Projection.Mercator,
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
L.CRS.EPSG3857 = L.Util.extend({}, L.CRS, {
|
||||
L.CRS.EPSG3857 = L.extend({}, L.CRS, {
|
||||
code: 'EPSG:3857',
|
||||
|
||||
projection: L.Projection.SphericalMercator,
|
||||
@ -12,6 +12,6 @@ L.CRS.EPSG3857 = L.Util.extend({}, L.CRS, {
|
||||
}
|
||||
});
|
||||
|
||||
L.CRS.EPSG900913 = L.Util.extend({}, L.CRS.EPSG3857, {
|
||||
L.CRS.EPSG900913 = L.extend({}, L.CRS.EPSG3857, {
|
||||
code: 'EPSG:900913'
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
L.CRS.EPSG4326 = L.Util.extend({}, L.CRS, {
|
||||
L.CRS.EPSG4326 = L.extend({}, L.CRS, {
|
||||
code: 'EPSG:4326',
|
||||
|
||||
projection: L.Projection.LonLat,
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
L.CRS.Simple = L.Util.extend({}, L.CRS, {
|
||||
L.CRS.Simple = L.extend({}, L.CRS, {
|
||||
projection: L.Projection.LonLat,
|
||||
transformation: new L.Transformation(1, 0, 1, 0)
|
||||
});
|
||||
|
@ -10,7 +10,7 @@ L.FeatureGroup = L.LayerGroup.extend({
|
||||
},
|
||||
|
||||
addLayer: function (layer) {
|
||||
if (this._layers[L.Util.stamp(layer)]) {
|
||||
if (this._layers[L.stamp(layer)]) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
L.GeoJSON = L.FeatureGroup.extend({
|
||||
initialize: function (geojson, options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
|
||||
this._layers = {};
|
||||
|
||||
@ -59,7 +59,7 @@ L.GeoJSON = L.FeatureGroup.extend({
|
||||
}
|
||||
});
|
||||
|
||||
L.Util.extend(L.GeoJSON, {
|
||||
L.extend(L.GeoJSON, {
|
||||
geometryToLayer: function (geojson, pointToLayer) {
|
||||
var geometry = geojson.type === 'Feature' ? geojson.geometry : geojson,
|
||||
coords = geometry.coordinates,
|
||||
|
@ -9,7 +9,7 @@ L.ImageOverlay = L.Class.extend({
|
||||
this._url = url;
|
||||
this._bounds = L.latLngBounds(bounds);
|
||||
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
onAdd: function (map) {
|
||||
@ -79,11 +79,11 @@ L.ImageOverlay = L.Class.extend({
|
||||
this._updateOpacity();
|
||||
|
||||
//TODO createImage util method to remove duplication
|
||||
L.Util.extend(this._image, {
|
||||
L.extend(this._image, {
|
||||
galleryimg: 'no',
|
||||
onselectstart: L.Util.falseFn,
|
||||
onmousemove: L.Util.falseFn,
|
||||
onload: L.Util.bind(this._onImageLoad, this),
|
||||
onload: L.bind(this._onImageLoad, this),
|
||||
src: this._url
|
||||
});
|
||||
},
|
||||
|
@ -16,7 +16,7 @@ L.LayerGroup = L.Class.extend({
|
||||
},
|
||||
|
||||
addLayer: function (layer) {
|
||||
var id = L.Util.stamp(layer);
|
||||
var id = L.stamp(layer);
|
||||
|
||||
this._layers[id] = layer;
|
||||
|
||||
@ -28,7 +28,7 @@ L.LayerGroup = L.Class.extend({
|
||||
},
|
||||
|
||||
removeLayer: function (layer) {
|
||||
var id = L.Util.stamp(layer);
|
||||
var id = L.stamp(layer);
|
||||
|
||||
delete this._layers[id];
|
||||
|
||||
|
@ -18,7 +18,7 @@ L.Popup = L.Class.extend({
|
||||
},
|
||||
|
||||
initialize: function (options, source) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
|
||||
this._source = source;
|
||||
},
|
||||
|
@ -13,7 +13,7 @@ L.Icon = L.Class.extend({
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
createIcon: function () {
|
||||
|
@ -28,7 +28,7 @@ L.Marker.include({
|
||||
anchor = anchor.add(options.offset);
|
||||
}
|
||||
|
||||
options = L.Util.extend({offset: anchor}, options);
|
||||
options = L.extend({offset: anchor}, options);
|
||||
|
||||
if (!this._popup) {
|
||||
this
|
||||
|
@ -18,7 +18,7 @@ L.Marker = L.Class.extend({
|
||||
},
|
||||
|
||||
initialize: function (latlng, options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
this._latlng = L.latLng(latlng);
|
||||
},
|
||||
|
||||
|
@ -4,7 +4,7 @@ L.TileLayer.Canvas = L.TileLayer.extend({
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
redraw: function () {
|
||||
|
@ -14,7 +14,7 @@ L.TileLayer.WMS = L.TileLayer.extend({
|
||||
|
||||
this._url = url;
|
||||
|
||||
var wmsParams = L.Util.extend({}, this.defaultWmsParams);
|
||||
var wmsParams = L.extend({}, this.defaultWmsParams);
|
||||
|
||||
if (options.detectRetina && L.Browser.retina) {
|
||||
wmsParams.width = wmsParams.height = this.options.tileSize * 2;
|
||||
@ -31,7 +31,7 @@ L.TileLayer.WMS = L.TileLayer.extend({
|
||||
|
||||
this.wmsParams = wmsParams;
|
||||
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
onAdd: function (map) {
|
||||
@ -63,7 +63,7 @@ L.TileLayer.WMS = L.TileLayer.extend({
|
||||
|
||||
setParams: function (params, noRedraw) {
|
||||
|
||||
L.Util.extend(this.wmsParams, params);
|
||||
L.extend(this.wmsParams, params);
|
||||
|
||||
if (!noRedraw) {
|
||||
this.redraw();
|
||||
|
@ -28,7 +28,7 @@ L.TileLayer = L.Class.extend({
|
||||
},
|
||||
|
||||
initialize: function (url, options) {
|
||||
options = L.Util.setOptions(this, options);
|
||||
options = L.setOptions(this, options);
|
||||
|
||||
// detecting retina displays, adjusting tileSize and zoom levels
|
||||
if (options.detectRetina && L.Browser.retina && options.maxZoom > 0) {
|
||||
@ -418,7 +418,7 @@ L.TileLayer = L.Class.extend({
|
||||
getTileUrl: function (tilePoint) {
|
||||
this._adjustTilePoint(tilePoint);
|
||||
|
||||
return L.Util.template(this._url, L.Util.extend({
|
||||
return L.Util.template(this._url, L.extend({
|
||||
s: this._getSubdomain(tilePoint),
|
||||
z: this._getZoomForUrl(),
|
||||
x: tilePoint.x,
|
||||
|
@ -29,7 +29,7 @@ L.Path = L.Class.extend({
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
onAdd: function (map) {
|
||||
@ -82,7 +82,7 @@ L.Path = L.Class.extend({
|
||||
},
|
||||
|
||||
setStyle: function (style) {
|
||||
L.Util.setOptions(this, style);
|
||||
L.setOptions(this, style);
|
||||
|
||||
if (this._container) {
|
||||
this._updateStyle();
|
||||
|
@ -8,7 +8,7 @@ L.Handler.PolyEdit = L.Handler.extend({
|
||||
|
||||
initialize: function (poly, options) {
|
||||
this._poly = poly;
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
addHooks: function () {
|
||||
@ -90,7 +90,7 @@ L.Handler.PolyEdit = L.Handler.extend({
|
||||
_onMarkerDrag: function (e) {
|
||||
var marker = e.target;
|
||||
|
||||
L.Util.extend(marker._origLatLng, marker._latlng);
|
||||
L.extend(marker._origLatLng, marker._latlng);
|
||||
|
||||
if (marker._middleLeft) {
|
||||
marker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));
|
||||
|
@ -22,7 +22,7 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path :
|
||||
},
|
||||
|
||||
setStyle: function (style) {
|
||||
L.Util.setOptions(this, style);
|
||||
L.setOptions(this, style);
|
||||
|
||||
if (this._map) {
|
||||
this._updateStyle();
|
||||
|
@ -21,7 +21,7 @@ L.Map = L.Class.extend({
|
||||
},
|
||||
|
||||
initialize: function (id, options) { // (HTMLElement or String, Object)
|
||||
options = L.Util.setOptions(this, options);
|
||||
options = L.setOptions(this, options);
|
||||
|
||||
this._initContainer(id);
|
||||
this._initLayout();
|
||||
@ -141,7 +141,7 @@ L.Map = L.Class.extend({
|
||||
addLayer: function (layer) {
|
||||
// TODO method is too big, refactor
|
||||
|
||||
var id = L.Util.stamp(layer);
|
||||
var id = L.stamp(layer);
|
||||
|
||||
if (this._layers[id]) { return this; }
|
||||
|
||||
@ -171,7 +171,7 @@ L.Map = L.Class.extend({
|
||||
},
|
||||
|
||||
removeLayer: function (layer) {
|
||||
var id = L.Util.stamp(layer);
|
||||
var id = L.stamp(layer);
|
||||
|
||||
if (!this._layers[id]) { return; }
|
||||
|
||||
@ -190,7 +190,7 @@ L.Map = L.Class.extend({
|
||||
},
|
||||
|
||||
hasLayer: function (layer) {
|
||||
var id = L.Util.stamp(layer);
|
||||
var id = L.stamp(layer);
|
||||
return this._layers.hasOwnProperty(id);
|
||||
},
|
||||
|
||||
@ -215,7 +215,7 @@ L.Map = L.Class.extend({
|
||||
this.fire('move');
|
||||
|
||||
clearTimeout(this._sizeTimer);
|
||||
this._sizeTimer = setTimeout(L.Util.bind(this.fire, this, 'moveend'), 200);
|
||||
this._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
@ -600,7 +600,7 @@ L.Map = L.Class.extend({
|
||||
this._tileLayersToLoad--;
|
||||
if (this._tileLayersNum && !this._tileLayersToLoad && this._tileBg) {
|
||||
clearTimeout(this._clearTileBgTimer);
|
||||
this._clearTileBgTimer = setTimeout(L.Util.bind(this._clearTileBg, this), 500);
|
||||
this._clearTileBgTimer = setTimeout(L.bind(this._clearTileBg, this), 500);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -14,7 +14,7 @@ L.Map.include({
|
||||
|
||||
locate: function (/*Object*/ options) {
|
||||
|
||||
options = this._locationOptions = L.Util.extend(this._defaultLocateOptions, options);
|
||||
options = this._locationOptions = L.extend(this._defaultLocateOptions, options);
|
||||
|
||||
if (!navigator.geolocation) {
|
||||
this._handleGeolocationError({
|
||||
@ -24,8 +24,8 @@ L.Map.include({
|
||||
return this;
|
||||
}
|
||||
|
||||
var onResponse = L.Util.bind(this._handleGeolocationResponse, this),
|
||||
onError = L.Util.bind(this._handleGeolocationError, this);
|
||||
var onResponse = L.bind(this._handleGeolocationResponse, this),
|
||||
onError = L.bind(this._handleGeolocationError, this);
|
||||
|
||||
if (options.watch) {
|
||||
this._locationWatchId =
|
||||
|
@ -29,7 +29,7 @@ L.Map.ScrollWheelZoom = L.Handler.extend({
|
||||
var left = Math.max(40 - (+new Date() - this._startTime), 0);
|
||||
|
||||
clearTimeout(this._timer);
|
||||
this._timer = setTimeout(L.Util.bind(this._performZoom, this), left);
|
||||
this._timer = setTimeout(L.bind(this._performZoom, this), left);
|
||||
|
||||
L.DomEvent.preventDefault(e);
|
||||
L.DomEvent.stopPropagation(e);
|
||||
|
Loading…
Reference in New Issue
Block a user