X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/ff52509d5a75c7f218a8d6d6d82bb25897b3dae9..5cf26d0559e303a26a6908a64b8fca012472edd3:/app/assets/javascripts/leaflet.note.js?ds=sidebyside
diff --git a/app/assets/javascripts/leaflet.note.js b/app/assets/javascripts/leaflet.note.js
index 43717f2c1..77fb9baff 100644
--- a/app/assets/javascripts/leaflet.note.js
+++ b/app/assets/javascripts/leaflet.note.js
@@ -1,39 +1,19 @@
-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;
+ $('
')
+ .attr('class', 'control-button')
+ .attr('href', '#')
+ .attr('title', I18n.t('javascripts.notes.new.add'))
+ .html('')
+ .appendTo($container);
- L.DomEvent
- .on(link, 'click', L.DomEvent.stopPropagation)
- .on(link, 'click', L.DomEvent.preventDefault)
- .on(link, 'click', this._toggle, this)
- .on(link, 'dblclick', L.DomEvent.stopPropagation);
+ return $container[0];
+ };
- this.map = map;
-
- return container;
- },
-
- // TODO: this relies on notesLayer on the map
- _toggle: function() {
- if (this.map.hasLayer(this.map.noteLayer)) {
- this.map.removeLayer(this.map.noteLayer);
- } else {
- this.map.addLayer(this.map.noteLayer);
- }
- }
-});
-
-L.control.note = function(options) {
- return new L.Control.Note(options);
+ return control;
};