Add copy_to_clipboard JS
This commit is contained in:
parent
201641594d
commit
c05275a201
|
@ -0,0 +1,21 @@
|
|||
#= require clipboard
|
||||
|
||||
$ ->
|
||||
clipboard = new Clipboard '.js-clipboard-trigger',
|
||||
text: (trigger) ->
|
||||
$target = $(trigger.nextElementSibling || trigger.previousElementSibling)
|
||||
$target.data('clipboard-text') || $target.text().trim()
|
||||
|
||||
clipboard.on 'success', (e) ->
|
||||
$(e.trigger).
|
||||
tooltip(trigger: 'manual', placement: 'auto bottom', title: 'Copied!').
|
||||
tooltip('show')
|
||||
|
||||
# Clear the selection and blur the trigger so it loses its border
|
||||
e.clearSelection()
|
||||
$(e.trigger).blur()
|
||||
|
||||
# Manually hide the tooltip after 1 second
|
||||
setTimeout(->
|
||||
$(e.trigger).tooltip('hide')
|
||||
, 1000)
|
Loading…
Reference in New Issue