Skip to content

Commit

Permalink
Shield Tutorial is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
borjasalguero committed Jun 2, 2014
1 parent 66f3d58 commit 80e41e0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
20 changes: 14 additions & 6 deletions apps/ftu/js/tutorial.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
'translate(' + ((step - 1) * 100) + '%)';
}

function _setStep(value) {
function _setStep(value, callback) {
// If value is bigger than the max, show finish screen
var stepIndex = value - 1;
if (stepIndex >= stepsConfig.steps.length) {
Expand All @@ -43,8 +43,12 @@
stepData.l10nKey
);

if (typeof callback === 'function') {
dom.tutorialStepImage.querySelector('img').onload = callback;
}
// Update the image
dom.tutorialStepImage.querySelector('img').src = stepData.image;

_setProgressBarStep(currentStep);
}

Expand All @@ -62,7 +66,7 @@
// A configuration object.
config: null,

init: function(stepsKey) {
init: function(stepsKey, onLoaded) {
if (initialized) {
return;
}
Expand All @@ -72,7 +76,7 @@
}, this);

this.ensureConfig().then(function() {
if (stepsKey === undefined) {
if (!stepsKey) {
stepsKey = 'default';
}
if (!this.config) {
Expand All @@ -88,9 +92,13 @@

// Set the first step
currentStep = 1;
_setStep(currentStep);
// Show the panel
dom.tutorial.classList.add('show');
_setStep(currentStep, function onFirstResourceLoaded() {
if (typeof onLoaded === 'function') {
onLoaded();
}
// Show the panel
dom.tutorial.classList.add('show');
});
}.bind(this), function Tutorial_configLoadError(err) {
throw new Error('Tutorial config load error: ' + err.statusText);
});
Expand Down
8 changes: 5 additions & 3 deletions apps/ftu/js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,13 @@ var UIManager = {
this.letsGoButton.addEventListener('click', function() {
// Stop Wifi Manager
WifiManager.finish();
UIManager.activationScreen.classList.remove('show');
UIManager.finishScreen.classList.remove('show');

// Tutorial config is probably preloaded by now, but init could be
// async if it is still loading
Tutorial.init();
Tutorial.init(null, function onTutorialLoaded() {
UIManager.activationScreen.classList.remove('show');
UIManager.finishScreen.classList.remove('show');
});
});

// Enable sharing performance data (saving to settings)
Expand Down

0 comments on commit 80e41e0

Please sign in to comment.