From 28cefbd5904eca6586b01af7c54286421d431f98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sn=C3=ADda=C5=88ov=C3=BD=20Mistr?= Date: Tue, 27 Feb 2024 20:56:37 +0100 Subject: [PATCH] =?UTF-8?q?Pozice=20formul=C3=A1=C5=99e=20v=20localStorage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/js/post-form.js | 15 +++++++++++++++ templates/macros/post-form.html | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/static/js/post-form.js b/static/js/post-form.js index 5ad099f..b3dbb57 100644 --- a/static/js/post-form.js +++ b/static/js/post-form.js @@ -24,6 +24,18 @@ $(function () { let form = $("#post-form"); let handle = $("#post-form-handle"); + let saved_top = window.localStorage.getItem("post_form_top"); + let saved_left = window.localStorage.getItem("post_form_left"); + + if (saved_top) { + form.css("top", saved_top); + } + + if (saved_left) { + form.css("left", saved_left); + form.css("right", "auto") + } + handle.on("mousedown", start); handle.get(0).addEventListener("touchstart", start, { passive: true }); $(document).on("mouseup", stop); @@ -107,6 +119,9 @@ $(function () { } form.css("right", "auto"); + + window.localStorage.setItem("post_form_top", form.css("top")); + window.localStorage.setItem("post_form_left", form.css("left")); } function stop() { diff --git a/templates/macros/post-form.html b/templates/macros/post-form.html index 85df7ca..520fdb8 100644 --- a/templates/macros/post-form.html +++ b/templates/macros/post-form.html @@ -12,7 +12,7 @@ {% else %} Nové vlákno {% endif %} - [Zavřít] + [X]