Last active
November 24, 2019 23:32
-
-
Save jimmyko/1250381a5d17017d67d8cf0b2875b5d1 to your computer and use it in GitHub Desktop.
HeiHiscoxFrance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -- in page multi step form. | |
var multiStepForm = { | |
_init: function() { | |
this.backBtn = null; | |
this.continueBtn = null; | |
this.previousBtn = null; | |
this.nextBtn = null; | |
this.forms = []; | |
this.current; | |
}, | |
addForm: function(elem) { | |
this.forms.push(elem); | |
}, | |
start: function() { | |
// do nothing when no forms defined. | |
if (this.forms.length == 0) { | |
return; | |
} | |
this._init(); | |
this.current = 0; | |
this.processButtons(); | |
}, | |
hideElem: function(elem) { | |
elem.hide(); | |
}, | |
showElem: function(elem) { | |
elem.show(); | |
}, | |
processButtons: function() { | |
if (current == 0) { | |
this.hideElem(this.previousBtn); | |
this.showElem(this.backBtn); | |
} | |
if (current > 0) { | |
this.showElem(this.previousBtn); | |
this.hideelem(this.backBtn); | |
} | |
if (current == this.forms.length - 1) { | |
this.hideElem(this.nextBtn); | |
this.showElem(this.continueBtn); | |
} | |
if (current < this.forms.length - 1) { | |
this.showElem(this.nextBtn); | |
this.hideElem(this.continueBtn); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment