mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-10 22:24:19 +01:00
Update ZeroClipboard and remove Copy buttons when Flash is unavailable
Fixes #16269. Closes #16301 by merging a rebased version of it.
This commit is contained in:
parent
21e94b0374
commit
229e888929
Binary file not shown.
@ -127,7 +127,7 @@
|
|||||||
|
|
||||||
// Config ZeroClipboard
|
// Config ZeroClipboard
|
||||||
ZeroClipboard.config({
|
ZeroClipboard.config({
|
||||||
moviePath: '/assets/flash/ZeroClipboard.swf',
|
swfPath: '/assets/flash/ZeroClipboard.swf',
|
||||||
hoverClass: 'btn-clipboard-hover'
|
hoverClass: 'btn-clipboard-hover'
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -136,25 +136,25 @@
|
|||||||
var btnHtml = '<div class="zero-clipboard"><span class="btn-clipboard">Copy</span></div>'
|
var btnHtml = '<div class="zero-clipboard"><span class="btn-clipboard">Copy</span></div>'
|
||||||
$(this).before(btnHtml)
|
$(this).before(btnHtml)
|
||||||
})
|
})
|
||||||
|
|
||||||
var zeroClipboard = new ZeroClipboard($('.btn-clipboard'))
|
var zeroClipboard = new ZeroClipboard($('.btn-clipboard'))
|
||||||
var htmlBridge = $('#global-zeroclipboard-html-bridge')
|
var htmlBridge = $('#global-zeroclipboard-html-bridge')
|
||||||
|
|
||||||
// Handlers for ZeroClipboard
|
// Handlers for ZeroClipboard
|
||||||
zeroClipboard.on('load', function () {
|
zeroClipboard.on('ready', function () {
|
||||||
htmlBridge
|
htmlBridge
|
||||||
.data('placement', 'top')
|
.data('placement', 'top')
|
||||||
.attr('title', 'Copy to clipboard')
|
.attr('title', 'Copy to clipboard')
|
||||||
.tooltip()
|
.tooltip()
|
||||||
})
|
|
||||||
|
|
||||||
// Copy to clipboard
|
// Copy to clipboard
|
||||||
zeroClipboard.on('dataRequested', function (client) {
|
zeroClipboard.on('copy', function (event) {
|
||||||
var highlight = $(this).parent().nextAll('.highlight').first()
|
var highlight = $(event.target).parent().nextAll('.highlight').first()
|
||||||
client.setText(highlight.text())
|
event.clipboardData.setData('text/plain', highlight.text())
|
||||||
})
|
})
|
||||||
|
|
||||||
// Notify copy success and reset tooltip title
|
// Notify copy success and reset tooltip title
|
||||||
zeroClipboard.on('complete', function () {
|
zeroClipboard.on('aftercopy', function () {
|
||||||
htmlBridge
|
htmlBridge
|
||||||
.attr('title', 'Copied!')
|
.attr('title', 'Copied!')
|
||||||
.tooltip('fixTitle')
|
.tooltip('fixTitle')
|
||||||
@ -162,13 +162,12 @@
|
|||||||
.attr('title', 'Copy to clipboard')
|
.attr('title', 'Copy to clipboard')
|
||||||
.tooltip('fixTitle')
|
.tooltip('fixTitle')
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// Notify copy failure
|
// Hide copy button on error
|
||||||
zeroClipboard.on('noflash wrongflash', function () {
|
zeroClipboard.on('error', function () {
|
||||||
htmlBridge
|
$('.zero-clipboard').remove()
|
||||||
.attr('title', 'Flash required')
|
ZeroClipboard.destroy()
|
||||||
.tooltip('fixTitle')
|
|
||||||
.tooltip('show')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
16
docs/assets/js/vendor/ZeroClipboard.min.js
vendored
16
docs/assets/js/vendor/ZeroClipboard.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user