var $container = $('<div>')
.attr('class', 'control-note');
- $('<a>')
+ var link = $('<a>')
.attr('class', 'control-button')
.attr('href', '#')
- .attr('title', 'Notes')
.html('<span class="icon note"></span>')
- .on('click', toggle)
.appendTo($container);
- function toggle(e) {
- e.stopPropagation();
- e.preventDefault();
+ map.on('zoomend', update);
- if (map.hasLayer(map.noteLayer)) {
- map.removeLayer(map.noteLayer);
- } else {
- map.addLayer(map.noteLayer);
- }
+ function update() {
+ var disabled = OSM.STATUS === "database_offline" || map.getZoom() < 12;
+ link
+ .toggleClass('disabled', disabled)
+ .attr('data-original-title', I18n.t(disabled ?
+ 'javascripts.site.createnote_disabled_tooltip' :
+ 'javascripts.site.createnote_tooltip'));
}
+ update();
+
return $container[0];
};