Disable query feature tool below z14
This commit is contained in:
parent
8a70e1c082
commit
606ac76108
4 changed files with 40 additions and 2 deletions
|
@ -9,6 +9,8 @@ OSM.Query = function(map) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
|
if (queryButton.hasClass("disabled")) return;
|
||||||
|
|
||||||
if (queryButton.hasClass("active")) {
|
if (queryButton.hasClass("active")) {
|
||||||
disableQueryMode();
|
disableQueryMode();
|
||||||
|
|
||||||
|
@ -16,6 +18,18 @@ OSM.Query = function(map) {
|
||||||
} else {
|
} else {
|
||||||
enableQueryMode();
|
enableQueryMode();
|
||||||
}
|
}
|
||||||
|
}).on("disabled", function (e) {
|
||||||
|
if (queryButton.hasClass("active")) {
|
||||||
|
map.off("click", clickHandler);
|
||||||
|
$(map.getContainer()).removeClass("query-active").addClass("query-disabled");
|
||||||
|
$(this).tooltip("show");
|
||||||
|
}
|
||||||
|
}).on("enabled", function (e) {
|
||||||
|
if (queryButton.hasClass("active")) {
|
||||||
|
map.on("click", clickHandler);
|
||||||
|
$(map.getContainer()).removeClass("query-disabled").addClass("query-active");
|
||||||
|
$(this).tooltip("hide");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#sidebar_content")
|
$("#sidebar_content")
|
||||||
|
@ -230,7 +244,7 @@ OSM.Query = function(map) {
|
||||||
|
|
||||||
function disableQueryMode() {
|
function disableQueryMode() {
|
||||||
if (marker) map.removeLayer(marker);
|
if (marker) map.removeLayer(marker);
|
||||||
$(map.getContainer()).removeClass("query-active");
|
$(map.getContainer()).removeClass("query-active").removeClass("query-disabled");
|
||||||
map.off("click", clickHandler);
|
map.off("click", clickHandler);
|
||||||
queryButton.removeClass("active");
|
queryButton.removeClass("active");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,29 @@ L.OSM.query = function (options) {
|
||||||
var link = $('<a>')
|
var link = $('<a>')
|
||||||
.attr('class', 'control-button')
|
.attr('class', 'control-button')
|
||||||
.attr('href', '#')
|
.attr('href', '#')
|
||||||
.attr('data-original-title', I18n.t('javascripts.site.queryfeature_tooltip'))
|
|
||||||
.html('<span class="icon query"></span>')
|
.html('<span class="icon query"></span>')
|
||||||
.appendTo($container);
|
.appendTo($container);
|
||||||
|
|
||||||
|
map.on('zoomend', update);
|
||||||
|
|
||||||
|
update();
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
var wasDisabled = link.hasClass('disabled'),
|
||||||
|
isDisabled = map.getZoom() < 14;
|
||||||
|
link
|
||||||
|
.toggleClass('disabled', isDisabled)
|
||||||
|
.attr('data-original-title', I18n.t(isDisabled ?
|
||||||
|
'javascripts.site.queryfeature_disabled_tooltip' :
|
||||||
|
'javascripts.site.queryfeature_tooltip'));
|
||||||
|
|
||||||
|
if (isDisabled && !wasDisabled) {
|
||||||
|
link.trigger('disabled');
|
||||||
|
} else if (wasDisabled && !isDisabled) {
|
||||||
|
link.trigger('enabled');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $container[0];
|
return $container[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -687,6 +687,10 @@ nav.secondary {
|
||||||
&.query-active {
|
&.query-active {
|
||||||
cursor: help;
|
cursor: help;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.query-disabled {
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#map-ui {
|
#map-ui {
|
||||||
|
|
|
@ -2109,6 +2109,7 @@ en:
|
||||||
map_notes_zoom_in_tooltip: Zoom in to see map notes
|
map_notes_zoom_in_tooltip: Zoom in to see map notes
|
||||||
map_data_zoom_in_tooltip: Zoom in to see map data
|
map_data_zoom_in_tooltip: Zoom in to see map data
|
||||||
queryfeature_tooltip: Query features
|
queryfeature_tooltip: Query features
|
||||||
|
queryfeature_disabled_tooltip: Zoom in to query features
|
||||||
notes:
|
notes:
|
||||||
new:
|
new:
|
||||||
intro: "Spotted a mistake or something missing? Let other mappers know so we can fix it. Move the marker to the correct position and type a note to explain the problem. (Please don't enter personal information here.)"
|
intro: "Spotted a mistake or something missing? Let other mappers know so we can fix it. Move the marker to the correct position and type a note to explain the problem. (Please don't enter personal information here.)"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue