0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-01 13:24:25 +01:00

Revert "Update ZeroClipboard and remove Copy buttons when Flash is unavailable"

This reverts commit 229e888929.

ZeroClipboard v2.x drops IE < 9 support.
This commit is contained in:
XhmikosR 2015-04-28 14:27:09 +03:00
parent 16a44c208d
commit 438cae9d90
3 changed files with 32 additions and 31 deletions

Binary file not shown.

View File

@ -127,7 +127,7 @@
// Config ZeroClipboard // Config ZeroClipboard
ZeroClipboard.config({ ZeroClipboard.config({
swfPath: '/assets/flash/ZeroClipboard.swf', moviePath: '/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('ready', function () { zeroClipboard.on('load', 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('copy', function (event) { zeroClipboard.on('dataRequested', function (client) {
var highlight = $(event.target).parent().nextAll('.highlight').first() var highlight = $(this).parent().nextAll('.highlight').first()
event.clipboardData.setData('text/plain', highlight.text()) client.setText(highlight.text())
}) })
// Notify copy success and reset tooltip title // Notify copy success and reset tooltip title
zeroClipboard.on('aftercopy', function () { zeroClipboard.on('complete', function () {
htmlBridge htmlBridge
.attr('title', 'Copied!') .attr('title', 'Copied!')
.tooltip('fixTitle') .tooltip('fixTitle')
@ -162,12 +162,13 @@
.attr('title', 'Copy to clipboard') .attr('title', 'Copy to clipboard')
.tooltip('fixTitle') .tooltip('fixTitle')
}) })
})
// Hide copy button on error // Notify copy failure
zeroClipboard.on('error', function () { zeroClipboard.on('noflash wrongflash', function () {
$('.zero-clipboard').remove() htmlBridge
ZeroClipboard.destroy() .attr('title', 'Flash required')
.tooltip('fixTitle')
.tooltip('show')
}) })
}) })

File diff suppressed because one or more lines are too long