-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwizardstep.min.js
8 lines (8 loc) · 2.89 KB
/
wizardstep.min.js
1
2
3
4
5
6
7
8
/* ========================================================================
* Bootstrap Wizard Step v1.0
* http://johnitvn.github.io/bootstrap-wizard-step
* ========================================================================
* Copyright John Martin
* Licensed under Apache License 2.0 (https://github.com/johnitvn/bootstrap-wizard-step/blob/master/LICENSE)
* ======================================================================== */
$.fn.boostrapWizardStep=function(t){function e(e){var a={};"undefined"!=typeof $(e).attr("data-start")&&(a.startStep=parseInt($(e).attr("data-start"))),"undefined"!=typeof $(e).attr("data-content")&&(a.contentIdentifier=$(e).attr("data-content")),"undefined"!=typeof $(e).attr("data-tab")&&(a.tabIdentifier=$(e).attr("data-tab")),"undefined"!=typeof $(e).attr("data-previous")&&(a.btnPreviousIdentifier=$(e).attr("data-previous")),"undefined"!=typeof $(e).attr("data-next")&&(a.btnNextIdentifier=$(e).attr("data-next")),i=$.extend({},v,a,t),d=$(e).find(i.tabIdentifier),s=$(e).find(i.contentIdentifier),o=$(e).find(i.btnNextIdentifier),f=$(e).find(i.btnPreviousIdentifier),l=i.startStep,u=$(d).find("li>a")}function a(t){p=l,l=t,r(),n()}function n(){0===l?$(f).addClass("disabled"):$(f).removeClass("disabled")}function r(){for(var t=0;l>t;t++)$(u[t]).parent().removeClass("disabled active fade"),$(u[t]).parent().removeClass("active"),$(u[t]).parent().removeClass("fade"),$(s).find($(u[t]).attr("href")).removeClass("active");$(u[l]).parent().removeClass("disabled"),$(u[l]).parent().removeClass("fade"),$(u[l]).parent().addClass("active"),$(s).find($(u[l]).attr("href")).addClass("active");for(var t=l+1;t<u.length;t++)$(u[t]).parent().addClass("disabled"),$(u[t]).parent().removeClass("active"),$(u[t]).parent().removeClass("fade"),$(s).find($(u[t]).attr("href")).removeClass("active")}var i,d,s,o,f,l,u,p,v={startStep:0,onNextStep:null,onBackStep:null,onJumpBack:null,tabIdentifier:"#wizard-tab",contentIdentifier:"#wizard-content",btnNextIdentifier:"#next",btnPreviousIdentifier:"#previous"};return this.each(function(){var t=$(this);return $(this).hasClass("in-wizard")?!1:($(this).addClass("in-wizard"),e(t),$(d).on("click","li>a",function(e){var n=$(this).parent().index();if(!(n>=l)){var r=jQuery.Event("jumpback.bs.wizard");$(t).trigger(r,[n,l]),r.isDefaultPrevented()===!1&&(null===i.onJumpBack||null!==i.onJumpBack&&i.onJumpBack(n,l))&&a(n),e.preventDefault()}}),a(i.startStep),$(o).click(function(e){if(l!==u.length-1){var n=jQuery.Event("next.bs.wizard");$(t).trigger(n,[l]),n.isDefaultPrevented()===!1&&(null===i.onNextStep||null!==i.onNextStep&&i.onNextStep(l))&&a(l+1),e.preventDefault()}}),void $(f).click(function(e){if(0!==l){var n=jQuery.Event("previous.bs.wizard");$(t).trigger(n,[l]),n.isDefaultPrevented()===!1&&(null===i.onBackStep||null!==i.onBackStep&&i.onBackStep(l))&&a(l-1),e.preventDefault()}}))})},$(function(){$('[data-toggle="bootstrap-wizard-step"]').boostrapWizardStep()});