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) ->
|
clipboard.on 'success', (e) ->
|
||||||
$(e.trigger).
|
$(e.trigger).
|
||||||
tooltip(trigger: 'manual', placement: 'auto bottom', title: 'Copied!').
|
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
|
# Clear the selection and blur the trigger so it loses its border
|
||||||
e.clearSelection()
|
e.clearSelection()
|
||||||
$(e.trigger).blur()
|
$(e.trigger).blur()
|
||||||
|
|
||||||
# Manually hide the tooltip after 1 second
|
# Safari doesn't support `execCommand`, so instead we inform the user to
|
||||||
setTimeout(->
|
# copy manually.
|
||||||
$(e.trigger).tooltip('hide')
|
#
|
||||||
, 1000)
|
# 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