2015-12-30 18:07:37 +01:00
|
|
|
<script>
|
|
|
|
'use strict';
|
2016-06-23 19:03:49 +02:00
|
|
|
window.Snapdrop = window.Snapdrop || {};
|
|
|
|
Snapdrop.InvitationLinkBehavior = {
|
2015-12-30 18:07:37 +01:00
|
|
|
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>
|