smartwizard
Version:
A modern and accessible step wizard plugin for jQuery
16 lines (15 loc) • 22.5 kB
JavaScript
/*!
* jQuery SmartWizard v7.1.2
* A modern and accessible step wizard plugin for jQuery
* http://www.techlaboratory.net/jquery-smartwizard
*
* See the next-generation [SmartWizard](https://github.com/techlab/smart-wizard)
* A framework-agnostic wizard component with React & Vue support.
*
* Created by Dipu Raj (https://github.com/techlab)
*
* Licensed under the terms of the MIT License - Free for personal and open-source projects.
* For commercial use, please purchase a commercial license: https://techlaboratory.net/jquery-smartwizard#license
*/
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=".sw",e={CLICK:`click${t}`,KEYUP:`keyup${t}`,HASHCHANGE:`hashchange${t}`,SCROLLEND:`scrollend${t}`,WHEEL:`wheel${t}`,RESIZE:`resize${t}`,ANIMATIONEND:`animationend${t}`,ANIMATIONCANCEL:`animationcancel${t}`,TOUCHSTART:`touchstart${t}`,TOUCHEND:`touchend${t}`,INITIALIZED:`initialized${t}`,LOADED:`loaded${t}`,LEAVESTEP:`leave${t}`,SHOWSTEP:`shown${t}`},s={Forward:"forward",Backward:"backward"},i={LeftToRight:"ltr",RightToLeft:"rtl"},o={First:"first",Middle:"middle",Last:"last"},n={None:"none",Top:"top",Bottom:"bottom",Both:"both"},r={PROGRESS_PERCENTAGE:"--sw-progress-percentage"},a={TOOLBAR_ELM:".sw-toolbar-elm"},l={THEME:"data-theme"},h={initialStep:0,theme:"basic",displayMode:"auto",behavior:{autoHeight:!0,useUrlHash:!1,supportBrowserHistory:!1},navigation:{enabled:!0,alwaysClickable:!1,completed:{enabled:!0,completeAllPreviousSteps:!0,clearOnBack:!1,clickable:!0}},transition:{effect:"default",speed:400,easing:"",css:{prefix:"",forward:{show:"",hide:""},backward:{show:"",hide:""}}},toolbar:{position:"bottom",buttons:{showNext:!0,showPrevious:!0},extraElements:""},keyboardNavigation:{enabled:!0,keys:{left:["ArrowLeft"],right:["ArrowRight"]}},localization:{buttons:{next:"Next",previous:"Previous"}},styles:{baseClass:"sw",navigation:{container:"sw-nav",link:"sw-nav-link"},content:{container:"sw-tab-content",panel:"sw-tab-pane"},themePrefix:"sw-theme-",anchorStates:{default:"default",completed:"completed",active:"active",disabled:"disabled",hidden:"hidden",error:"error",warning:"warning"},buttons:{base:"sw-btn",next:"sw-btn-next",previous:"sw-btn-prev",reset:"sw-btn-reset",scroll:"sw-nav-scroll-btn",scrollNext:"sw-nav-scroll-btn-right",scrollPrevious:"sw-nav-scroll-btn-left"},loader:"sw-loading",progressBar:{container:"sw-progress",bar:"sw-progress-bar"},toolbar:{base:"sw-toolbar",prefix:"sw-toolbar-"}},stepStates:{completed:[],disabled:[],hidden:[],error:[],warning:[]},swipeNavigation:{enabled:!1,threshold:50},scrollToView:!0,contentLoader:null,contentSanitize:!0};function c(){return window.location.hash||""}function p(t){history.pushState(null,"",t)}function d(t){return"function"==typeof t}function u(t,e){const s=t=>{if(null===t||"object"!=typeof t)return t;if(Array.isArray(t))return t.map(s);const e={};for(const i of Object.keys(t))e[i]=s(t[i]);return e},i=s(t);for(const t of Object.keys(e)){const o=i[t],n=e[t];null===n||"object"!=typeof n||Array.isArray(n)||null===o||"object"!=typeof o||Array.isArray(o)?void 0!==n&&(i[t]=s(n)):i[t]=u(o,n)}return i}function f(t,e){const s=t.children(e);if(s.length>0)return s;let i=null;if(t.children().each(((t,s)=>{const o=$(s).children(e);if(o.length>0)return i=o,!1})),i)return i;throw new Error(`Element not found ${e}`)}function g(t){return t.prop("dir")||document.documentElement.dir||""}function b(t,e){t.prop("dir",e)}function S(t,e,s=[]){const i=$.Event(e);return t.trigger(i,s),!i.isDefaultPrevented()}function v(...t){d($.fn.finish)&&$(t).finish()}const w={default:function(t,e,s,i,o){e&&e.hide(),t.show(),o()},fade:function(t,e,s,i,o){if(!d(t.fadeOut))return void w.default(t,e,s,i,o);const{speed:n,easing:r}=i.getOptions().transition,a=()=>t.fadeIn(n,r,o);e?e.fadeOut(n,r,a):a()},slideHorizontal:function(t,e,s,i,o){if(!d(t.animate))return void w.default(t,e,s,i,o);const{speed:n,easing:r}=i.getOptions().transition,a=i.getWidth();-1==i.getCurrentIndex()&&i.resetHeight();const l=(t,e,s,i)=>{t.css({position:"absolute",left:e}).show().stop(!0).animate({left:s},n,r,i)};if(e){const t=e.css(["position","left"]);l(e,0,a*("backward"==s?1:-1),(()=>{e.hide().css(t)}))}const h=t.css(["position"]);l(t,a*("backward"==s?-2:1),0,(()=>{t.css(h),o()}))},slideVertical:function(t,e,s,i,o){if(!d(t.animate))return void w.default(t,e,s,i,o);const{speed:n,easing:r}=i.getOptions().transition,a=i.getWidth();-1==i.getCurrentIndex()&&i.resetHeight();const l=(t,e,s,i)=>{t.css({position:"absolute",top:e}).show().stop(!0).animate({top:s},n,r,i)};if(e){const t=e.css(["position","top"]);l(e,0,a*("backward"==s?1:-1),(()=>{e.hide().css(t)}))}const h=t.css(["position"]);l(t,a*("backward"==s?-2:1),0,(()=>{t.css(h),o()}))},slideSwing:function(t,e,s,i,o){if(!d(t.slideDown))return void w.default(t,e,s,i,o);const{speed:n,easing:r}=i.getOptions().transition,a=()=>t.slideDown(n,r,o);e?e.slideUp(n,r,a):a()},css:function(t,s,i,o,n){const{prefix:r,forward:a,backward:l}=o.getOptions().transition.css;if(0==a.show.length||0==l.show.length)return void w.default(t,s,i,o,n);const h=(t,s,i)=>{if(!s||0==s.length)return void i();t.show();let o=!1;const n=e=>{o||(o=!0,t.removeClass(s),i(e))};t.addClass(s).one(e.ANIMATIONEND,(()=>n())).one(e.ANIMATIONCANCEL,(()=>n("cancel")))},c=()=>{const e=r+" "+("backward"==i?l.show:a.show);h(t,e,(()=>{n()}))};if(s){const t=r+" "+("backward"==i?l.hide:a.hide);h(s,t,(()=>{s.hide(),c()}))}else c()}};class m{constructor(t,e){Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"main",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"nav",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"steps",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"progressbar",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contentDirection",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isInitialized",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"currentStepIndex",{enumerable:!0,configurable:!0,writable:!0,value:-1}),Object.defineProperty(this,"touchStartX",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"touchStartY",{enumerable:!0,configurable:!0,writable:!0,value:0}),this.options=u(h,e??{}),this.main=$(t),this.setup(),this.init(),requestAnimationFrame((()=>{this.load()}))}setup(){this.container=f(this.main,"."+this.options.styles.content.container),this.nav=f(this.main,"."+this.options.styles.navigation.container),this.steps=this.nav.find("."+this.options.styles.navigation.link),this.pages=this.container.children("."+this.options.styles.content.panel),this.progressbar=this.main.find("."+this.options.styles.progressBar.container),this.contentDirection=g(this.main),this.contentDirection??b(this.main,this.contentDirection),this.currentStepIndex=-1,this.isInitialized=!1}init(){this.setElements(),this.setToolbar(),this.setNav(),!0!==this.isInitialized&&(this.setEvents(),S(this.main,e.INITIALIZED),this.isInitialized=!0)}load(){this.pages.hide(),this.currentStepIndex=-1;const t=this.getInitialStep();t>0&&this.options.navigation.completed.enabled&&this.options.navigation.completed.completeAllPreviousSteps&&this.steps.slice(0,t).addClass(this.options.styles.anchorStates.completed),this.showStep(t),S(this.main,e.LOADED)}getInitialStep(){let t=null;if(this.options.behavior.useUrlHash){const e=c();t=e?this.getStepByAnchor(e):null}const e=t??this.options.initialStep;return this.getShowable(e-1,s.Forward)??(e>0?this.getShowable(-1,s.Forward)??0:e)}setElements(){this.main.removeClass(((t,e)=>(e.match(new RegExp("(^|\\s)"+this.options.styles.themePrefix+"\\S+","g"))||[]).join(" "))).addClass(this.options.styles.baseClass+" "+this.options.styles.themePrefix+this.options.theme),this.setDisplayMode()}setDisplayMode(){const t=this.options.displayMode;if(this.main.removeAttr(l.THEME),"none"!==t)if("dark"===t)this.main.attr(l.THEME,"dark");else if("light"===t)this.main.attr(l.THEME,"light");else if("auto"===t){const t=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(this.main.attr(l.THEME,t?"dark":"light"),window.matchMedia){const t=window.matchMedia("(prefers-color-scheme: dark)"),e=t=>{this.main.attr(l.THEME,t.matches?"dark":"light")};t.addEventListener?t.addEventListener("change",e):t.addListener&&t.addListener(e)}}}setEvents(){this.steps.on(e.CLICK,(t=>{if(t.preventDefault(),!0!==this.options.navigation.enabled)return;const e=$(t.currentTarget);this.isShowable(e)&&this.showStep(this.steps.index(e))})),this.main.on(e.CLICK,(t=>{const e=$(t.target);e.hasClass(this.options.styles.buttons.next)?(t.preventDefault(),this.navigate(s.Forward)):e.hasClass(this.options.styles.buttons.previous)?(t.preventDefault(),this.navigate(s.Backward)):e.hasClass(this.options.styles.buttons.scrollNext)?(t.preventDefault(),this.scrollAnchor("right")):e.hasClass(this.options.styles.buttons.scrollPrevious)&&(t.preventDefault(),this.scrollAnchor("left"))})),$(this.nav).on(e.SCROLLEND,(()=>{this.scrollCheck()})),this.nav.on(e.WHEEL,(t=>{const e=this.nav.get(0);if(!e||e.scrollWidth<=e.clientWidth)return;const s=t.originalEvent;s&&0!==s.deltaY&&(t.preventDefault(),e.scrollLeft+=s.deltaY)})),$(document).on(e.KEYUP,(t=>{this.keyNav(t)})),$(window).on(e.HASHCHANGE,(t=>{if(!0!==this.options.behavior.supportBrowserHistory)return;const e=this.getURLHashIndex();!1!==e&&this.isShowable(this.steps.eq(e))&&(t.preventDefault(),this.showStep(e))}));let t=null;$(window).on(e.RESIZE,(()=>{null!==t&&cancelAnimationFrame(t),t=requestAnimationFrame((()=>{this.fixHeight(this.currentStepIndex),this.scrollCheck()}))})),this.container.on(e.TOUCHSTART,(t=>{const e=t.originalEvent.touches[0];this.touchStartX=e.clientX,this.touchStartY=e.clientY})),this.container.on(e.TOUCHEND,(t=>{if(!this.options.swipeNavigation.enabled)return;const e=t.originalEvent.changedTouches[0],i=e.clientX-this.touchStartX,o=e.clientY-this.touchStartY;if(Math.abs(i)<Math.abs(o))return;const{threshold:n}=this.options.swipeNavigation;i<-n?this.navigate(s.Forward):i>n&&this.navigate(s.Backward)}))}setNav(){this.steps.removeClass([this.options.styles.anchorStates.completed,this.options.styles.anchorStates.active,this.options.styles.anchorStates.default,this.options.styles.anchorStates.disabled,this.options.styles.anchorStates.error,this.options.styles.anchorStates.warning,this.options.styles.anchorStates.hidden]),!0===this.options.navigation.alwaysClickable&&!0===this.options.navigation.enabled||this.steps.addClass(this.options.styles.anchorStates.default),this.setStepStyle(this.options.stepStates.completed,this.options.styles.anchorStates.completed),this.setStepStyle(this.options.stepStates.disabled,this.options.styles.anchorStates.disabled),this.setStepStyle(this.options.stepStates.warning,this.options.styles.anchorStates.warning),this.setStepStyle(this.options.stepStates.error,this.options.styles.anchorStates.error),this.setStepStyle(this.options.stepStates.hidden,this.options.styles.anchorStates.hidden)}setAnchor(t){if(null!==this.currentStepIndex&&this.currentStepIndex>=0){let e=this.options.styles.anchorStates.active;e+=" "+this.options.styles.anchorStates.default;let i="";!1!==this.options.navigation.completed.enabled&&(i+=this.options.styles.anchorStates.completed,!1!==this.options.navigation.completed.clearOnBack&&this.getStepDirection(t)===s.Backward&&(e+=" "+this.options.styles.anchorStates.completed)),this.steps.eq(this.currentStepIndex).addClass(i).removeClass(e)}this.steps.eq(t).removeClass(this.options.styles.anchorStates.completed+" "+this.options.styles.anchorStates.default).addClass(this.options.styles.anchorStates.active)}setButtons(t){this.main.find("."+this.options.styles.buttons.next+", ."+this.options.styles.buttons.previous).removeClass(this.options.styles.anchorStates.disabled);const e=this.getStepPosition(t);if(e===o.First||e===o.Last){const t=e===o.First?"."+this.options.styles.buttons.previous:"."+this.options.styles.buttons.next;this.main.find(t).addClass(this.options.styles.anchorStates.disabled)}else null===this.getShowable(t,s.Forward)&&this.main.find("."+this.options.styles.buttons.next).addClass(this.options.styles.anchorStates.disabled),null===this.getShowable(t,s.Backward)&&this.main.find("."+this.options.styles.buttons.previous).addClass(this.options.styles.anchorStates.disabled)}setProgressbar(t){const e=this.nav.width()??0,s=(e/this.steps.length*(t+1)/e*100).toFixed(2);document.documentElement.style.setProperty(r.PROGRESS_PERCENTAGE,s+"%"),this.progressbar.length>0&&this.progressbar.find("."+this.options.styles.progressBar.bar).css("width",s+"%")}getShowable(t,e){if(e==s.Backward){for(let e=t-1;e>=0;e--)if(this.isEnabled(this.steps[e]))return e}else{const e=this.steps.length;for(let s=t+1;s<e;s++)if(this.isEnabled(this.steps[s]))return s}return null}isShowable(t){if(!t)return!1;const e=t instanceof $?t[0]:t;if(!e)return!1;if(!this.isEnabled(e))return!1;const s=e.classList.contains(this.options.styles.anchorStates.completed);return(!1!==this.options.navigation.completed.enabled||!s)&&((!1!==this.options.navigation.completed.clickable||!s)&&!(!1===this.options.navigation.alwaysClickable&&!s))}isEnabled(t){if(!t)return!1;const e=t instanceof $?t[0]:t;return!!e&&(!e.classList.contains(this.options.styles.anchorStates.disabled)&&!e.classList.contains(this.options.styles.anchorStates.hidden))}getStepByAnchor(t){var e=this.nav.find("a[href*='"+t+"']");return e.length>0?this.steps.index(e):null}setStepStyle(t,e){$.each(t,((t,s)=>{this.steps.eq(s).addClass(e)}))}setToolbar(){this.main.find(a.TOOLBAR_ELM).remove();const t=this.options.toolbar.position;t!==n.None&&(t==n.Both?(this.container.before(this.createToolbar(n.Top)),this.container.after(this.createToolbar(n.Bottom))):t==n.Top?this.container.before(this.createToolbar(n.Top)):this.container.after(this.createToolbar(n.Bottom)))}createToolbar(t){const e=$("<div></div>").addClass("sw-toolbar-elm "+this.options.styles.toolbar.base+" "+this.options.styles.toolbar.prefix+t).attr("role","toolbar");let s=[];return!1!==this.options.toolbar.buttons.showPrevious&&s.push($("<button></button>").text(this.options.localization.buttons.previous).addClass("btn "+this.options.styles.buttons.previous+" "+this.options.styles.buttons.base).attr("type","button")),!1!==this.options.toolbar.buttons.showNext&&s.push($("<button></button>").text(this.options.localization.buttons.next).addClass("btn "+this.options.styles.buttons.next+" "+this.options.styles.buttons.base).attr("type","button")),s.length>0&&e.append(...s),e.append(this.options.toolbar.extraElements)}getURLHashIndex(){if(this.options.behavior.useUrlHash){var t=c();if(t.length>0){var e=this.nav.find("a[href*='"+t+"']");if(e.length>0)return this.steps.index(e)}}return!1}navigate(t){const e=this.getShowable(this.currentStepIndex,t);null!==e&&this.showStep(e)}scrollAnchor(t){const e=this.nav.get(0);if(!e)return;const s="column"!==window.getComputedStyle(e).flexDirection,i=s?e.clientWidth/2:e.clientHeight/2,o=s?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight;let n=s?e.scrollLeft:e.scrollTop;n+="right"===t||"next"===t?i:-i,n=Math.max(0,Math.min(n,o)),"function"==typeof e.scrollTo?e.scrollTo({[s?"left":"top"]:n,behavior:"smooth"}):s?e.scrollLeft=n:e.scrollTop=n}scrollCheck(){const t=this.nav.get(0);if(!t)return;const e="column"!==window.getComputedStyle(t).flexDirection,s=e?t.scrollLeft:t.scrollTop,i=e?t.scrollWidth:t.scrollHeight,o=e?t.clientWidth:t.clientHeight,n=i>o;if(this.nav.find("."+this.options.styles.buttons.scroll).toggle(n),!n)return;const r=s>0,a=Math.ceil(o+s)<i;this.nav.find("."+this.options.styles.buttons.scrollPrevious).toggle(r),this.nav.find("."+this.options.styles.buttons.scrollNext).toggle(a)}scrollNavToStep(t){const e=this.steps.eq(t);if(!e.length)return;const s=this.nav.get(0);if(!s)return;const i=e.closest("li, .sw-nav-item"),o=i.length>0?i.get(0):e.get(0);if(!o)return;const n="column"!==window.getComputedStyle(s).flexDirection;let r=n?o.offsetLeft:o.offsetTop;if(o.offsetParent!==s){const t=s.getBoundingClientRect(),e=o.getBoundingClientRect();r=n?e.left-t.left+s.scrollLeft:e.top-t.top+s.scrollTop}const a=n?o.offsetWidth:o.offsetHeight,l=n?s.clientWidth:s.clientHeight,h=n?s.scrollWidth-s.clientWidth:s.scrollHeight-s.clientHeight,c=r+a/2-l/2,p=Math.max(0,Math.min(c,h));"function"==typeof s.scrollTo?s.scrollTo({[n?"left":"top"]:p,behavior:"smooth"}):n?s.scrollLeft=p:s.scrollTop=p}keyNav(t){if(!this.options.keyboardNavigation.enabled)return;const e=t.target?.tagName;if("INPUT"===e||"TEXTAREA"===e||"SELECT"===e)return;const i=t.key;i&&(this.options.keyboardNavigation.keys.left.includes(i)?(this.navigate(s.Backward),t.preventDefault()):this.options.keyboardNavigation.keys.right.includes(i)&&(this.navigate(s.Forward),t.preventDefault()))}getStepDirection(t){return t>this.currentStepIndex?s.Forward:s.Backward}getStepAnchor(t){return null==t||-1==t?null:this.steps.eq(t)??null}getStepPage(t){return null==t||-1==t?null:this.pages.eq(t)??null}transit(t,e,s,i){v(this.pages,this.container);let o=w[this.options.transition.effect]??null;o=d(o)?o:w.default,o(t,e,s,this,i)}fixHeight(t){if(!1===this.options.behavior.autoHeight)return;const e=this.getStepPage(t);if(null==e)return;const s=parseFloat(this.container.css("padding-top"))+parseFloat(this.container.css("padding-bottom")),i=parseFloat(this.container.css("border-top-width"))+parseFloat(this.container.css("border-bottom-width")),o=($(e).outerHeight(!0)??0)+s+i;d(this.container.finish)&&d(this.container.animate)&&o>0?this.container.finish().animate({height:o},this.options.transition.speed):this.container.css({height:o>0?o:"auto"})}showStep(t){if(-1===t||null===t)return;if(t==this.currentStepIndex)return;if(!this.steps.eq(t))return;if(!this.isEnabled(this.steps.eq(t)))return;const s=this.getStepDirection(t);if(-1!==this.currentStepIndex){const i={stepIndex:this.currentStepIndex,nextStepIndex:t,stepElement:this.getStepAnchor(this.currentStepIndex),stepDirection:s,stepPosition:this.getStepPosition(this.currentStepIndex)};if(!1===S(this.main,e.LEAVESTEP,i))return}this.loadContent(t,(()=>{const i=this.getStepAnchor(t);if(this.options.behavior.useUrlHash&&this.options.behavior.supportBrowserHistory){const t=i?.attr("href")??"";t&&p(t)}this.setAnchor(t),this.options.scrollToView&&this.scrollNavToStep(t);const o=this.getStepPage(this.currentStepIndex),n=this.getStepPage(t);null!=n&&(this.transit($(n),o?$(o):null,s,(()=>{this.fixHeight(t);const o={stepIndex:t,stepElement:i,stepDirection:s,stepPosition:this.getStepPosition(t)};S(this.main,e.SHOWSTEP,o)})),this.currentStepIndex=t,this.setButtons(t),this.setProgressbar(t))}))}loadContent(t,e){if(!this.options.contentLoader||!d(this.options.contentLoader))return void e();let s=this.getStepPage(t);if(!s)return void e();s=$(s);const i=this.getStepDirection(t),o=this.getStepPosition(t);let n=this.getStepAnchor(t);null!=n?(n=$(n),this.options.contentLoader(t,i,o,n,(t=>{t&&(!1!==this.options.contentSanitize&&"string"==typeof t?s.empty().append($.parseHTML(t)):s.html(t)),e()}))):e()}getStepPosition(t){return 0===t?o.First:t===this.steps.length-1?o.Last:o.Middle}changeState(t,e,s){s=!1!==s;let i="";"default"==e?i=this.options.styles.anchorStates.default:"active"==e?i=this.options.styles.anchorStates.active:"completed"==e?i=this.options.styles.anchorStates.completed:"disable"==e?i=this.options.styles.anchorStates.disabled:"hidden"==e?i=this.options.styles.anchorStates.hidden:"error"==e?i=this.options.styles.anchorStates.error:"warning"==e&&(i=this.options.styles.anchorStates.warning),$.each(t,((t,e)=>{this.steps.eq(e).toggleClass(i,s)}))}goToStep(t,e){((e=!0===e)||this.isShowable(this.steps.eq(t)))&&(e&&t>0&&this.options.navigation.completed.enabled&&this.options.navigation.completed.completeAllPreviousSteps&&this.steps.slice(0,t).addClass(this.options.styles.anchorStates.completed),this.showStep(t))}next(){this.navigate(s.Forward)}prev(){this.navigate(s.Backward)}reset(){this.steps.removeClass([this.options.styles.anchorStates.completed,this.options.styles.anchorStates.active,this.options.styles.anchorStates.error,this.options.styles.anchorStates.warning]),this.options.behavior.useUrlHash&&this.options.behavior.supportBrowserHistory&&p("#"),this.init(),this.load()}setState(t,e){this.changeState(t,e,!0)}unsetState(t,e){this.changeState(t,e,!1)}setOptions(t){this.options=u(this.options,t),this.init(),this.load()}getOptions(){return this.options}getContentDirection(){return this.contentDirection||i.LeftToRight}getCurrentIndex(){return this.currentStepIndex}getStepInfo(){return{currentStep:this.currentStepIndex?this.currentStepIndex:0,totalSteps:this.steps?this.steps.length:0}}loader(t){this.main.toggleClass(this.options.styles.loader,"show"===t)}adjustHeight(){this.fixHeight(this.currentStepIndex)}resetHeight(){const t=this.getStepPage(0);if(null==t)return;const e=$(t).outerHeight(!0)??"auto";this.container.css({height:e})}getWidth(){return this.container.width()??0}}$.fn.extend({smartWizard:function(t){if(void 0===t||"object"==typeof t)return this.each((function(){$.data(this,"smartWizard")||$.data(this,"smartWizard",new m($(this),t))}));if("string"==typeof t&&"_"!==t[0]&&"init"!==t){const e=$.data(this[0],"smartWizard");return"destroy"===t?($.data(this,"smartWizard",null),e?.destroy(),this):e instanceof m&&"function"==typeof e[t]?e[t].apply(e,Array.prototype.slice.call(arguments,1)):this}}}),$.fn.smartWizard.transitions=w,exports.CONTENT_DIRECTION=i,exports.CSS_PROPERTIES=r,exports.DATA_ATTRIBUTES=l,exports.EVENTS=e,exports.EVENT_NAMESPACE=t,exports.SELECTORS=a,exports.STEP_DIRECTION=s,exports.STEP_POSITION=o,exports.TOOLBAR_POSITION=n,exports.Wizard=m,exports.deepMerge=u,exports.default=m,exports.defaults=h,exports.getContentDirection=g,exports.getFirstDescendant=f,exports.getUrlHash=c,exports.isFunction=d,exports.scrollToView=function(t){t[0]?.scrollIntoView({behavior:"smooth"})},exports.setContentDirection=b,exports.setUrlHash=p,exports.stopAnimations=v,exports.transitions=w,exports.triggerEvent=S;
//# sourceMappingURL=jquery.smartWizard.cjs.min.js.map