Commit 438cae9d authored by XhmikosR's avatar XhmikosR

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

This reverts commit 229e8889.

ZeroClipboard v2.x drops IE < 9 support.
parent 16a44c20
...@@ -127,7 +127,7 @@ ...@@ -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,38 +136,39 @@ ...@@ -136,38 +136,39 @@
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')
.tooltip('show') .tooltip('show')
.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')
}) })
}) })
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment