diff --git a/.gitignore b/.gitignore index 2f0104d..a8f2b7c 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,6 @@ $RECYCLE.BIN/ node_modules/ # production folder -production/ \ No newline at end of file +production/ + +todo.md \ No newline at end of file diff --git a/scripts/glitcher.js b/scripts/glitcher.js index 05b1442..3906cc5 100644 --- a/scripts/glitcher.js +++ b/scripts/glitcher.js @@ -64,6 +64,8 @@ require( [ LocalisationModel, localforage ) { + var wasAppLoadComplete = false; + var imageModel = ImageModel(); var glitchModel = GlitchModel(); var shareModel = ShareModel(); @@ -107,12 +109,6 @@ require( [ controlsView.loadInitialValues(); loadInitialItem(); } - - document.documentElement.classList.add( 'is-loaded' ); - - setTimeout( function () { - document.documentElement.classList.remove( 'is-loading' ); - }, 10 ); } // hooks up all messaging between items @@ -218,7 +214,9 @@ require( [ .on( 'error', indicatorView.showError ); localisationModel - .on( 'error', indicatorView.showError ); + .on( 'error', indicatorView.showError ) + .on( 'error', hideAppLoader ) + .on( 'update', hideAppLoader ); } function addCSSClasses () { @@ -327,5 +325,18 @@ require( [ } } + function hideAppLoader () { + if ( ! wasAppLoadComplete ) { + requestAnimationFrame ( function () { + wasAppLoadComplete = true; + document.documentElement.classList.add( 'is-loaded' ); + + setTimeout( function () { + document.documentElement.classList.remove( 'is-loading' ); + }, 10 ); + } ); + } + } + init(); } ); \ No newline at end of file diff --git a/scripts/models/localisationmodel.js b/scripts/models/localisationmodel.js index e50065a..502ba48 100644 --- a/scripts/models/localisationmodel.js +++ b/scripts/models/localisationmodel.js @@ -9,7 +9,7 @@ define( var self = this; - var publishers = addPublishers( self, 'error' ); + var publishers = addPublishers( self, 'update', 'error' ); var textElData = [ ]; var texts = ''; @@ -37,7 +37,6 @@ define( // if this is the first language to load, that's really bad. languageWasLoaded = true; publishers.error.dispatch( 'I\'m really sorry. I failed to load the language file for ' + languageName + '. This is a serious error that makes the app very hard to use. Maybe you can try reloading?' ); - }, success: function ( res ) { languageLoaded( languageName, res ); @@ -74,11 +73,12 @@ define( item.wasUpdated = true; } - } - else { + } else { textElData.splice( i, 1 ); } } + + publishers.update.dispatch(); } ); } }