hide loader after language was updated

This commit is contained in:
Georg Fischer 2015-12-30 10:43:58 +01:00
parent 6828476874
commit a54a42950e
3 changed files with 25 additions and 12 deletions

2
.gitignore vendored
View File

@ -28,3 +28,5 @@ node_modules/
# production folder
production/
todo.md

View File

@ -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();
} );

View File

@ -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();
} );
}
}