Add a fallback for Safari copy-to-clipboard
Also, hide the tooltip in a less stupid way. Closes #3547
This commit is contained in:
parent
e1780825ee
commit
2a3680219b
|
@ -9,13 +9,24 @@ $ ->
|
|||
clipboard.on 'success', (e) ->
|
||||
$(e.trigger).
|
||||
tooltip(trigger: 'manual', placement: 'auto bottom', title: 'Copied!').
|
||||
tooltip('show')
|
||||
tooltip('show').
|
||||
one('mouseleave', -> $(this).tooltip('hide'))
|
||||
|
||||
# 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)
|
||||
# Safari doesn't support `execCommand`, so instead we inform the user to
|
||||
# copy manually.
|
||||
#
|
||||
# See http://clipboardjs.com/#browser-support
|
||||
clipboard.on 'error', (e) ->
|
||||
if /Mac/i.test(navigator.userAgent)
|
||||
title = "Press ⌘-C to copy"
|
||||
else
|
||||
title = "Press Ctrl-C to copy"
|
||||
|
||||
$(e.trigger).
|
||||
tooltip(trigger: 'manual', placement: 'auto bottom', html: true, title: title).
|
||||
tooltip('show').
|
||||
one('mouseleave', -> $(this).tooltip('hide'))
|
||||
|
|
Loading…
Reference in New Issue