-
Notifications
You must be signed in to change notification settings - Fork 1
/
formToWizard.min.js
1 lines (1 loc) · 1.34 KB
/
formToWizard.min.js
1
function d(a){console.log(a)}(function(a){a.fn.formToWizard=function(b){function c(c,d,e,f){var g=a("p.form-wizard-buttons",a("div.step"+c,f));a("<a />").text(e).addClass("form-wizard-button").appendTo(g).attr("href","#").click(function(e){e.preventDefault();a("div.step"+c,f).hide();a("div.step"+d,f).show();a("li.stepDesc"+c,f).removeClass("current");a("li.stepDesc"+d,f).addClass("current");if(b.hideSubmit){if(d==f.data("wizard-steps-count")-1){a("input[type='submit']",f).show()}else{a("input[type='submit']",f).hide()}}})}b=a.extend({hideSubmit:true},b);this.each(function(){var d=a(this);var e=d.find("fieldset");var f=e.size();if(f<2){console.log("You should define almost 2 legends, please reffer documentation");return}d.data("wizard-steps-count",f);d.addClass("form-wizard");if(b.hideSubmit){a("input[type='submit']",d).hide()}a(d).prepend("<ul class='steps'></ul>");e.each(function(b){a(this).wrap("<div class='step"+b+" step'></div>");a(this).parent().append("<p class='form-wizard-buttons'></p>").hide();var e="";if(a("legend",this).length>0){e=a("legend",this).text()}a("ul.steps",d).append("<li class='stepDesc"+b+" step-description'>Step "+(b+1)+"<span>"+e+"</span></li>");if(b==0){a(this).parent().show();a("li.stepDesc0",d).addClass("current");c(b,b+1,"Next",d)}else if(b==f-1){c(b,b-1,"Prev",d)}else{c(b,b-1,"Prev",d);c(b,b+1,"Next",d)}})})}})(jQuery)