From 3b51d345cfe190130918a1316da37f50b3e85f3b Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Wed, 25 Nov 2015 13:23:13 -0500 Subject: [PATCH] Fix error when closing modals Helps with #64 #49 --- js/scratchx.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/js/scratchx.js b/js/scratchx.js index 0f206a2..4593c56 100644 --- a/js/scratchx.js +++ b/js/scratchx.js @@ -246,7 +246,11 @@ function showModal(templateId, data) { $(document).one("modal:exit page:show editor:extensionLoaded", function(e){ $("body").removeClass("modal-open"); - Scratch.FlashApp.ASobj.ASsetModalOverlay(false); + try { + Scratch.FlashApp.ASobj.ASsetModalOverlay(false); + } catch (e) { + // SWF not yet loaded + } $modal.remove(); }); @@ -258,7 +262,13 @@ $(document).keyup(function(e) { if (e.keyCode == 27) $(document).trigger("modal:exit"); }); -$(document).on("modal:exit", function(e){Scratch.FlashApp.ASobj.ASsetModalOverlay(false);}); +$(document).on("modal:exit", function(e){ + try { + Scratch.FlashApp.ASobj.ASsetModalOverlay(false); + } catch (e) { + // SWF not yet loaded + } +}); $(document).on('click', "[data-action='modal']", function(e){ /*