aboutsummaryrefslogtreecommitdiff
path: root/site/assets/js
diff options
context:
space:
mode:
authorPuru Vijay <[email protected]>2022-03-09 21:02:58 +0530
committerGitHub <[email protected]>2022-03-09 17:32:58 +0200
commit645f95584551409660fcd9b990fc24caa0327df5 (patch)
tree7c2e06398708c563cecd43c5b9df2d01188093fc /site/assets/js
parent7e5a8016ba557641ee93b38aed4482a1360b64af (diff)
downloadbootstrap-645f95584551409660fcd9b990fc24caa0327df5.tar.xz
bootstrap-645f95584551409660fcd9b990fc24caa0327df5.zip
docs: add a StackBlitz "Try It" button in code examples (#35644)
Co-authored-by: GeoSot <[email protected]> Co-authored-by: XhmikosR <[email protected]>
Diffstat (limited to 'site/assets/js')
-rw-r--r--site/assets/js/application.js27
1 files changed, 17 insertions, 10 deletions
diff --git a/site/assets/js/application.js b/site/assets/js/application.js
index b267bfb6f..1719ed9f2 100644
--- a/site/assets/js/application.js
+++ b/site/assets/js/application.js
@@ -125,17 +125,24 @@
element.insertAdjacentHTML('beforebegin', btnHtml)
})
- document.querySelectorAll('.btn-clipboard')
- .forEach(function (btn) {
- var tooltipBtn = new bootstrap.Tooltip(btn, { title: btnTitle })
-
- 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()
- })
+ /**
+ *
+ * @param {HTMLButtonElement} btn
+ * @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()
})
+ }
+
+ snippetButtonTooltip(document.querySelector('.btn-clipboard'), 'Copy to clipboard')
+ snippetButtonTooltip(document.querySelector('.btn-edit'), 'Edit on Stackblitz')
var clipboard = new ClipboardJS('.btn-clipboard', {
target: function (trigger) {