X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/22d6633114d02af0e543afbb23cc05e33d1a1c9d..69893849cafcd117a7cee59113b9a6e7baf53dc5:/app/assets/javascripts/leaflet.note.js
diff --git a/app/assets/javascripts/leaflet.note.js b/app/assets/javascripts/leaflet.note.js
index 14a33640a..c0f72af20 100644
--- a/app/assets/javascripts/leaflet.note.js
+++ b/app/assets/javascripts/leaflet.note.js
@@ -1,27 +1,31 @@
-L.Control.Note = L.Control.extend({
- options: {
- position: 'topright',
- title: 'Notes',
- },
+L.OSM.note = function (options) {
+ var control = L.control(options);
- onAdd: function (map) {
- var className = 'leaflet-control-locate',
- classNames = className + ' leaflet-control-zoom leaflet-bar leaflet-control',
- container = L.DomUtil.create('div', classNames);
+ control.onAdd = function (map) {
+ var $container = $('
')
+ .attr('class', 'control-note');
- var link = L.DomUtil.create('a', 'leaflet-bar-part leaflet-bar-part-single', container);
- link.href = '#';
- link.title = this.options.title;
+ var link = $('
')
+ .attr('class', 'control-button')
+ .attr('href', '#')
+ .html('')
+ .appendTo($container);
- L.DomEvent
- .on(link, 'click', L.DomEvent.stopPropagation)
- .on(link, 'click', L.DomEvent.preventDefault)
- .on(link, 'dblclick', L.DomEvent.stopPropagation);
+ map.on('zoomend', update);
- return container;
+ update();
+
+ function update() {
+ var disabled = map.getZoom() < 12;
+ link
+ .toggleClass('disabled', disabled)
+ .attr('data-original-title', I18n.t(disabled ?
+ 'javascripts.site.createnote_disabled_tooltip' :
+ 'javascripts.site.createnote_tooltip'));
}
-});
-L.control.note = function(options) {
- return new L.Control.Note(options);
+ return $container[0];
+ };
+
+ return control;
};