X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/e731dd71a77ad4ad1e9db22535e89444bb98e5d9..367fa44a74c06563b6f0e23c1e9db888769f57f0:/app/assets/javascripts/leaflet.share.js diff --git a/app/assets/javascripts/leaflet.share.js b/app/assets/javascripts/leaflet.share.js index eedfe3ab3..eb351fa02 100644 --- a/app/assets/javascripts/leaflet.share.js +++ b/app/assets/javascripts/leaflet.share.js @@ -1,38 +1,12 @@ 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", "deemphasize") - .text(I18n.t("javascripts.share.paste_html")) - .appendTo($linkSection)); + .attr("class", "text-muted") + .text(I18n.t("javascripts.share.paste_html"))); // Geo URI @@ -147,57 +128,71 @@ L.OSM.share = function (options) { $("
") - .attr("class", "deemphasize") - .html(I18n.t("javascripts.share.image_size") + " x ") + .attr("class", "text-muted") + .html(I18n.t("javascripts.share.image_dimensions", args)) .appendTo($form); $("") .attr("type", "submit") + .attr("class", "btn btn-primary") .attr("value", I18n.t("javascripts.share.download")) .appendTo($form); @@ -240,11 +241,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; @@ -252,18 +257,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()); @@ -319,6 +312,7 @@ L.OSM.share = function (options) { } function update() { + var canEmbed = map.getMapBaseLayerId() !== "tracestracktopo"; var bounds = map.getBounds(); $("#link_marker") @@ -344,8 +338,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( - "" + "" + @@ -408,8 +410,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;