diff --git a/dist/js/jquery.smartWizard.js b/dist/js/jquery.smartWizard.js index df0e293..5ee9856 100644 --- a/dist/js/jquery.smartWizard.js +++ b/dist/js/jquery.smartWizard.js @@ -219,7 +219,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = var idx = this._getURLHashIndex(); - idx = idx ? idx : this.options.selected; + idx = idx !== false ? idx : this.options.selected; var idxShowable = this._getShowable(idx - 1, 'forward'); @@ -356,7 +356,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = var idx = _this3._getURLHashIndex(); - if (idx && _this3._isShowable(_this3.steps.eq(idx))) { + if (idx !== false && _this3._isShowable(_this3.steps.eq(idx))) { e.preventDefault(); _this3._showStep(idx); diff --git a/dist/js/jquery.smartWizard.min.js b/dist/js/jquery.smartWizard.min.js index 30d5aa8..7de2031 100644 --- a/dist/js/jquery.smartWizard.min.js +++ b/dist/js/jquery.smartWizard.min.js @@ -9,4 +9,4 @@ * Licensed under the terms of the MIT License * https://github.com/techlab/jquery-smartwizard/blob/master/LICENSE */ -!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"===("undefined"==typeof module?"undefined":_typeof(module))&&module.exports?module.exports=function(t,s){return void 0===s&&(s="undefined"!=typeof window?require("jquery"):require("jquery")(t)),e(s),s}:e(jQuery)}(function(l){var i={selected:0,theme:"basic",justified:!0,autoAdjustHeight:!0,backButtonSupport:!0,enableUrlHash:!0,transition:{animation:"none",speed:"400",easing:"",prefixCss:"",fwdShowCss:"",fwdHideCss:"",bckShowCss:"",bckHideCss:""},toolbar:{position:"bottom",showNextButton:!0,showPreviousButton:!0,extraHtml:""},anchor:{enableNavigation:!0,enableNavigationAlways:!1,enableDoneState:!0,markPreviousStepsAsDone:!0,unDoneOnBackNavigation:!1,enableDoneStateNavigation:!0},keyboard:{keyNavigation:!0,keyLeft:[37],keyRight:[39]},lang:{next:"Next",previous:"Previous"},style:{mainCss:"sw",navCss:"nav",navLinkCss:"nav-link",contentCss:"tab-content",contentPanelCss:"tab-pane",themePrefixCss:"sw-theme-",anchorDefaultCss:"default",anchorDoneCss:"done",anchorActiveCss:"active",anchorDisabledCss:"disabled",anchorHiddenCss:"hidden",anchorErrorCss:"error",anchorWarningCss:"warning",justifiedCss:"sw-justified",btnCss:"sw-btn",btnNextCss:"sw-btn-next",btnPrevCss:"sw-btn-prev",loaderCss:"sw-loading",progressCss:"progress",progressBarCss:"progress-bar",toolbarCss:"toolbar",toolbarPrefixCss:"toolbar-"},disabledSteps:[],errorSteps:[],warningSteps:[],hiddenSteps:[],getContent:null},e=function(){function n(t,s){var e=this;_classCallCheck(this,n),this.options=l.extend(!0,{},i,s),this.main=l(t),this.nav=this._getFirstDescendant("."+this.options.style.navCss),this.container=this._getFirstDescendant("."+this.options.style.contentCss),this.steps=this.nav.find("."+this.options.style.navLinkCss),this.pages=this.container.children("."+this.options.style.contentPanelCss),this.progressbar=this.main.find("."+this.options.style.progressCss),this.dir=this._getDir(),this.current_index=-1,this.is_init=!1,this._init(),setTimeout(function(){e._load()},0)}return _createClass(n,[{key:"_init",value:function(){if(this._setElements(),this._setToolbar(),!0===this.is_init)return!0;this._setEvents(),this.is_init=!0,this._triggerEvent("initialized")}},{key:"_load",value:function(){this.pages.hide(),this.steps.removeClass([this.options.style.anchorDoneCss,this.options.style.anchorActiveCss]),this.current_index=-1;var t=(t=this._getURLHashIndex())||this.options.selected,s=this._getShowable(t-1,"forward");0<(t=null===s&&0").addClass("sw-toolbar-elm "+this.options.style.toolbarCss+" "+this.options.style.toolbarPrefixCss+t).attr("role","toolbar"),e=!1!==this.options.toolbar.showNextButton?l("").text(this.options.lang.next).addClass("btn "+this.options.style.btnNextCss+" "+this.options.style.btnCss).attr("type","button"):null,n=!1!==this.options.toolbar.showPreviousButton?l("").text(this.options.lang.previous).addClass("btn "+this.options.style.btnPrevCss+" "+this.options.style.btnCss).attr("type","button"):null;return s.append(n,e,this.options.toolbar.extraHtml)}},{key:"_navigate",value:function(t){this._showStep(this._getShowable(this.current_index,t))}},{key:"_showStep",value:function(n){var i=this;if(-1===n||null===n)return!1;if(n==this.current_index)return!1;if(!this.steps.eq(n))return!1;if(!this._isEnabled(this.steps.eq(n)))return!1;var o=this._getStepDirection(n);if(-1!==this.current_index&&!1===this._triggerEvent("leaveStep",[this._getStepAnchor(this.current_index),this.current_index,n,o]))return!1;this._loadContent(n,function(){var t=i._getStepAnchor(n);i._setURLHash(t.attr("href")),i._setAnchor(n);var s=i._getStepPage(i.current_index),e=i._getStepPage(n);i._transit(e,s,o,function(){i._fixHeight(n),i._triggerEvent("showStep",[t,n,o,i._getStepPosition(n)])}),i.current_index=n,i._setButtons(n),i._setProgressbar(n)})}},{key:"_getShowable",value:function(e,n){var i=this,o=null;return("prev"==n?l(this.steps.slice(0,e).get().reverse()):this.steps.slice(e+1)).each(function(t,s){if(i._isEnabled(l(s)))return o="prev"==n?e-(t+1):t+e+1,!1}),o}},{key:"_isShowable",value:function(t){if(!this._isEnabled(t))return!1;var s=t.hasClass(this.options.style.anchorDoneCss);return(!1!==this.options.anchor.enableDoneStateNavigation||!s)&&!(!1===this.options.anchor.enableNavigationAlways&&!s)}},{key:"_isEnabled",value:function(t){return!t.hasClass(this.options.style.anchorDisabledCss)&&!t.hasClass(this.options.style.anchorHiddenCss)}},{key:"_getStepDirection",value:function(t){return this.current_index").addClass("sw-toolbar-elm "+this.options.style.toolbarCss+" "+this.options.style.toolbarPrefixCss+t).attr("role","toolbar"),e=!1!==this.options.toolbar.showNextButton?l("").text(this.options.lang.next).addClass("btn "+this.options.style.btnNextCss+" "+this.options.style.btnCss).attr("type","button"):null,n=!1!==this.options.toolbar.showPreviousButton?l("").text(this.options.lang.previous).addClass("btn "+this.options.style.btnPrevCss+" "+this.options.style.btnCss).attr("type","button"):null;return s.append(n,e,this.options.toolbar.extraHtml)}},{key:"_navigate",value:function(t){this._showStep(this._getShowable(this.current_index,t))}},{key:"_showStep",value:function(n){var i=this;if(-1===n||null===n)return!1;if(n==this.current_index)return!1;if(!this.steps.eq(n))return!1;if(!this._isEnabled(this.steps.eq(n)))return!1;var o=this._getStepDirection(n);if(-1!==this.current_index&&!1===this._triggerEvent("leaveStep",[this._getStepAnchor(this.current_index),this.current_index,n,o]))return!1;this._loadContent(n,function(){var t=i._getStepAnchor(n);i._setURLHash(t.attr("href")),i._setAnchor(n);var s=i._getStepPage(i.current_index),e=i._getStepPage(n);i._transit(e,s,o,function(){i._fixHeight(n),i._triggerEvent("showStep",[t,n,o,i._getStepPosition(n)])}),i.current_index=n,i._setButtons(n),i._setProgressbar(n)})}},{key:"_getShowable",value:function(e,n){var i=this,o=null;return("prev"==n?l(this.steps.slice(0,e).get().reverse()):this.steps.slice(e+1)).each(function(t,s){if(i._isEnabled(l(s)))return o="prev"==n?e-(t+1):t+e+1,!1}),o}},{key:"_isShowable",value:function(t){if(!this._isEnabled(t))return!1;var s=t.hasClass(this.options.style.anchorDoneCss);return(!1!==this.options.anchor.enableDoneStateNavigation||!s)&&!(!1===this.options.anchor.enableNavigationAlways&&!s)}},{key:"_isEnabled",value:function(t){return!t.hasClass(this.options.style.anchorDisabledCss)&&!t.hasClass(this.options.style.anchorHiddenCss)}},{key:"_getStepDirection",value:function(t){return this.current_index 0) ? this._getShowable(-1, 'forward') : idxShowable; @@ -296,7 +296,7 @@ return; } const idx = this._getURLHashIndex(); - if (idx && this._isShowable(this.steps.eq(idx))) { + if (idx !== false && this._isShowable(this.steps.eq(idx))) { e.preventDefault(); this._showStep(idx); }