mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-24 16:56:16 -04:00
52 lines
1.9 KiB
HTML
52 lines
1.9 KiB
HTML
<link rel="import" href="../../bower_components/paper-dialog/paper-dialog.html">
|
|
<link rel="import" href="../../bower_components/paper-button/paper-button.html">
|
|
<link rel="import" href="../../bower_components/neon-animation/animations/scale-up-animation.html">
|
|
<link rel="import" href="../../bower_components/neon-animation/animations/fade-out-animation.html">
|
|
<dom-module id="file-receiver">
|
|
<template>
|
|
<style>
|
|
:host {
|
|
display: block;
|
|
position: fixed;
|
|
z-index: 100;
|
|
}
|
|
</style>
|
|
<paper-dialog id="dialog" entry-animation="scale-up-animation" exit-animation="fade-out-animation" with-backdro>
|
|
<h2>File Received</h2>
|
|
<p>You received file {{file.name}}</p>
|
|
<div class="buttons">
|
|
<paper-button dialog-dismiss>Dismiss</paper-button>
|
|
<paper-button dialog-confirm on-tap="_download">Download</paper-button>
|
|
</div>
|
|
</paper-dialog>
|
|
</template>
|
|
<script>
|
|
'use strict';
|
|
Polymer({
|
|
is: 'file-receiver',
|
|
attached: function() {
|
|
this.async(function() {
|
|
app.p2p.addEventListener('file-received', function(e) {
|
|
this.fileReceived(e.detail);
|
|
}.bind(this), false);
|
|
},200);
|
|
},
|
|
fileReceived: function(file) {
|
|
this.set('file', file);
|
|
this.$.dialog.open();
|
|
},
|
|
_download: function() {
|
|
var link = document.createElement('a');
|
|
link.download = this.file.name;
|
|
// Construct the uri
|
|
var uri = this.file.dataURI;
|
|
link.href = uri;
|
|
document.body.appendChild(link);
|
|
link.click();
|
|
// Cleanup the DOM
|
|
document.body.removeChild(link);
|
|
//delete link;
|
|
}
|
|
});
|
|
</script>
|
|
</dom-module>
|