mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-22 21:22:52 +02:00
Fix the remaining issues for the clipboard.js switch.
This commit is contained in:
@@ -38,29 +38,38 @@
|
|||||||
|
|
||||||
// Insert copy to clipboard button before .highlight
|
// Insert copy to clipboard button before .highlight
|
||||||
$('.highlight').each(function () {
|
$('.highlight').each(function () {
|
||||||
var btnHtml = '<div class="bd-clipboard"><span class="btn-clipboard">Copy</span></div>'
|
var btnHtml = '<div class="bd-clipboard"><span class="btn-clipboard" title="Copy to clipboard">Copy</span></div>'
|
||||||
$(this).before(btnHtml)
|
$(this).before(btnHtml)
|
||||||
|
$('.btn-clipboard').tooltip()
|
||||||
})
|
})
|
||||||
|
|
||||||
var clipboard = new Clipboard('.bd-clipboard', {
|
var clipboard = new Clipboard('.btn-clipboard', {
|
||||||
target: function (trigger) {
|
target: function (trigger) {
|
||||||
return trigger.nextElementSibling;
|
return trigger.parentNode.nextElementSibling
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
/*
|
|
||||||
clipboard.on('success', function (e) {
|
clipboard.on('success', function (e) {
|
||||||
console.info('Action:', e.action);
|
$(e.trigger)
|
||||||
console.info('Text:', e.text);
|
.attr('title', 'Copied!')
|
||||||
console.info('Trigger:', e.trigger);
|
.tooltip('_fixTitle')
|
||||||
|
.tooltip('show')
|
||||||
|
.attr('title', 'Copy to clipboard')
|
||||||
|
.tooltip('_fixTitle')
|
||||||
|
|
||||||
e.clearSelection();
|
e.clearSelection()
|
||||||
});
|
})
|
||||||
|
|
||||||
clipboard.on('error', function (e) {
|
clipboard.on('error', function (e) {
|
||||||
console.error('Action:', e.action);
|
var fallbackMsg = /Mac/i.test(navigator.userAgent) ? 'Press \u2318 to copy' : 'Press Ctrl-C to copy'
|
||||||
console.error('Trigger:', e.trigger);
|
|
||||||
});*/
|
$(e.trigger)
|
||||||
|
.attr('title', fallbackMsg)
|
||||||
|
.tooltip('_fixTitle')
|
||||||
|
.tooltip('show')
|
||||||
|
.attr('title', 'Copy to clipboard')
|
||||||
|
.tooltip('_fixTitle')
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user