Disable query feature tool below z14

This commit is contained in:
Tom Hughes 2014-03-09 13:51:43 +00:00
parent 8a70e1c082
commit 606ac76108
4 changed files with 40 additions and 2 deletions

View file

@ -9,6 +9,8 @@ OSM.Query = function(map) {
e.preventDefault();
e.stopPropagation();
if (queryButton.hasClass("disabled")) return;
if (queryButton.hasClass("active")) {
disableQueryMode();
@ -16,6 +18,18 @@ OSM.Query = function(map) {
} else {
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")
@ -230,7 +244,7 @@ OSM.Query = function(map) {
function disableQueryMode() {
if (marker) map.removeLayer(marker);
$(map.getContainer()).removeClass("query-active");
$(map.getContainer()).removeClass("query-active").removeClass("query-disabled");
map.off("click", clickHandler);
queryButton.removeClass("active");
}

View file

@ -8,10 +8,29 @@ L.OSM.query = function (options) {
var link = $('<a>')
.attr('class', 'control-button')
.attr('href', '#')
.attr('data-original-title', I18n.t('javascripts.site.queryfeature_tooltip'))
.html('<span class="icon query"></span>')
.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];
};

View file

@ -687,6 +687,10 @@ nav.secondary {
&.query-active {
cursor: help;
}
&.query-disabled {
cursor: not-allowed;
}
}
#map-ui {

View file

@ -2109,6 +2109,7 @@ en:
map_notes_zoom_in_tooltip: Zoom in to see map notes
map_data_zoom_in_tooltip: Zoom in to see map data
queryfeature_tooltip: Query features
queryfeature_disabled_tooltip: Zoom in to query features
notes:
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.)"