mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-22 07:46:17 -04:00
Add text-input files
This commit is contained in:
parent
c8111e37bb
commit
3fb735e901
8 changed files with 201 additions and 27 deletions
34
app/elements/text-sharing/text-input-behavior.html
Normal file
34
app/elements/text-sharing/text-input-behavior.html
Normal file
|
@ -0,0 +1,34 @@
|
|||
<script>
|
||||
'use strict';
|
||||
window.Chat = window.Chat || {};
|
||||
Chat.TextInputBehavior = {
|
||||
get textInput() {
|
||||
var textInput = Polymer.dom(this).querySelector('.textInput');
|
||||
if (!textInput) {
|
||||
textInput = document.createElement('input');
|
||||
textInput.type = 'file';
|
||||
textInput.multiple = 'true';
|
||||
textInput.className = 'textInput';
|
||||
textInput.style.position = 'fixed';
|
||||
textInput.style.top = '-10000px';
|
||||
textInput.style.left = '-10000px';
|
||||
textInput.style.opacity = 0;
|
||||
Polymer.dom(this).appendChild(textInput);
|
||||
}
|
||||
return textInput;
|
||||
},
|
||||
attached: function() {
|
||||
this.textInput.onchange = function() {
|
||||
var files = this.textInput.files;
|
||||
this.notifyFilesSelection(files);
|
||||
}.bind(this);
|
||||
},
|
||||
listeners: {
|
||||
'tap': '_openDialog'
|
||||
},
|
||||
_openDialog: function() {
|
||||
this.textInput.value = null;
|
||||
this.textInput.click();
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue