Skip to content

Commit

Permalink
goNextTimeout and onStepRender
Browse files Browse the repository at this point in the history
  • Loading branch information
Karen committed May 17, 2017
1 parent ef3279a commit 721f7af
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
2 changes: 1 addition & 1 deletion classes/Step.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class Step {
this.template = params.template || ''
this.ignore_progress = params.ignore_progress || false
this.from = null
this._data = {}
this._data = params.data || {}
params.interceptors = params.interceptors || {}
this.interceptors = {
beforeRender: params.interceptors.beforeRender || this.methods.beforeRender || function () {
Expand Down
21 changes: 17 additions & 4 deletions classes/StepSystem.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* StepSystem v1.0.0
* Last update: 15.05.2017
* Last update: 17.05.2017
*
* Dependencies: jQuery
*
Expand All @@ -11,15 +11,18 @@ export class StepSystem {
/**
* @param {jQuery element} container
*/
constructor (container) {
constructor (params) {
this._steps = {}
this._current_step = null
this._container = container
this._container = params.container || $('.step-system')
this._step_container = params.step_class || '.step'
this._next_timeout = null
this.steps_past = []
this.progress = 0
this.commonHandlers = function () {}
this.onFinish = function () {}
this.onProgress = function () {}
this.onStepRender = function () {}
}

/**
Expand Down Expand Up @@ -59,7 +62,9 @@ export class StepSystem {
if (_br.onError) _br.onError()
return this
}
this.container.find('.step').html(step.template || this._container.find(`#${step.name}`).html())
this.container.find(this._step_container).html(step.template || this._container.find(`#${step.name}`).html())
this.container.find(this._step_container).attr('data-name', step.name)
this.onStepRender(step)
if (step.methods.onRender) {
step.methods.onRender()
}
Expand All @@ -80,6 +85,14 @@ export class StepSystem {
this.onProgress(this.progress)
}

goNextTimeout (timeout = 300) {
const $this = this
clearTimeout(this._next_timeout)
this._next_timeout = setTimeout(function () {
$this.goNext()
}, timeout)
}

goNext () {
let curr_step = this.current_step || {}
let next_step = curr_step.next || null
Expand Down
26 changes: 21 additions & 5 deletions example/dist/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 721f7af

Please sign in to comment.