From 05c6e7dd66c10af8b2f8345b48c26de12f769335 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Fri, 11 Mar 2022 17:56:57 +0200 Subject: [PATCH] Fix docs error after #35644 (#36002) --- site/assets/js/application.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/site/assets/js/application.js b/site/assets/js/application.js index 1719ed9f2a..0603f52c3a 100644 --- a/site/assets/js/application.js +++ b/site/assets/js/application.js @@ -127,22 +127,24 @@ /** * - * @param {HTMLButtonElement} btn + * @param {string} selector * @param {string} title */ - function snippetButtonTooltip(btn, title) { - var tooltipBtn = new bootstrap.Tooltip(btn, { title: title }) - - btn.addEventListener('mouseleave', function () { - // Explicitly hide tooltip, since after clicking it remains - // focused (as it's a button), so tooltip would otherwise - // remain visible until focus is moved away - tooltipBtn.hide() + function snippetButtonTooltip(selector, title) { + document.querySelectorAll(selector).forEach(function (btn) { + var tooltipBtn = new bootstrap.Tooltip(btn, { title: title }) + + btn.addEventListener('mouseleave', function () { + // Explicitly hide tooltip, since after clicking it remains + // focused (as it's a button), so tooltip would otherwise + // remain visible until focus is moved away + tooltipBtn.hide() + }) }) } - snippetButtonTooltip(document.querySelector('.btn-clipboard'), 'Copy to clipboard') - snippetButtonTooltip(document.querySelector('.btn-edit'), 'Edit on Stackblitz') + snippetButtonTooltip('.btn-clipboard', 'Copy to clipboard') + snippetButtonTooltip('.btn-edit', 'Edit on Stackblitz') var clipboard = new ClipboardJS('.btn-clipboard', { target: function (trigger) { -- 2.47.2