From 6889b0eccc553e8a9465f1952d733f1d28f966a9 Mon Sep 17 00:00:00 2001 From: Ilker Kulgu Date: Thu, 13 Jul 2017 15:14:55 +0200 Subject: [PATCH] Add readAsBinaryString function to IE11 --- .../default/templates/layouts/default.html.ep | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/themes/default/templates/layouts/default.html.ep b/themes/default/templates/layouts/default.html.ep index faf03be..cae09a9 100644 --- a/themes/default/templates/layouts/default.html.ep +++ b/themes/default/templates/layouts/default.html.ep @@ -22,6 +22,32 @@ console.log(i18n.confirmExit); return i18n.confirmExit; } + + // Is the browser IE? + var isIE = /*@cc_on!@*/false || !!document.documentMode; + + // If the browser is IE, add readAsBinaryString function and store the data +if (isIE == true){ + if (FileReader.prototype.readAsBinaryString === undefined) { + FileReader.prototype.readAsBinaryString = function (fileData) { + var binary = ""; + var pt = this; + var reader = new FileReader(); + reader.onload = function (e) { + var bytes = new Uint8Array(reader.result); + var length = bytes.byteLength; + for (var i = 0; i < length; i++) { + binary += String.fromCharCode(bytes[i]); + } + //pt.result - readonly so assign content to another property + pt.content = binary; + $(pt).trigger('onloadend'); + } + reader.readAsArrayBuffer(fileData); + } + } +} + % end