control.addTo(map);
});
- var lastContainer = controls[controls.length -1].getContainer();
- $(lastContainer).addClass("leaflet-control-group-end");
+ var firstContainer = controls[0].getContainer();
+ $(firstContainer).find(".control-button").first()
+ .addClass("control-button-first");
+
+ var lastContainer = controls[controls.length - 1].getContainer();
+ $(lastContainer).find(".control-button").last()
+ .addClass("control-button-last");
}
addControlGroup([
}
}
- var placement = $("html").attr("dir") === "rtl" ? "right" : "left";
- $(".leaflet-control .control-button").tooltip({ placement: placement, container: "body" });
+ $(".leaflet-control .control-button").tooltip({ placement: "left", container: "body" });
var expiry = new Date();
expiry.setYear(expiry.getFullYear() + 10);
});
if (Cookies.get("_osm_welcome") !== "hide") {
- $(".welcome").addClass("visible");
+ $(".welcome").removeAttr("hidden");
}
$(".welcome .btn-close").on("click", function () {
- $(".welcome").removeClass("visible");
+ $(".welcome").hide();
Cookies.set("_osm_welcome", "hide", { secure: true, expires: expiry, path: "/", samesite: "lax" });
});
});
function remoteEditHandler(bbox, object) {
- var loaded = false,
- url,
+ var remoteEditHost = "http://127.0.0.1:8111",
+ osmHost = location.protocol + "//" + location.host,
query = {
left: bbox.getWest() - 0.0001,
top: bbox.getNorth() + 0.0001,
bottom: bbox.getSouth() - 0.0001
};
- url = "http://127.0.0.1:8111/load_and_zoom?";
-
- if (object) query.select = object.type + object.id;
-
- var iframe = $("<iframe>")
- .hide()
- .appendTo("body")
- .attr("src", url + Qs.stringify(query))
- .on("load", function () {
- $(this).remove();
- loaded = true;
- });
+ if (object && object.type !== "note") query.select = object.type + object.id; // can't select notes
+ sendRemoteEditCommand(remoteEditHost + "/load_and_zoom?" + Qs.stringify(query), function () {
+ if (object && object.type === "note") {
+ var noteQuery = { url: osmHost + OSM.apiUrl(object) };
+ sendRemoteEditCommand(remoteEditHost + "/import?" + Qs.stringify(noteQuery));
+ }
+ });
- setTimeout(function () {
- if (!loaded) {
+ function sendRemoteEditCommand(url, callback) {
+ var iframe = $("<iframe>");
+ var timeoutId = setTimeout(function () {
alert(I18n.t("site.index.remote_failed"));
iframe.remove();
- }
- }, 1000);
+ }, 5000);
+
+ iframe
+ .hide()
+ .appendTo("body")
+ .attr("src", url)
+ .on("load", function () {
+ clearTimeout(timeoutId);
+ iframe.remove();
+ if (callback) callback();
+ });
+ }
return false;
}
e.preventDefault();
}
});
+
+ $(document).on("click", "#sidebar_content .btn-close", function () {
+ OSM.router.route("/" + OSM.formatHash(map));
+ });
});