Skip to content

Commit

Permalink
fix(modal): add Chrome clipboard implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
SabreCat committed Dec 4, 2018
1 parent 0853fce commit 8b15302
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions website/client/components/groups/createPartyModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,17 @@ b-modal#create-party-modal(size='lg', hide-footer=true)
this.$router.push('/party');
},
copyUsername () {
let copyText = document.createElement('textarea');
copyText.value = this.user.auth.local.username;
document.body.appendChild(copyText);
copyText.select();
document.execCommand('copy');
if (navigator.clipboard) {
navigator.clipboard.writeText(this.user.auth.local.username);
} else {
let copyText = document.createElement('textarea');
copyText.value = this.user.auth.local.username;
document.body.appendChild(copyText);
copyText.select();
document.execCommand('copy');
document.body.removeChild(copyText);
}
this.text(this.$t('usernameCopied'));
document.body.removeChild(copyText);
},
},
mixins: [notifications],
Expand Down

0 comments on commit 8b15302

Please sign in to comment.