From 299d45bbb9548f0d12bfe8204e36b4b095db352f Mon Sep 17 00:00:00 2001 From: Jeremy Roberts Date: Fri, 20 Nov 2015 16:16:39 -0800 Subject: [PATCH] Update Editor.js --- source/Editor.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source/Editor.js b/source/Editor.js index e431358..d0656a5 100644 --- a/source/Editor.js +++ b/source/Editor.js @@ -57,12 +57,9 @@ function Squire ( doc, config ) { this.addEventListener( 'mouseup', this._updatePathOnEvent ); // Prevents redirecting dropped files, event can then be captured with editor.addEventListener in the host document - this.addEventListener('dragover', function(event) { - event.preventDefault(); - }); - this.addEventListener('drop', function(){ - event.preventDefault(); - }); + this.addEventListener('dragover', this.addEventListener('dragover', this.preventDefaultEvent); + this.addEventListener('drop', this.preventDefaultEvent); + this.addEventListener('drop', this.preventDefaultEvent); win.addEventListener( 'focus', this, false ); win.addEventListener( 'blur', this, false ); @@ -186,6 +183,10 @@ proto.getDocument = function () { return this._doc; }; +proto.preventDefaultEvent = function(event) { + event.preventDefault(); +}; + // --- Events --- // Subscribing to these events won't automatically add a listener to the