From 639e31a2c071786b5b47b05bbc263ba4817b6f60 Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Tue, 16 Aug 2016 14:27:01 -0400 Subject: [PATCH] Added loading svg prior to init Resolves #70 --- PopcornEditor.js | 23 ++++++++++++++++++++++- PopcornEditor/resources/ring-alt.svg | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 PopcornEditor/resources/ring-alt.svg diff --git a/PopcornEditor.js b/PopcornEditor.js index c0609ab..0a09712 100644 --- a/PopcornEditor.js +++ b/PopcornEditor.js @@ -10,9 +10,30 @@ function PopcornEditor() { this.init = function (el, url) { var editor = (typeof el === 'string') ? document.getElementById(el) : el, - url = url || 'PopcornEditor/editor.html'; + url = url || 'PopcornEditor/editor.html', + loadingDiv = null, + loadingSpinner = null; window.addEventListener('message', onmessage); + this.listen('loaded', function () { + document.querySelector('#loading').remove(); + }); + + loadingDiv = document.createElement('div'); + loadingDiv.setAttribute('id', 'loading'); + loadingDiv.style.width = '100%'; + loadingDiv.style.height = '100%'; + loadingDiv.style.backgroundColor = 'white'; + loadingDiv.style.display = 'flex'; + loadingDiv.style.justifyContent = 'center'; + + loadingSpinner = document.createElement('img'); + loadingSpinner.setAttribute('class', 'loading-spinner'); + loadingSpinner.setAttribute('src', 'PopcornEditor/resources/ring-alt.svg'); + loadingSpinner.style.width = '30%'; + + loadingDiv.appendChild(loadingSpinner); + editor.appendChild(loadingDiv); this.iframe = document.createElement('iframe'), diff --git a/PopcornEditor/resources/ring-alt.svg b/PopcornEditor/resources/ring-alt.svg new file mode 100644 index 0000000..b1844c4 --- /dev/null +++ b/PopcornEditor/resources/ring-alt.svg @@ -0,0 +1 @@ + \ No newline at end of file