mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-21 04:41:36 +02:00
@@ -127,22 +127,24 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {HTMLButtonElement} btn
|
* @param {string} selector
|
||||||
* @param {string} title
|
* @param {string} title
|
||||||
*/
|
*/
|
||||||
function snippetButtonTooltip(btn, title) {
|
function snippetButtonTooltip(selector, title) {
|
||||||
var tooltipBtn = new bootstrap.Tooltip(btn, { title: title })
|
document.querySelectorAll(selector).forEach(function (btn) {
|
||||||
|
var tooltipBtn = new bootstrap.Tooltip(btn, { title: title })
|
||||||
|
|
||||||
btn.addEventListener('mouseleave', function () {
|
btn.addEventListener('mouseleave', function () {
|
||||||
// Explicitly hide tooltip, since after clicking it remains
|
// Explicitly hide tooltip, since after clicking it remains
|
||||||
// focused (as it's a button), so tooltip would otherwise
|
// focused (as it's a button), so tooltip would otherwise
|
||||||
// remain visible until focus is moved away
|
// remain visible until focus is moved away
|
||||||
tooltipBtn.hide()
|
tooltipBtn.hide()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
snippetButtonTooltip(document.querySelector('.btn-clipboard'), 'Copy to clipboard')
|
snippetButtonTooltip('.btn-clipboard', 'Copy to clipboard')
|
||||||
snippetButtonTooltip(document.querySelector('.btn-edit'), 'Edit on Stackblitz')
|
snippetButtonTooltip('.btn-edit', 'Edit on Stackblitz')
|
||||||
|
|
||||||
var clipboard = new ClipboardJS('.btn-clipboard', {
|
var clipboard = new ClipboardJS('.btn-clipboard', {
|
||||||
target: function (trigger) {
|
target: function (trigger) {
|
||||||
|
Reference in New Issue
Block a user