Skip to content

Commit

Permalink
Fix the remaining issues for the clipboard.js switch.
Browse files Browse the repository at this point in the history
  • Loading branch information
zenorocha authored and XhmikosR committed Oct 24, 2015
1 parent c343b9f commit e4590ac
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions docs/assets/js/src/application.js
Original file line number Diff line number Diff line change
@@ -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.clearSelection();
});
$(e.trigger)
.attr('title', 'Copied!')
.tooltip('_fixTitle')
.tooltip('show')
.attr('title', 'Copy to clipboard')
.tooltip('_fixTitle')

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')
})

})

0 comments on commit e4590ac

Please sign in to comment.