e.preventDefault();
e.stopPropagation();
+ if (queryButton.hasClass("disabled")) return;
+
if (queryButton.hasClass("active")) {
disableQueryMode();
} 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")
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");
}
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];
};
&.query-active {
cursor: help;
}
+
+ &.query-disabled {
+ cursor: not-allowed;
+ }
}
#map-ui {
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.)"