jam-cloud/web/app/assets/javascripts/wizard/loopback/loopback_wizard.js

105 lines
2.3 KiB
JavaScript

(function (context, $) {
"use strict";
context.JK = context.JK || {};
context.JK.LoopbackWizard = function (app) {
var EVENTS = context.JK.EVENTS;
var logger = context.JK.logger;
var $dialog = null;
var wizard = null;
var $wizardSteps = null;
var $self = $(this);
var step1 = new context.JK.StepLoopbackIntro(app, this);
var step2 = new context.JK.StepLoopbackTest(app, this);
var step3 = new context.JK.StepLoopbackResult(app, this);
var STEPS = {
0: step1,
1: step2,
2: step3
}
function beforeShow(args) {
wizard.onBeforeShow(args);
}
function afterHide() {
wizard.onAfterHide();
}
function closeDialog() {
wizard.onCloseDialog();
app.layout.closeDialog('loopback-wizard');
}
function setNextState(enabled) {
wizard.setNextState(enabled);
}
function setBackState(enabled) {
wizard.setBackState(enabled);
}
function onStepChanged(e, data) {
var step = wizard.getCurrentStep();
var $currentWizardStep = wizard.getCurrentWizardStep();
}
function onCanceled() {
closeDialog();
return false;
}
function onClosed() {
closeDialog();
return false;
}
function getGearTest() {
return step2.getGearTest();
}
function events() {
$(wizard).on('step_changed', onStepChanged);
$(wizard).on('wizard_cancel', onCanceled);
$(wizard).on('wizard_close', onClosed);
}
function getDialog() {
return $dialog;
}
function initialize() {
var dialogBindings = { beforeShow: beforeShow, afterHide: afterHide };
app.bindDialog('loopback-wizard', dialogBindings);
$dialog = $('#loopback-wizard-dialog');
$wizardSteps = $dialog.find('.wizard-step');
step1.initialize($wizardSteps.filter($('[layout-wizard-step=0]')));
step2.initialize($wizardSteps.filter($('[layout-wizard-step=1]')));
wizard = new context.JK.Wizard(app);
wizard.initialize($dialog, $wizardSteps, STEPS);
events();
}
this.setNextState = setNextState;
this.setBackState = setBackState;
this.initialize = initialize;
this.getGearTest = getGearTest;
this.getDialog = getDialog;
return this;
}
})(window, jQuery);