2015-12-19 01:18:02 +01:00
|
|
|
<link rel="import" href="file-selection-behavior.html">
|
|
|
|
<script>
|
|
|
|
'use strict';
|
|
|
|
window.Chat = window.Chat || {};
|
|
|
|
Chat.FileButtonBehaviorImpl = {
|
|
|
|
get fileInput() {
|
|
|
|
var fileInput = Polymer.dom(this).querySelector('.fileInput');
|
|
|
|
if (!fileInput) {
|
|
|
|
fileInput = document.createElement('input');
|
|
|
|
fileInput.type = 'file';
|
2015-12-23 13:57:13 +01:00
|
|
|
fileInput.multiple = 'true';
|
2015-12-19 01:18:02 +01:00
|
|
|
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);
|
|
|
|
},
|
|
|
|
listeners: {
|
|
|
|
'tap': '_openDialog'
|
|
|
|
},
|
|
|
|
_openDialog: function() {
|
2015-12-28 05:59:50 +01:00
|
|
|
this.fileInput.value = null;
|
2015-12-19 01:18:02 +01:00
|
|
|
this.fileInput.click();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
Chat.FileButtonBehavior = [Chat.FileButtonBehaviorImpl, Chat.FileSelectionBehavior];
|
|
|
|
</script>
|