Add prettier and reformat code

This commit is contained in:
Gautier Pelloux-Prayer 2019-05-16 21:31:06 +02:00
parent 68eb00bae9
commit 970a34981f
37 changed files with 3459 additions and 1969 deletions

View file

@ -1,8 +1,6 @@
BR.Map = {
initMap: function() {
var map,
layersControl;
var map, layersControl;
BR.keys = BR.keys || {};
@ -14,23 +12,35 @@ BR.Map = {
minZoom: 0,
maxZoom: maxZoom
});
L.control.zoom({
zoomInTitle: i18next.t('map.zoomInTitle'),
zoomOutTitle: i18next.t('map.zoomOutTitle'),
}).addTo(map);
L.control
.zoom({
zoomInTitle: i18next.t('map.zoomInTitle'),
zoomOutTitle: i18next.t('map.zoomOutTitle')
})
.addTo(map);
if (!map.restoreView()) {
map.setView([50.99, 9.86], 6);
}
// two attribution lines by adding two controls, prevents ugly wrapping on
// small screens, better separates static from layer-specific attribution
var osmAttribution = $(map.getContainer()).outerWidth() >= 400 ? i18next.t('map.attribution-osm-long') : i18next.t('map.attribution-osm-short');
var osmAttribution =
$(map.getContainer()).outerWidth() >= 400
? i18next.t('map.attribution-osm-long')
: i18next.t('map.attribution-osm-short');
map.attributionControl.setPrefix(
'&copy; <a target="_blank" href="https://www.openstreetmap.org/copyright">' + osmAttribution + '</a>' +
' &middot; <a href="" data-toggle="modal" data-target="#credits">' + i18next.t('map.copyright') + '</a>' +
' &middot; <a target="_blank" href="http://brouter.de/privacypolicy.html">' + i18next.t('map.privacy') + '</a>');
'&copy; <a target="_blank" href="https://www.openstreetmap.org/copyright">' +
osmAttribution +
'</a>' +
' &middot; <a href="" data-toggle="modal" data-target="#credits">' +
i18next.t('map.copyright') +
'</a>' +
' &middot; <a target="_blank" href="http://brouter.de/privacypolicy.html">' +
i18next.t('map.privacy') +
'</a>'
);
$('#credits').on('show.bs.modal', function (event) {
$('#credits').on('show.bs.modal', function(event) {
BR.Map._renderLayerCredits(layersControl._layers);
});
@ -42,15 +52,22 @@ BR.Map = {
var overlays = layersConfig.getOverlays();
if (BR.keys.bing) {
baseLayers[i18next.t('map.layer.bing')] = new BR.BingLayer(BR.keys.bing);
baseLayers[i18next.t('map.layer.bing')] = new BR.BingLayer(
BR.keys.bing
);
}
if (BR.keys.digitalGlobe) {
var recent = new L.tileLayer('https://{s}.tiles.mapbox.com/v4/digitalglobe.nal0g75k/{z}/{x}/{y}.png?access_token=' + BR.keys.digitalGlobe, {
minZoom: 1,
maxZoom: 19,
attribution: '&copy; <a href=\"https://www.digitalglobe.com/platforms/mapsapi\">DigitalGlobe</a> (<a href=\"https://bit.ly/mapsapiview\">Terms of Use</a>)'
});
var recent = new L.tileLayer(
'https://{s}.tiles.mapbox.com/v4/digitalglobe.nal0g75k/{z}/{x}/{y}.png?access_token=' +
BR.keys.digitalGlobe,
{
minZoom: 1,
maxZoom: 19,
attribution:
'&copy; <a href="https://www.digitalglobe.com/platforms/mapsapi">DigitalGlobe</a> (<a href="https://bit.ly/mapsapiview">Terms of Use</a>)'
}
);
baseLayers[i18next.t('map.layer.digitalglobe')] = recent;
}
@ -69,17 +86,24 @@ BR.Map = {
}
}
layersControl = BR.layersTab(layersConfig, baseLayers, overlays).addTo(map);
layersControl = BR.layersTab(layersConfig, baseLayers, overlays).addTo(
map
);
var secureContext = 'isSecureContext' in window ? isSecureContext : location.protocol === 'https:';
var secureContext =
'isSecureContext' in window
? isSecureContext
: location.protocol === 'https:';
if (secureContext) {
L.control.locate({
strings: {
title: i18next.t('map.locate-me')
},
icon: 'fa fa-location-arrow',
iconLoading: 'fa fa-spinner fa-pulse',
}).addTo(map);
L.control
.locate({
strings: {
title: i18next.t('map.locate-me')
},
icon: 'fa fa-location-arrow',
iconLoading: 'fa fa-spinner fa-pulse'
})
.addTo(map);
}
L.control.scale().addTo(map);
@ -96,7 +120,7 @@ BR.Map = {
};
},
_renderLayerCredits: function (layers) {
_renderLayerCredits: function(layers) {
var dl = document.getElementById('credits-maps');
var i, obj, dt, dd, attribution;