Increase prettier maxwidth to 120
This commit is contained in:
parent
ce9e34283b
commit
d31be926d2
27 changed files with 248 additions and 956 deletions
|
|
@ -15,33 +15,19 @@ BR.Elevation = L.Control.Elevation.extend({
|
|||
|
||||
// revert registering touch events when touch screen detection is available and negative
|
||||
// see https://github.com/MrMufflon/Leaflet.Elevation/issues/67
|
||||
if (
|
||||
L.Browser.touch &&
|
||||
BR.Browser.touchScreenDetectable &&
|
||||
!BR.Browser.touchScreen
|
||||
) {
|
||||
if (L.Browser.touch && BR.Browser.touchScreenDetectable && !BR.Browser.touchScreen) {
|
||||
this._background
|
||||
.on('touchmove.drag', null)
|
||||
.on('touchstart.drag', null)
|
||||
.on('touchstart.focus', null);
|
||||
L.DomEvent.off(
|
||||
this._container,
|
||||
'touchend',
|
||||
this._dragEndHandler,
|
||||
this
|
||||
);
|
||||
L.DomEvent.off(this._container, 'touchend', this._dragEndHandler, this);
|
||||
|
||||
this._background
|
||||
.on('mousemove.focus', this._mousemoveHandler.bind(this))
|
||||
.on('mouseout.focus', this._mouseoutHandler.bind(this))
|
||||
.on('mousedown.drag', this._dragStartHandler.bind(this))
|
||||
.on('mousemove.drag', this._dragHandler.bind(this));
|
||||
L.DomEvent.on(
|
||||
this._container,
|
||||
'mouseup',
|
||||
this._dragEndHandler,
|
||||
this
|
||||
);
|
||||
L.DomEvent.on(this._container, 'mouseup', this._dragEndHandler, this);
|
||||
}
|
||||
|
||||
return container;
|
||||
|
|
@ -61,10 +47,7 @@ BR.Elevation = L.Control.Elevation.extend({
|
|||
}
|
||||
this.addTo(map);
|
||||
// move elevation graph outside of the map
|
||||
setParent(
|
||||
this.getContainer(),
|
||||
document.getElementById('elevation-chart')
|
||||
);
|
||||
setParent(this.getContainer(), document.getElementById('elevation-chart'));
|
||||
},
|
||||
|
||||
update: function(track, layer) {
|
||||
|
|
|
|||
|
|
@ -143,9 +143,7 @@ BR.NogoAreas = L.Control.extend({
|
|||
resolve(reader.result);
|
||||
};
|
||||
reader.onerror = function() {
|
||||
self.displayUploadError(
|
||||
'Could not load file: ' + reader.error.message
|
||||
);
|
||||
self.displayUploadError('Could not load file: ' + reader.error.message);
|
||||
};
|
||||
|
||||
reader.readAsText(nogoFile);
|
||||
|
|
@ -184,32 +182,22 @@ BR.NogoAreas = L.Control.extend({
|
|||
var maybeBufferedFeature = feature;
|
||||
// Eventually buffer GeoJSON
|
||||
if (nogoBuffer !== 0) {
|
||||
maybeBufferedFeature = turf.buffer(
|
||||
maybeBufferedFeature,
|
||||
nogoBuffer,
|
||||
{ units: 'meters' }
|
||||
);
|
||||
maybeBufferedFeature = turf.buffer(maybeBufferedFeature, nogoBuffer, { units: 'meters' });
|
||||
}
|
||||
cleanedGeoJSONFeatures.push(maybeBufferedFeature);
|
||||
}
|
||||
});
|
||||
|
||||
if (cleanedGeoJSONFeatures.length === 0) {
|
||||
self.displayUploadError(
|
||||
'No valid area found in provided input.'
|
||||
);
|
||||
self.displayUploadError('No valid area found in provided input.');
|
||||
return false;
|
||||
}
|
||||
|
||||
var geoJSON = L.geoJson(
|
||||
turf.featureCollection(cleanedGeoJSONFeatures),
|
||||
{
|
||||
onEachFeature: function(feature, layer) {
|
||||
layer.options.nogoWeight =
|
||||
feature.properties.nogoWeight || nogoWeight;
|
||||
}
|
||||
var geoJSON = L.geoJson(turf.featureCollection(cleanedGeoJSONFeatures), {
|
||||
onEachFeature: function(feature, layer) {
|
||||
layer.options.nogoWeight = feature.properties.nogoWeight || nogoWeight;
|
||||
}
|
||||
);
|
||||
});
|
||||
var nogosPoints = geoJSON.getLayers().filter(function(e) {
|
||||
return e.feature.geometry.type === 'Point';
|
||||
});
|
||||
|
|
@ -332,9 +320,7 @@ BR.NogoAreas = L.Control.extend({
|
|||
BR.NogoAreas.include(L.Evented.prototype);
|
||||
|
||||
L.Editable.prototype.createVertexIcon = function(options) {
|
||||
return BR.Browser.touch
|
||||
? new L.Editable.TouchVertexIcon(options)
|
||||
: new L.Editable.VertexIcon(options);
|
||||
return BR.Browser.touch ? new L.Editable.TouchVertexIcon(options) : new L.Editable.VertexIcon(options);
|
||||
};
|
||||
|
||||
BR.EditingTooltip = L.Handler.extend({
|
||||
|
|
@ -351,12 +337,7 @@ BR.EditingTooltip = L.Handler.extend({
|
|||
addHooks: function() {
|
||||
// hack: listen to EasyButton click (instead of editable:drawing:start),
|
||||
// to get mouse position from event for initial tooltip location
|
||||
L.DomEvent.addListener(
|
||||
this.button.button,
|
||||
'click',
|
||||
this._addCreate,
|
||||
this
|
||||
);
|
||||
L.DomEvent.addListener(this.button.button, 'click', this._addCreate, this);
|
||||
|
||||
this.editTools.featuresLayer.on('layeradd', this._bind, this);
|
||||
|
||||
|
|
@ -366,12 +347,7 @@ BR.EditingTooltip = L.Handler.extend({
|
|||
},
|
||||
|
||||
removeHooks: function() {
|
||||
L.DomEvent.removeListener(
|
||||
this.button.button,
|
||||
'click',
|
||||
this._addCreate,
|
||||
this
|
||||
);
|
||||
L.DomEvent.removeListener(this.button.button, 'click', this._addCreate, this);
|
||||
|
||||
this.editTools.featuresLayer.off('layeradd', this._bind, this);
|
||||
|
||||
|
|
@ -396,9 +372,7 @@ BR.EditingTooltip = L.Handler.extend({
|
|||
if (!latlng && layer instanceof L.Layer) {
|
||||
latlng = L.latLng(
|
||||
layer.getBounds().getSouth(),
|
||||
0.5 *
|
||||
(layer.getBounds().getWest() +
|
||||
layer.getBounds().getEast())
|
||||
0.5 * (layer.getBounds().getWest() + layer.getBounds().getEast())
|
||||
);
|
||||
}
|
||||
L.Layer.prototype.openTooltip.call(this, layer, latlng);
|
||||
|
|
@ -444,11 +418,7 @@ BR.EditingTooltip = L.Handler.extend({
|
|||
var closeTooltip = function() {
|
||||
this.map.closeTooltip(tooltip);
|
||||
};
|
||||
this.editTools.once(
|
||||
'editable:editing editable:drawing:cancel',
|
||||
closeTooltip,
|
||||
this
|
||||
);
|
||||
this.editTools.once('editable:editing editable:drawing:cancel', closeTooltip, this);
|
||||
|
||||
if (BR.Browser.touch) {
|
||||
// can't move with cursor on touch devices, so show at start pos for a few seconds
|
||||
|
|
@ -501,9 +471,7 @@ BR.EditingTooltip = L.Handler.extend({
|
|||
BR.DeletableCircleEditor = L.Editable.CircleEditor.extend({
|
||||
_computeDeleteLatLng: function() {
|
||||
// While circle is not added to the map, _radius is not set.
|
||||
var delta =
|
||||
(this.feature._radius || this.feature._mRadius) *
|
||||
Math.cos(Math.PI / 4),
|
||||
var delta = (this.feature._radius || this.feature._mRadius) * Math.cos(Math.PI / 4),
|
||||
point = this.map.project(this.feature._latlng);
|
||||
return this.map.unproject([point.x - delta, point.y - delta]);
|
||||
},
|
||||
|
|
@ -530,12 +498,7 @@ BR.DeletableCircleEditor = L.Editable.CircleEditor.extend({
|
|||
},
|
||||
|
||||
initialize: function(map, feature, options) {
|
||||
L.Editable.CircleEditor.prototype.initialize.call(
|
||||
this,
|
||||
map,
|
||||
feature,
|
||||
options
|
||||
);
|
||||
L.Editable.CircleEditor.prototype.initialize.call(this, map, feature, options);
|
||||
this._deleteLatLng = this._computeDeleteLatLng();
|
||||
|
||||
// FeatureGroup instead of LayerGroup to propagate events to members
|
||||
|
|
@ -584,9 +547,7 @@ BR.DeleteMarker = L.Marker.extend({
|
|||
options: {
|
||||
draggable: false,
|
||||
icon: L.divIcon({
|
||||
iconSize: BR.Browser.touch
|
||||
? new L.Point(24, 24)
|
||||
: new L.Point(16, 16),
|
||||
iconSize: BR.Browser.touch ? new L.Point(24, 24) : new L.Point(16, 16),
|
||||
className: 'leaflet-div-icon fa fa-trash-o nogo-delete-marker'
|
||||
})
|
||||
},
|
||||
|
|
|
|||
|
|
@ -94,11 +94,7 @@ BR.Routing = L.Routing.extend({
|
|||
|
||||
// intercept listener: only re-show draw trailer after marker hover
|
||||
// when edit is not active (i.e. wasn't also supended)
|
||||
this._parent.off(
|
||||
'waypoint:mouseout',
|
||||
this._catchWaypointEvent,
|
||||
this
|
||||
);
|
||||
this._parent.off('waypoint:mouseout', this._catchWaypointEvent, this);
|
||||
this.on(
|
||||
'waypoint:mouseout',
|
||||
function(e) {
|
||||
|
|
@ -134,12 +130,7 @@ BR.Routing = L.Routing.extend({
|
|||
this._map.off('mouseout', hide, this);
|
||||
this._map.off('mouseover', show, this);
|
||||
L.DomEvent.off(this._map._controlContainer, 'mouseout', show, this);
|
||||
L.DomEvent.off(
|
||||
this._map._controlContainer,
|
||||
'mouseover',
|
||||
hide,
|
||||
this
|
||||
);
|
||||
L.DomEvent.off(this._map._controlContainer, 'mouseover', hide, this);
|
||||
});
|
||||
|
||||
// Call show after deleting last waypoint, but hide trailer.
|
||||
|
|
@ -159,11 +150,7 @@ BR.Routing = L.Routing.extend({
|
|||
);
|
||||
|
||||
// keys not working when map container does not have focus, use document instead
|
||||
L.DomEvent.removeListener(
|
||||
this._container,
|
||||
'keyup',
|
||||
this._keyupListener
|
||||
);
|
||||
L.DomEvent.removeListener(this._container, 'keyup', this._keyupListener);
|
||||
L.DomEvent.addListener(document, 'keyup', this._keyupListener, this);
|
||||
|
||||
// enable drawing mode
|
||||
|
|
@ -173,10 +160,7 @@ BR.Routing = L.Routing.extend({
|
|||
},
|
||||
|
||||
_addSegmentCasing: function(e) {
|
||||
var casing = L.polyline(
|
||||
e.layer.getLatLngs(),
|
||||
this.options.styles.trackCasing
|
||||
);
|
||||
var casing = L.polyline(e.layer.getLatLngs(), this.options.styles.trackCasing);
|
||||
this._segmentsCasing.addLayer(casing);
|
||||
e.layer._casing = casing;
|
||||
this._segments.bringToFront();
|
||||
|
|
@ -335,10 +319,7 @@ BR.Routing = L.Routing.extend({
|
|||
|
||||
_keyupListener: function(e) {
|
||||
// Suppress shortcut handling when a text input field is focussed
|
||||
if (
|
||||
document.activeElement.type == 'text' ||
|
||||
document.activeElement.type == 'textarea'
|
||||
) {
|
||||
if (document.activeElement.type == 'text' || document.activeElement.type == 'textarea') {
|
||||
return;
|
||||
}
|
||||
// add 'esc' to disable drawing
|
||||
|
|
|
|||
|
|
@ -36,11 +36,7 @@ BR.Sidebar = L.Control.Sidebar.extend({
|
|||
|
||||
this._rememberTabState();
|
||||
|
||||
if (
|
||||
L.Browser.touch &&
|
||||
BR.Browser.touchScreenDetectable &&
|
||||
!BR.Browser.touchScreen
|
||||
) {
|
||||
if (L.Browser.touch && BR.Browser.touchScreenDetectable && !BR.Browser.touchScreen) {
|
||||
L.DomUtil.removeClass(this._container, 'leaflet-touch');
|
||||
L.DomUtil.removeClass(this._tabContainer, 'leaflet-touch');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
(function(window) {
|
||||
var HAS_HASHCHANGE = (function() {
|
||||
var doc_mode = window.documentMode;
|
||||
return (
|
||||
'onhashchange' in window && (doc_mode === undefined || doc_mode > 7)
|
||||
);
|
||||
return 'onhashchange' in window && (doc_mode === undefined || doc_mode > 7);
|
||||
})();
|
||||
|
||||
L.Hash = function(map, options) {
|
||||
|
|
@ -47,12 +45,7 @@
|
|||
precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)),
|
||||
layers = this.formatLayers();
|
||||
|
||||
var params = [
|
||||
zoom,
|
||||
center.lat.toFixed(precision),
|
||||
center.lng.toFixed(precision),
|
||||
layers
|
||||
];
|
||||
var params = [zoom, center.lat.toFixed(precision), center.lng.toFixed(precision), layers];
|
||||
url = '#map=' + params.join('/');
|
||||
if (this.additionalCb != null) {
|
||||
var additional = this.additionalCb();
|
||||
|
|
@ -92,9 +85,7 @@
|
|||
var layerString = decodeURIComponent(layerEncoded);
|
||||
|
||||
if (layerString) {
|
||||
obj = this.options.layersControl.getLayerFromString(
|
||||
layerString
|
||||
);
|
||||
obj = this.options.layersControl.getLayerFromString(layerString);
|
||||
}
|
||||
|
||||
return obj;
|
||||
|
|
@ -112,10 +103,7 @@
|
|||
return count;
|
||||
};
|
||||
|
||||
var layers = this._parseLayers(
|
||||
layersParam,
|
||||
this.options.layerSeparator
|
||||
);
|
||||
var layers = this._parseLayers(layersParam, this.options.layerSeparator);
|
||||
var found = layers.reduce(countFoundLayers, 0);
|
||||
|
||||
if (found < layers.length) {
|
||||
|
|
@ -158,9 +146,7 @@
|
|||
var objList = this.options.layersControl.getActiveLayers();
|
||||
var layerList = objList.map(
|
||||
L.bind(function(obj) {
|
||||
return encodeURIComponent(
|
||||
this.options.layersControl.toLayerString(obj)
|
||||
);
|
||||
return encodeURIComponent(this.options.layersControl.toLayerString(obj));
|
||||
}, this)
|
||||
);
|
||||
|
||||
|
|
@ -246,41 +232,22 @@
|
|||
isListening: false,
|
||||
hashChangeInterval: null,
|
||||
startListening: function() {
|
||||
this.map.on(
|
||||
'moveend layeradd layerremove',
|
||||
this.onMapMove,
|
||||
this
|
||||
);
|
||||
this.map.on('moveend layeradd layerremove', this.onMapMove, this);
|
||||
|
||||
if (HAS_HASHCHANGE) {
|
||||
L.DomEvent.addListener(
|
||||
window,
|
||||
'hashchange',
|
||||
this.onHashChange
|
||||
);
|
||||
L.DomEvent.addListener(window, 'hashchange', this.onHashChange);
|
||||
} else {
|
||||
clearInterval(this.hashChangeInterval);
|
||||
this.hashChangeInterval = setInterval(
|
||||
this.onHashChange,
|
||||
50
|
||||
);
|
||||
this.hashChangeInterval = setInterval(this.onHashChange, 50);
|
||||
}
|
||||
this.isListening = true;
|
||||
},
|
||||
|
||||
stopListening: function() {
|
||||
this.map.off(
|
||||
'moveend layeradd layerremove',
|
||||
this.onMapMove,
|
||||
this
|
||||
);
|
||||
this.map.off('moveend layeradd layerremove', this.onMapMove, this);
|
||||
|
||||
if (HAS_HASHCHANGE) {
|
||||
L.DomEvent.removeListener(
|
||||
window,
|
||||
'hashchange',
|
||||
this.onHashChange
|
||||
);
|
||||
L.DomEvent.removeListener(window, 'hashchange', this.onHashChange);
|
||||
} else {
|
||||
clearInterval(this.hashChangeInterval);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,10 +7,7 @@ BR.stravaSegments = function(map, layersControl) {
|
|||
stravaToken: BR.keys.strava
|
||||
})
|
||||
.addTo(map);
|
||||
layersControl.addOverlay(
|
||||
stravaControl.stravaLayer,
|
||||
i18next.t('map.layer.strava-segments')
|
||||
);
|
||||
layersControl.addOverlay(stravaControl.stravaLayer, i18next.t('map.layer.strava-segments'));
|
||||
stravaControl.onError = function(err) {
|
||||
BR.message.showError(
|
||||
i18next.t('warning.strava-error', {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue