]> git.openstreetmap.org Git - rails.git/blob - app/assets/javascripts/leaflet.note.js
Localisation updates from https://translatewiki.net.
[rails.git] / app / assets / javascripts / leaflet.note.js
1 L.OSM.note = function (options) {
2   const control = L.control(options);
3
4   control.onAdd = function (map) {
5     const $container = $("<div>")
6       .attr("class", "control-note");
7
8     const link = $("<a>")
9       .attr("class", "control-button")
10       .attr("href", "#")
11       .attr("title", OSM.i18n.t("javascripts.site.createnote_tooltip"))
12       .appendTo($container);
13
14     $(L.SVG.create("svg"))
15       .append($(L.SVG.create("use")).attr("href", "#icon-note"))
16       .attr("class", "h-100 w-100")
17       .appendTo(link);
18
19     map.on("zoomend", update);
20
21     function update() {
22       const wasDisabled = link.hasClass("disabled"),
23             isDisabled = OSM.STATUS === "database_offline" || map.getZoom() < 12;
24       link
25         .toggleClass("disabled", isDisabled)
26         .attr("data-bs-original-title", OSM.i18n.t(isDisabled ?
27           "javascripts.site.createnote_disabled_tooltip" :
28           "javascripts.site.createnote_tooltip"));
29       if (isDisabled === wasDisabled) return;
30       link.trigger(isDisabled ? "disabled" : "enabled");
31     }
32
33     update();
34
35     return $container[0];
36   };
37
38   return control;
39 };