Add text-input files

This commit is contained in:
Paul Szymanski 2016-01-02 02:26:07 +01:00 committed by Robin Linus
parent c8111e37bb
commit 3fb735e901
8 changed files with 201 additions and 27 deletions

View 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>