From 46babe7a480dc006a3c7246326c780f7539f817a Mon Sep 17 00:00:00 2001 From: macdonst Date: Wed, 17 Nov 2010 15:30:08 -0500 Subject: [PATCH] Calling correct events from FileWriter.abort() --- framework/assets/js/file.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/framework/assets/js/file.js b/framework/assets/js/file.js index 4a4c0d6f..4fdc75dd 100755 --- a/framework/assets/js/file.js +++ b/framework/assets/js/file.js @@ -161,6 +161,7 @@ FileReader.DONE = 2; */ FileReader.prototype.abort = function() { this.readyState = FileReader.DONE; + this.result = null; // set error var error = new FileError(); @@ -406,15 +407,29 @@ FileWriter.DONE = 2; * Abort writing file. */ FileWriter.prototype.abort = function() { - this.readyState = FileWriter.DONE; - + // set error + var error = new FileError(); + error.code = error.ABORT_ERR; + this.error = error; + + // If error callback + if (typeof this.onerror == "function") { + var evt = File._createEvent("error", this); + this.onerror(evt); + } // If abort callback if (typeof this.onabort == "function") { var evt = File._createEvent("abort", this); this.onabort(evt); } + + this.readyState = FileWriter.DONE; - // TODO: Anything else to do? Maybe sent to native? + // If load end callback + if (typeof this.onloadend == "function") { + var evt = File._createEvent("writeend", this); + this.onloadend(evt); + } }; FileWriter.prototype.writeAsText = function(file, text, bAppend) {