import EventQueue from './utils/eventQueue';
import * as utils from './utils/utils';

export default class FileInput {
	
	constructor(inputEl){
		this.$el = utils.getEl(inputEl);
		this.onFileChanged = new EventQueue();

		this.initEvents();

	}

	initEvents(){

		this.$el.addEventListener('change', 
			(e) => { 
				this.onFileChanged.run({ file:this.$el.files[0] }) ;
			});

	}

	


}
@@ -137,16 +137,17 @@
 putEl)%7B%0A
+%0A
 %09%09this.$
@@ -218,173 +218,840 @@
 ();%0A
-%0A%09%09this.initEvents();%0A%0A%09%7D%0A%0A%09initEvents()%7B%0A%0A%09%09this.$el.addEventListener('change', %0A%09%09%09(e) =%3E %7B %0A%09%09%09%09this.onFileChanged.run(%7B file:this.$el.files%5B0%5D %7D) ;%0A%09%09%09%7D);
+%09%09this.onWrongFileType = new EventQueue();%0A%0A%09%09this.allowedFileTypes = %5B%0A%09%09%09'image/jpeg',%0A%09%09%09'image/png',%0A%09%09%09'image/svg+xml'%0A%09%09%5D%0A%0A%09%09this.initEvents();%0A%0A%09%7D%0A%0A%09initEvents()%7B%0A%0A%09%09this.$el.addEventListener('change', %0A%09%09%09(e) =%3E %7B%0A%0A%09%09%09%09var file = this.$el.files%5B0%5D;%0A%0A%09%09%09%09if( this.isFileAllowed(file) )%7B%0A%09%09%09%09%09this.onFileChanged.run(%7B file: file %7D) ;%0A%09%09%09%09%7Delse%7B%0A%09%09%09%09%09this.onWrongFileType.run(%7B type: this.getFileType(file)%7D );%0A%09%09%09%09%7D%0A%09%09%09%7D);%0A%0A%09%7D%0A%0A%09getFileType(file)%7B%0A%09%09if( file.type.length === 0)%7B%0A%09%09%09var nameType = file.name.substr(file.name.lastIndexOf('.') + 1);%0A%09%09%09return nameType;%0A%09%09%7Delse%7B%0A%09%09%09return file.type;%0A%09%09%7D%0A%09%7D%0A%0A%09isFileAllowed(file)%7B%0A%0A%09%09for( let allowedType of this.allowedFileTypes )%7B%0A%0A%09%09%09if (allowedType === this.getFileType(file) %7C%7C allowedType.indexOf(this.getFileType(file)) %3E= 0)%7B%0A%09%09%09%09return true;%0A%09%09%09%7D
 %0A%0A
+%09
 %09%7D%0A%0A%09
-%0A
+%09return false;%0A%0A%09%7D
 %0A%0A%7D

add file type check