]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Fix docs error after #35644 (#36002)
authorGeoSot <geo.sotis@gmail.com>
Fri, 11 Mar 2022 15:56:57 +0000 (17:56 +0200)
committerGitHub <noreply@github.com>
Fri, 11 Mar 2022 15:56:57 +0000 (17:56 +0200)
site/assets/js/application.js

index 1719ed9f2a7179db453ef42b01589803f5ba9938..0603f52c3af17e5e2577e9100b7c4dcd93c4a91f 100644 (file)
 
   /**
    *
-   * @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) {