From 8c69541b49f702c2a55f9a873dacf11b3afce605 Mon Sep 17 00:00:00 2001 From: Helen Chong <119173961+helenclx@users.noreply.github.com> Date: Tue, 12 Nov 2024 21:41:06 +0800 Subject: [PATCH] Gather all tooltip script in one file --- src/_includes/global/baselayout.njk | 14 +++----------- src/assets/js/tooltips.js | 9 ++++++++- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/_includes/global/baselayout.njk b/src/_includes/global/baselayout.njk index b7b971a4..d614ebc1 100644 --- a/src/_includes/global/baselayout.njk +++ b/src/_includes/global/baselayout.njk @@ -39,6 +39,9 @@ {% if toc %} {% endif %} + {% if hasTooltips %} + + {% endif %} {% block pageTitle %}{{ title + " | " if title }}{{ sitemeta.siteName | safe }}{% endblock %} @@ -52,16 +55,5 @@ {{ content | safe }} </main> {% block footer %}{% include "global/footer.njk" %}{% endblock %} - {% if hasTooltips %} - <script src="/assets/js/tooltips.js"></script> - <script> - var selector = '[data-tooltip]'; - var els = document.querySelectorAll(selector); - - for ( var i = 0; i < els.length; i++ ) { - var dm = new ARIAtip( els[i] ); - } - </script> - {% endif %} </body> </html> \ No newline at end of file diff --git a/src/assets/js/tooltips.js b/src/assets/js/tooltips.js index e597045a..acba6d27 100644 --- a/src/assets/js/tooltips.js +++ b/src/assets/js/tooltips.js @@ -300,4 +300,11 @@ var util = { }; // ARIAtip w.ARIAtip = ARIAtip; -})( window, document ); \ No newline at end of file +})( window, document ); + +var selector = '[data-tooltip]'; +var els = document.querySelectorAll(selector); + +for ( var i = 0; i < els.length; i++ ) { + var dm = new ARIAtip( els[i] ); +} \ No newline at end of file