Merge remote-tracking branch 'upstream/pull/5731'
This commit is contained in:
commit
30415443e9
6 changed files with 33 additions and 31 deletions
|
@ -95,6 +95,9 @@ $(document).ready(function () {
|
|||
breakpointWidth = 768;
|
||||
let moreItemWidth = 0;
|
||||
|
||||
OSM.csrf = {};
|
||||
OSM.csrf[($("meta[name=csrf-param]").attr("content"))] = $("meta[name=csrf-token]").attr("content");
|
||||
|
||||
function updateHeader() {
|
||||
const windowWidth = $(window).width();
|
||||
|
||||
|
|
|
@ -44,19 +44,14 @@ OSM.Search = function (map) {
|
|||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const div = $(this).parents(".search_more"),
|
||||
csrf_param = $("meta[name=csrf-param]").attr("content"),
|
||||
csrf_token = $("meta[name=csrf-token]").attr("content"),
|
||||
params = new URLSearchParams();
|
||||
const div = $(this).parents(".search_more");
|
||||
|
||||
$(this).hide();
|
||||
div.find(".loader").show();
|
||||
|
||||
params.set(csrf_param, csrf_token);
|
||||
|
||||
fetch($(this).attr("href"), {
|
||||
method: "POST",
|
||||
body: params
|
||||
body: new URLSearchParams(OSM.csrf)
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => div.replaceWith(data));
|
||||
|
@ -120,20 +115,17 @@ OSM.Search = function (map) {
|
|||
|
||||
page.load = function () {
|
||||
$(".search_results_entry").each(function (index) {
|
||||
const entry = $(this),
|
||||
csrf_param = $("meta[name=csrf-param]").attr("content"),
|
||||
csrf_token = $("meta[name=csrf-token]").attr("content"),
|
||||
params = new URLSearchParams({
|
||||
zoom: map.getZoom(),
|
||||
minlon: map.getBounds().getWest(),
|
||||
minlat: map.getBounds().getSouth(),
|
||||
maxlon: map.getBounds().getEast(),
|
||||
maxlat: map.getBounds().getNorth()
|
||||
});
|
||||
params.set(csrf_param, csrf_token);
|
||||
const entry = $(this);
|
||||
fetch(entry.data("href"), {
|
||||
method: "POST",
|
||||
body: params
|
||||
body: new URLSearchParams({
|
||||
zoom: map.getZoom(),
|
||||
minlon: map.getBounds().getWest(),
|
||||
minlat: map.getBounds().getSouth(),
|
||||
maxlon: map.getBounds().getEast(),
|
||||
maxlat: map.getBounds().getNorth(),
|
||||
...OSM.csrf
|
||||
})
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(function (html) {
|
||||
|
|
|
@ -16,7 +16,10 @@ L.OSM.key = function (options) {
|
|||
|
||||
function shown() {
|
||||
map.on("zoomend baselayerchange", update);
|
||||
$section.load("/key", update);
|
||||
fetch("/key")
|
||||
.then(r => r.text())
|
||||
.then(html => { $section.html(html); })
|
||||
.then(update);
|
||||
}
|
||||
|
||||
function hidden() {
|
||||
|
|
|
@ -228,13 +228,11 @@ L.OSM.share = function (options) {
|
|||
.appendTo($form);
|
||||
}
|
||||
|
||||
const csrf_param = $("meta[name=csrf-param]").attr("content"),
|
||||
csrf_token = $("meta[name=csrf-token]").attr("content");
|
||||
const csrfAttrs = { type: "hidden" };
|
||||
[[csrfAttrs.name, csrfAttrs.value]] = Object.entries(OSM.csrf);
|
||||
|
||||
$("<input>")
|
||||
.attr("name", csrf_param)
|
||||
.attr("value", csrf_token)
|
||||
.attr("type", "hidden")
|
||||
.attr(csrfAttrs)
|
||||
.appendTo($form);
|
||||
|
||||
const args = {
|
||||
|
|
|
@ -36,9 +36,15 @@
|
|||
if (preview.children(".richtext").contents().length === 0) {
|
||||
preview.children(".richtext_placeholder").removeAttr("hidden").addClass("delayed-fade-in");
|
||||
|
||||
preview.children(".richtext").load(editor.data("previewUrl"), { text: editor.val() }, function () {
|
||||
preview.children(".richtext_placeholder").attr("hidden", true).removeClass("delayed-fade-in");
|
||||
});
|
||||
fetch(editor.data("previewUrl"), {
|
||||
method: "POST",
|
||||
body: new URLSearchParams({ text: editor.val(), ...OSM.csrf })
|
||||
})
|
||||
.then(r => r.text())
|
||||
.then(html => {
|
||||
preview.children(".richtext").html(html);
|
||||
preview.children(".richtext_placeholder").attr("hidden", true).removeClass("delayed-fade-in");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -210,10 +210,10 @@ $(document).ready(function () {
|
|||
});
|
||||
|
||||
$("input[name=legale]").change(function () {
|
||||
const url = $(this).data("url");
|
||||
|
||||
$("#contributorTerms").html("<div class='spinner-border' role='status'><span class='visually-hidden'>" + I18n.t("browse.start_rjs.loading") + "</span></div>");
|
||||
$("#contributorTerms").load(url);
|
||||
fetch($(this).data("url"))
|
||||
.then(r => r.text())
|
||||
.then(html => { $("#contributorTerms").html(html); });
|
||||
});
|
||||
|
||||
$("#read_ct").on("click", function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue