Merge branch 'master' into 68-sl-formatting
This commit is contained in:
commit
1330317f1d
112 changed files with 3368 additions and 741 deletions
|
|
@ -148,6 +148,10 @@ BR.Export = L.Class.extend({
|
|||
}
|
||||
},
|
||||
|
||||
_selectTrackname: function () {
|
||||
trackname.setSelectionRange(0, trackname.value.lastIndexOf(BR.Browser.download ? ' (' : ' - '));
|
||||
},
|
||||
|
||||
_generateTrackname: function () {
|
||||
var trackname = this.trackname;
|
||||
this._getCityAtPosition(
|
||||
|
|
@ -180,6 +184,8 @@ BR.Export = L.Class.extend({
|
|||
trackname.value = trackname.value.replace(/[>)]/g, '').replace(/ \(/g, ' - ');
|
||||
this._validationMessage();
|
||||
}
|
||||
|
||||
this._selectTrackname();
|
||||
}, this)
|
||||
);
|
||||
}, this)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ BR.Layers = L.Class.extend({
|
|||
if (BR.Util.localStorageAvailable()) {
|
||||
var layers = JSON.parse(localStorage.getItem('map/customLayers'));
|
||||
for (a in layers) {
|
||||
this._addLayer(a, layers[a].layer, layers[a].isOverlay);
|
||||
this._addLayer(a, layers[a].layer, layers[a].isOverlay, layers[a].dataSource);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -13,14 +13,22 @@ BR.Layers = L.Class.extend({
|
|||
_loadTable: function () {
|
||||
var layersData = [];
|
||||
for (layer in this._customLayers) {
|
||||
var isOverlay = this._customLayers[layer].isOverlay;
|
||||
layersData.push([
|
||||
layer,
|
||||
this._customLayers[layer].layer._url,
|
||||
isOverlay
|
||||
? i18next.t('sidebar.layers.table.type_overlay')
|
||||
: i18next.t('sidebar.layers.table.type_layer'),
|
||||
]);
|
||||
if (this._customLayers[layer].dataSource === 'OverpassAPI') {
|
||||
layersData.push([
|
||||
layer,
|
||||
this._customLayers[layer].layer.options.query,
|
||||
i18next.t('sidebar.layers.table.type_overpass_query'),
|
||||
]);
|
||||
} else {
|
||||
var isOverlay = this._customLayers[layer].isOverlay;
|
||||
layersData.push([
|
||||
layer,
|
||||
this._customLayers[layer].layer._url,
|
||||
isOverlay
|
||||
? i18next.t('sidebar.layers.table.type_overlay')
|
||||
: i18next.t('sidebar.layers.table.type_layer'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
if (this._layersTable != null) {
|
||||
this._layersTable.destroy();
|
||||
|
|
@ -51,6 +59,7 @@ BR.Layers = L.Class.extend({
|
|||
|
||||
L.DomUtil.get('custom_layers_add_base').onclick = L.bind(this._addBaseLayer, this);
|
||||
L.DomUtil.get('custom_layers_add_overlay').onclick = L.bind(this._addOverlay, this);
|
||||
L.DomUtil.get('custom_layers_add_overpass').onclick = L.bind(this._addOverpassQuery, this);
|
||||
L.DomUtil.get('custom_layers_remove').onclick = L.bind(this._remove, this);
|
||||
|
||||
this._loadLayers();
|
||||
|
|
@ -83,10 +92,10 @@ BR.Layers = L.Class.extend({
|
|||
}
|
||||
},
|
||||
|
||||
_addFromInput: function (isOverlay) {
|
||||
_addFromInput: function (isOverlay, dataSource) {
|
||||
var layer_name = L.DomUtil.get('layer_name').value;
|
||||
var layer_url = L.DomUtil.get('layer_url').value;
|
||||
if (layer_name.length > 0 && layer_url.length > 0) this._addLayer(layer_name, layer_url, isOverlay);
|
||||
if (layer_name.length > 0 && layer_url.length > 0) this._addLayer(layer_name, layer_url, isOverlay, dataSource);
|
||||
},
|
||||
|
||||
_addBaseLayer: function (evt) {
|
||||
|
|
@ -95,18 +104,28 @@ BR.Layers = L.Class.extend({
|
|||
_addOverlay: function (evt) {
|
||||
this._addFromInput(true);
|
||||
},
|
||||
_addOverpassQuery: function (evt) {
|
||||
this._addFromInput(true, 'OverpassAPI');
|
||||
},
|
||||
|
||||
_addLayer: function (layerName, layerUrl, isOverlay) {
|
||||
_addLayer: function (layerName, layerUrl, isOverlay, dataSource) {
|
||||
if (layerName in this._layers) return;
|
||||
|
||||
if (layerName in this._customLayers) return;
|
||||
|
||||
try {
|
||||
var layer = L.tileLayer(layerUrl);
|
||||
var layer;
|
||||
|
||||
if (dataSource === 'OverpassAPI') {
|
||||
layer = this._layersControl.layersConfig.createOverpassLayer(layerUrl);
|
||||
} else {
|
||||
layer = L.tileLayer(layerUrl);
|
||||
}
|
||||
|
||||
this._customLayers[layerName] = {
|
||||
layer: layer,
|
||||
isOverlay: isOverlay,
|
||||
dataSource: dataSource,
|
||||
};
|
||||
|
||||
if (isOverlay) {
|
||||
|
|
@ -128,6 +147,18 @@ BR.Layers = L.Class.extend({
|
|||
localStorage.setItem(
|
||||
'map/customLayers',
|
||||
JSON.stringify(this._customLayers, function (k, v) {
|
||||
if (v === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (v.dataSource === 'OverpassAPI') {
|
||||
return {
|
||||
dataSource: 'OverpassAPI',
|
||||
isOverlay: true,
|
||||
layer: v.layer.options.query,
|
||||
};
|
||||
}
|
||||
|
||||
// dont write Leaflet.Layer in localStorage; simply keep the URL
|
||||
return v._url || v;
|
||||
})
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ BR.LayersTab = BR.ControlLayers.extend({
|
|||
core: {
|
||||
multiple: false,
|
||||
themes: {
|
||||
icons: false,
|
||||
icons: true,
|
||||
dots: false,
|
||||
},
|
||||
data: treeData,
|
||||
|
|
@ -188,6 +188,7 @@ BR.LayersTab = BR.ControlLayers.extend({
|
|||
function createRootNode(name) {
|
||||
var rootNode = {
|
||||
text: i18next.t('sidebar.layers.category.' + name, name),
|
||||
icon: false,
|
||||
state: {
|
||||
disabled: true,
|
||||
},
|
||||
|
|
@ -218,6 +219,7 @@ BR.LayersTab = BR.ControlLayers.extend({
|
|||
childNode = {
|
||||
id: id,
|
||||
text: getText(props, parent),
|
||||
icon: self.layersConfig.getOverpassIconUrl(props.icon) || false,
|
||||
state: {
|
||||
checked: self.layersConfig.isDefaultLayer(id, props.overlay),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ BR.Message = L.Class.extend({
|
|||
// true to manually attach click event to close button,
|
||||
// Bootstrap data-api's auto-initialization doesn't work in Controls because of stopPropagation
|
||||
alert: false,
|
||||
onClosed: null,
|
||||
},
|
||||
|
||||
initialize: function (id, options) {
|
||||
|
|
@ -18,12 +19,20 @@ BR.Message = L.Class.extend({
|
|||
case 'error':
|
||||
iconClass = 'fa-times-circle';
|
||||
alertClass = 'alert-danger';
|
||||
break;
|
||||
case 'warning':
|
||||
iconClass = 'fa-exclamation-triangle';
|
||||
alertClass = 'alert-warning';
|
||||
break;
|
||||
case 'loading':
|
||||
iconClass = 'fa-spinner fa-pulse';
|
||||
alertClass = 'alert-secondary';
|
||||
break;
|
||||
default:
|
||||
case 'info':
|
||||
iconClass = 'fa-info-circle';
|
||||
alertClass = 'alert-info';
|
||||
break;
|
||||
}
|
||||
|
||||
L.DomEvent.disableClickPropagation(ele);
|
||||
|
|
@ -41,6 +50,10 @@ BR.Message = L.Class.extend({
|
|||
msg +
|
||||
'</div>';
|
||||
|
||||
if (this.options.onClosed) {
|
||||
$('#' + this.id + ' .alert').on('closed.bs.alert', this.options.onClosed);
|
||||
}
|
||||
|
||||
if (this.options.alert) {
|
||||
$('#' + this.id + ' .alert').alert();
|
||||
}
|
||||
|
|
@ -74,6 +87,10 @@ BR.Message = L.Class.extend({
|
|||
showInfo: function (msg) {
|
||||
this._show(msg, 'info');
|
||||
},
|
||||
|
||||
showLoading: function (msg) {
|
||||
this._show(msg, 'loading');
|
||||
},
|
||||
});
|
||||
|
||||
// static instance as global control
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue