PairDrop/app/elements/file-sharing/file-button-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

37 lines
1.3 KiB
HTML

<link rel="import" href="file-selection-behavior.html">
<script>
'use strict';
window.Snapdrop = window.Snapdrop || {};
Snapdrop.FileButtonBehaviorImpl = {
get fileInput() {
var fileInput = Polymer.dom(this).querySelector('.fileInput');
if (!fileInput) {
fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.multiple = 'false';
fileInput.className = 'fileInput';
fileInput.style.position = 'fixed';
fileInput.style.top = '-10000px';
fileInput.style.left = '-10000px';
fileInput.style.opacity = 0;
Polymer.dom(this).appendChild(fileInput);
}
return fileInput;
},
attached: function() {
this.fileInput.onchange = function() {
var files = this.fileInput.files;
this.notifyFilesSelection(files);
}.bind(this);
this.addEventListener('click', function(e) {
var button = e.which || e.button;
if (button !== 1) {
return;
}
this.fileInput.value = null;
this.fileInput.click();
}.bind(this), false);
}
};
Snapdrop.FileButtonBehavior = [Snapdrop.FileButtonBehaviorImpl, Snapdrop.FileSelectionBehavior];
</script>