X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/501e25641969c0cf779c1178ca7f2613c88ca933..4a62dac9c06bcdb7c2acac75e9168bf654c4c64d:/app/assets/javascripts/leaflet.share.js diff --git a/app/assets/javascripts/leaflet.share.js b/app/assets/javascripts/leaflet.share.js index 79cb95973..b92d70796 100644 --- a/app/assets/javascripts/leaflet.share.js +++ b/app/assets/javascripts/leaflet.share.js @@ -1,42 +1,17 @@ L.OSM.share = function (options) { - var control = L.control(options), + var control = L.OSM.sidebarPane(options, "share", "javascripts.share.title", "javascripts.share.title"), marker = L.marker([0, 0], { draggable: true }), locationFilter = new L.LocationFilter({ enableButton: false, adjustButton: false }); - control.onAdd = function (map) { - var $container = $("
") - .attr("class", "text-muted") - .text(I18n.t("javascripts.share.paste_html")) - .appendTo($linkSection)); + .attr("class", "text-body-secondary") + .text(I18n.t("javascripts.share.paste_html"))); // Geo URI var $geoUriSection = $("
") - .attr("class", "text-muted") + .attr("class", "text-body-secondary") .html(I18n.t("javascripts.share.image_dimensions", args)) .appendTo($form); @@ -246,11 +242,15 @@ L.OSM.share = function (options) { map.on("move", movedMap); map.on("moveend layeradd layerremove", update); - options.sidebar.addPane($ui); - $ui + .on("show", shown) .on("hide", hidden); + function shown() { + $("#mapnik_scale").val(getScale()); + update(); + } + function hidden() { map.removeLayer(marker); map.options.scrollWheelZoom = map.options.doubleClickZoom = true; @@ -258,18 +258,6 @@ L.OSM.share = function (options) { update(); } - function toggle(e) { - e.stopPropagation(); - e.preventDefault(); - - $("#mapnik_scale").val(getScale()); - marker.setLatLng(map.getCenter()); - - update(); - options.sidebar.togglePane($ui, button); - $(".leaflet-control .control-button").tooltip("hide"); - } - function toggleMarker() { if ($(this).is(":checked")) { marker.setLatLng(map.getCenter()); @@ -325,6 +313,7 @@ L.OSM.share = function (options) { } function update() { + var canEmbed = map.getMapBaseLayerId() !== "tracestracktopo"; var bounds = map.getBounds(); $("#link_marker") @@ -350,8 +339,16 @@ L.OSM.share = function (options) { params.marker = latLng.lat + "," + latLng.lng; } + $("#embed_link") + .toggleClass("btn-primary", canEmbed) + .toggleClass("btn-secondary", !canEmbed) + .tooltip(canEmbed ? "disable" : "enable"); + if (!canEmbed && $("#embed_link").hasClass("active")) { + $("#long_link").click(); + } + $("#embed_html").val( - "" + "" + @@ -414,8 +411,6 @@ L.OSM.share = function (options) { var precision = 5 * Math.pow(10, Math.floor(Math.LOG10E * Math.log(scale)) - 2); return precision * Math.ceil(scale / precision); } - - return $container[0]; }; return control;