copy share invite link to clipboard automatically where possible

This commit is contained in:
Devin Howard 2016-10-18 15:59:15 +08:00
parent 139837e997
commit 2529e0d44f
2 changed files with 14 additions and 1 deletions

View file

@ -1,5 +1,7 @@
/* global Metamaps, $ */ /* global Metamaps, $ */
import clipboard from 'clipboard-js'
import Active from '../Active' import Active from '../Active'
import Create from '../Create' import Create from '../Create'
@ -139,7 +141,17 @@ const GlobalUI = {
self.hideDiv('#toast') self.hideDiv('#toast')
}, },
shareInvite: function (inviteLink) { shareInvite: function (inviteLink) {
window.prompt('To copy the invite link, press: Ctrl+C, Enter', inviteLink) clipboard.copy({
'text/plain': inviteLink
}).then(() => {
$('#joinCodesBox .popup').remove()
$('#joinCodesBox').append('<p class="popup" style="text-align: center">Copied!</p>')
window.setTimeout(() => $('#joinCodesBox .popup').remove(), 1500)
}, () => {
$('#joinCodesBox .popup').remove()
$('#joinCodesBox').append(`<p class="popup" style="text-align: center">Your browser doesn't support copying, please copy manually.</p>`)
window.setTimeout(() => $('#joinCodesBox .popup').remove(), 1500)
})
} }
} }

View file

@ -27,6 +27,7 @@
"babel-preset-es2015": "6.14.0", "babel-preset-es2015": "6.14.0",
"babel-preset-react": "6.11.1", "babel-preset-react": "6.11.1",
"backbone": "1.0.0", "backbone": "1.0.0",
"clipboard-js": "git://github.com/devvmh/clipboard.js#patch-1",
"commonmark": "0.26.0", "commonmark": "0.26.0",
"csv-parse": "1.1.7", "csv-parse": "1.1.7",
"getScreenMedia": "git://github.com/devvmh/getScreenMedia#patch-1", "getScreenMedia": "git://github.com/devvmh/getScreenMedia#patch-1",