From aa375315a2a9d990ece5873e17d76bec2d744559 Mon Sep 17 00:00:00 2001 From: jdescottes Date: Sun, 13 Jul 2014 01:01:33 +0200 Subject: [PATCH] Fixed mime type bug on Firefox --- src/css/settings-export.css | 1 + src/js/utils/PiskelFileUtils.js | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/css/settings-export.css b/src/css/settings-export.css index 83e5f499..8ad233c7 100644 --- a/src/css/settings-export.css +++ b/src/css/settings-export.css @@ -24,6 +24,7 @@ } .png-export-preview img { + max-height:32px; float: left; } diff --git a/src/js/utils/PiskelFileUtils.js b/src/js/utils/PiskelFileUtils.js index 60271b3c..901aa4b6 100644 --- a/src/js/utils/PiskelFileUtils.js +++ b/src/js/utils/PiskelFileUtils.js @@ -2,9 +2,17 @@ var ns = $.namespace('pskl.utils'); ns.PiskelFileUtils = { + /** + * Load a piskel from a piskel file. + * After deserialization is successful, the provided success callback will be called. + * Success callback is expected to handle 3 arguments : (piskel:Piskel, descriptor:PiskelDescriptor, fps:Number) + * @param {File} file the .piskel file to load + * @param {Function} onSuccess Called if the deserialization of the piskel is successful + * @param {Function} onError NOT USED YET + */ loadFromFile : function (file, onSuccess, onError) { pskl.utils.FileUtils.readFile(file, function (content) { - var rawPiskel = window.atob(content.replace('data:;base64,','')); + var rawPiskel = window.atob(content.replace(/data\:.*?\;base64\,/,'')); var serializedPiskel = JSON.parse(rawPiskel); var fps = serializedPiskel.piskel.fps; var descriptor = new pskl.model.piskel.Descriptor(serializedPiskel.piskel.name, serializedPiskel.piskel.description, true);