diff --git a/file-api/text-editor/js/main.js b/file-api/text-editor/js/main.js index f9f91f0..428eb4d 100644 --- a/file-api/text-editor/js/main.js +++ b/file-api/text-editor/js/main.js @@ -18,37 +18,17 @@ class TextEditor { registerEvents() { const save = throttle( this.save.bind( this ), 1000 ); this.contentContainer.addEventListener( 'input', save ); - this.container.addEventListener( 'dragover', this.showHint.bind( this )); - this.container.addEventListener( 'drop', this.loadFile.bind( this )); } loadFile( e ) { - e.preventDefault(); - const [ file ] = e.dataTransfer.files, - { type, name } = file; - if ( type !== 'text/plain' ) { - return; - } - this.readFile( file ) - .then( e => this.load( e.target.result )); - this.setFilename( name ); - this.hideHint(); } readFile( file ) { - const reader = new FileReader, - promise = new Promise( resolve => - reader.addEventListener( 'load', resolve )); - reader.readAsText(file); - return promise; } setFilename( filename ) { this.filenameContainer.textContent = filename; } showHint( e ) { - e.preventDefault(); - this.hintContainer.classList.add( 'text-editor__hint_visible' ); } hideHint() { - this.hintContainer.classList.remove( 'text-editor__hint_visible' ); } load( value ) { this.contentContainer.value = value || '';