file-selection-behavior.html 566 B

12345678910111213141516171819202122
  1. <script>
  2. 'use strict';
  3. window.Chat = window.Chat || {};
  4. Chat.FileSelectionBehavior = {
  5. notifyFilesSelection: function(files) {
  6. if (!files) {
  7. console.log('no files selected...');
  8. return;
  9. }
  10. this._fileSelected(files[0]); //single select
  11. //files.forEach(this._fileSelected.bind(this)); //multi-select
  12. },
  13. _fileSelected: function(file) {
  14. if (file) {
  15. this.fire('file-selected', {
  16. file: file,
  17. name: file.name
  18. });
  19. }
  20. }
  21. };
  22. </script>