From 3f15f3823d2351ec7a488bb60773f531c521841e Mon Sep 17 00:00:00 2001 From: Kazerlelutin Date: Thu, 1 Aug 2024 21:15:31 +0200 Subject: [PATCH] change return button --- ctrl/link.js | 7 +++++-- ctrl/returnButton.js | 6 ++++-- pages/index.html | 1 - pages/ressource.html | 1 - templates/404.html | 1 - templates/basic-layout.html | 5 ++++- templates/returnButton.html | 13 +++++++++++-- templates/sections.html | 4 +--- utils/displayReturnBtn.js | 11 +++++++++++ 9 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 utils/displayReturnBtn.js diff --git a/ctrl/link.js b/ctrl/link.js index eeda85c..9504269 100644 --- a/ctrl/link.js +++ b/ctrl/link.js @@ -1,9 +1,12 @@ import { kll } from '../main.js' +import { displayReturnBtn } from '../utils/displayReturnBtn.js' + export const link = { - onClick(_, el, e) { + async onClick(_, el, e) { e.preventDefault() const path = el.getAttribute('href') window.history.pushState({}, '', path) - kll.injectPage(path) + await kll.injectPage(path) + displayReturnBtn() }, } diff --git a/ctrl/returnButton.js b/ctrl/returnButton.js index 02ec897..44aab39 100644 --- a/ctrl/returnButton.js +++ b/ctrl/returnButton.js @@ -1,9 +1,10 @@ import { kll } from '../main' +import { displayReturnBtn } from '../utils/displayReturnBtn' import { getByDataAttr } from '../utils/getByDataAttr' export const returnButton = { - onInit(_, el) { - el.render() + async onInit(_, el) { + await el.render() }, render(_, el) { const textEl = getByDataAttr(el, 'text') @@ -26,5 +27,6 @@ export const returnButton = { arrow.setAttribute('href', el.href) kll.plugins.translate(textEl) + displayReturnBtn() }, } diff --git a/pages/index.html b/pages/index.html index e14151a..7311850 100644 --- a/pages/index.html +++ b/pages/index.html @@ -3,6 +3,5 @@
-
\ No newline at end of file diff --git a/pages/ressource.html b/pages/ressource.html index b53e118..9fa324c 100644 --- a/pages/ressource.html +++ b/pages/ressource.html @@ -1,7 +1,6 @@
-

diff --git a/templates/404.html b/templates/404.html index 96728fb..42e41f8 100644 --- a/templates/404.html +++ b/templates/404.html @@ -1,6 +1,5 @@