PairDrop/app/elements/invitation-link/invitation-link-behavior.html
Robin Linus 78dd776426 Rename global variable 'Chat' to 'Snapdrop'
Initially a lot of code was copied from another project. This lead to confusing naming conventions.
2016-10-17 01:40:50 +02:00

45 lines
1.3 KiB
HTML

<script>
'use strict';
window.Snapdrop = window.Snapdrop || {};
Snapdrop.InvitationLinkBehavior = {
properties: {
contact: {
type: String
}
},
_copy: function(e) {
if (e) {
e.preventDefault();
e.stopPropagation();
}
Polymer.Base.create('textarea');
var copyTextarea = this.textarea;
copyTextarea.value = this.link;
copyTextarea.select();
try {
var successful = document.execCommand('copy');
if (successful) {
app.displayToast('Copied invitation link to clipboard. Share it to send files to friends!');
}
} catch (err) {
console.log('Oops, unable to copy', err);
}
copyTextarea.blur();
},
get link() {
return 'http://' + window.location.host + '/' + this.contact;
},
get textarea() {
var textarea = document.querySelector('#copytextarea');
if (!textarea) {
textarea = Polymer.Base.create('textarea');
textarea.id = 'copytextarea';
var style = textarea.style;
style.position = 'absolute';
style.top = '-10000px';
document.body.appendChild(textarea);
}
return textarea;
}
};
</script>