Gather all tooltip script in one file

This commit is contained in:
Helen Chong 2024-11-12 21:41:06 +08:00
parent c94fc87d23
commit 8c69541b49
2 changed files with 11 additions and 12 deletions

View File

@ -39,6 +39,9 @@
{% if toc %} {% if toc %}
<script src="{{'/assets/js/details-utils.js'}}" defer></script> <script src="{{'/assets/js/details-utils.js'}}" defer></script>
{% endif %} {% endif %}
{% if hasTooltips %}
<script src="/assets/js/tooltips.js" defer></script>
{% endif %}
<title> <title>
{% block pageTitle %}{{ title + " | " if title }}{{ sitemeta.siteName | safe }}{% endblock %} {% block pageTitle %}{{ title + " | " if title }}{{ sitemeta.siteName | safe }}{% endblock %}
@ -52,16 +55,5 @@
{{ content | safe }} {{ content | safe }}
</main> </main>
{% block footer %}{% include "global/footer.njk" %}{% endblock %} {% 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> </body>
</html> </html>

View File

@ -301,3 +301,10 @@ var util = {
w.ARIAtip = ARIAtip; w.ARIAtip = ARIAtip;
})( window, document ); })( 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] );
}