Next button is now always focused when navigating through tutorial steps. [fixes SCI-719]

This commit is contained in:
Matej Zrimšek 2017-04-25 15:33:07 +02:00
parent a5cffd06f3
commit a6573bd508

View file

@ -90,9 +90,11 @@ function initPageTutorialSteps(pageFirstStepN, pageLastStepN, nextPagePath,
beforeCb(); beforeCb();
// Initialize tutorial for the current pages' steps // Initialize tutorial for the current pages' steps
var doneLabel = (pageLastStepN === TUTORIAL_STEPS_CNT) ? var isLastStep = pageLastStepN == TUTORIAL_STEPS_CNT;
'Start using sciNote' : 'End tutorial'; var doneLabel = isLastStep ? 'Start using sciNote' : 'End tutorial';
if (_.isUndefined(steps)) { if (_.isUndefined(steps)) {
// This approach (tutorial data separately in ERB) shouldn't be used,
// because it's buggy and inconvenient
introJs() introJs()
.setOptions({ .setOptions({
overlayOpacity: '0.2', overlayOpacity: '0.2',
@ -121,11 +123,13 @@ function initPageTutorialSteps(pageFirstStepN, pageLastStepN, nextPagePath,
}) })
.start(); .start();
} else { } else {
if (pageFirstStepN === pageLastStepN) { if (!isLastStep) {
// Only one page step, so add another fake one, so the back and next // Add extra fake step, so that next button on last step of current page
// buttons are added to the popup // gets focused. Also, if current page has only one step, this adds back
// and next buttons to the popup.
steps.push({}); steps.push({});
} }
introJs() introJs()
.setOptions({ .setOptions({
overlayOpacity: '0.2', overlayOpacity: '0.2',
@ -142,20 +146,16 @@ function initPageTutorialSteps(pageFirstStepN, pageLastStepN, nextPagePath,
tooltipClass: 'custom next-page-link', tooltipClass: 'custom next-page-link',
steps: steps steps: steps
}) })
.onexit(function() {
location.reload();
})
.oncomplete(function() {
location.reload();
})
.goToStep(stepNum - (pageFirstStepN - 1)) .goToStep(stepNum - (pageFirstStepN - 1))
.onexit(function() { .onexit(function() {
Cookies.remove('tutorial_data'); Cookies.remove('tutorial_data');
Cookies.remove('current_tutorial_step'); Cookies.remove('current_tutorial_step');
location.reload();
}) })
.oncomplete(function() { .oncomplete(function() {
Cookies.remove('tutorial_data'); Cookies.remove('tutorial_data');
Cookies.remove('current_tutorial_step'); Cookies.remove('current_tutorial_step');
location.reload();
}) })
.start(); .start();
} }