mirror of
https://github.com/twbs/bootstrap.git
synced 2024-11-29 11:24:18 +01:00
Fix the remaining issues for the clipboard.js switch.
This commit is contained in:
parent
c343b9f59d
commit
e4590aca61
@ -38,29 +38,38 @@
|
||||
|
||||
// Insert copy to clipboard button before .highlight
|
||||
$('.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)
|
||||
$('.btn-clipboard').tooltip()
|
||||
})
|
||||
|
||||
var clipboard = new Clipboard('.bd-clipboard', {
|
||||
var clipboard = new Clipboard('.btn-clipboard', {
|
||||
target: function (trigger) {
|
||||
return trigger.nextElementSibling;
|
||||
return trigger.parentNode.nextElementSibling
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
/*
|
||||
clipboard.on('success', function (e) {
|
||||
console.info('Action:', e.action);
|
||||
console.info('Text:', e.text);
|
||||
console.info('Trigger:', e.trigger);
|
||||
$(e.trigger)
|
||||
.attr('title', 'Copied!')
|
||||
.tooltip('_fixTitle')
|
||||
.tooltip('show')
|
||||
.attr('title', 'Copy to clipboard')
|
||||
.tooltip('_fixTitle')
|
||||
|
||||
e.clearSelection();
|
||||
});
|
||||
e.clearSelection()
|
||||
})
|
||||
|
||||
clipboard.on('error', function (e) {
|
||||
console.error('Action:', e.action);
|
||||
console.error('Trigger:', e.trigger);
|
||||
});*/
|
||||
var fallbackMsg = /Mac/i.test(navigator.userAgent) ? 'Press \u2318 to copy' : 'Press Ctrl-C to copy'
|
||||
|
||||
$(e.trigger)
|
||||
.attr('title', fallbackMsg)
|
||||
.tooltip('_fixTitle')
|
||||
.tooltip('show')
|
||||
.attr('title', 'Copy to clipboard')
|
||||
.tooltip('_fixTitle')
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user