Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2015-11-20 02:23:31 +0300
committerRobert Speicher <rspeicher@gmail.com>2015-11-20 02:25:59 +0300
commit34207d1dfbd687e38be518f569fe6a2095f65bfc (patch)
tree92d5adba257e04a506dd2c57c35d0edb6c26e575 /app
parent64e3cba941100f5af21ce47323bfa424aef582c1 (diff)
Merge branch 'rs-safari-clipboard-fallback' into 'master'
Add a fallback for Safari copy-to-clipboard Also, hide the tooltip in a less stupid way. Closes #3547 See merge request !1844
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/copy_to_clipboard.js.coffee21
1 files changed, 16 insertions, 5 deletions
diff --git a/app/assets/javascripts/copy_to_clipboard.js.coffee b/app/assets/javascripts/copy_to_clipboard.js.coffee
index ec4b80cca6f..9c68c5cc1bc 100644
--- a/app/assets/javascripts/copy_to_clipboard.js.coffee
+++ b/app/assets/javascripts/copy_to_clipboard.js.coffee
@@ -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 &#8984;-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'))