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 %}
<script src="{{'/assets/js/details-utils.js'}}" defer></script>
{% endif %}
{% if hasTooltips %}
<script src="/assets/js/tooltips.js" defer></script>
{% endif %}
<title>
{% 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>

View File

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