text-input-behavior.html 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. <script>
  2. 'use strict';
  3. window.Chat = window.Chat || {};
  4. Chat.TextInputBehavior = {
  5. get textInput() {
  6. var textInput = Polymer.dom(this).querySelector('.textInput');
  7. if (!textInput) {
  8. textInput = document.createElement('input');
  9. textInput.type = 'file';
  10. textInput.multiple = 'true';
  11. textInput.className = 'textInput';
  12. textInput.style.position = 'fixed';
  13. textInput.style.top = '-10000px';
  14. textInput.style.left = '-10000px';
  15. textInput.style.opacity = 0;
  16. Polymer.dom(this).appendChild(textInput);
  17. }
  18. return textInput;
  19. },
  20. attached: function() {
  21. this.textInput.onchange = function() {
  22. var files = this.textInput.files;
  23. this.notifyFilesSelection(files);
  24. }.bind(this);
  25. },
  26. listeners: {
  27. 'tap': '_openDialog'
  28. },
  29. _openDialog: function() {
  30. this.textInput.value = null;
  31. this.textInput.click();
  32. }
  33. };
  34. </script>