UNPKG

smartwizard

Version:

A modern and accessible step wizard plugin for jQuery

16 lines (15 loc) • 22.5 kB
/*! * 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 */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).smartWizard={})}(this,(function(t){"use strict";const e=".sw",s={CLICK:`click${e}`,KEYUP:`keyup${e}`,HASHCHANGE:`hashchange${e}`,SCROLLEND:`scrollend${e}`,WHEEL:`wheel${e}`,RESIZE:`resize${e}`,ANIMATIONEND:`animationend${e}`,ANIMATIONCANCEL:`animationcancel${e}`,TOUCHSTART:`touchstart${e}`,TOUCHEND:`touchend${e}`,INITIALIZED:`initialized${e}`,LOADED:`loaded${e}`,LEAVESTEP:`leave${e}`,SHOWSTEP:`shown${e}`},i={Forward:"forward",Backward:"backward"},n={LeftToRight:"ltr",RightToLeft:"rtl"},o={First:"first",Middle:"middle",Last:"last"},a={None:"none",Top:"top",Bottom:"bottom",Both:"both"},r={PROGRESS_PERCENTAGE:"--sw-progress-percentage"},l={TOOLBAR_ELM:".sw-toolbar-elm"},h={THEME:"data-theme"},c={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 p(){return window.location.hash||""}function d(t){history.pushState(null,"",t)}function u(t){return"function"==typeof t}function f(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 n=i[t],o=e[t];null===o||"object"!=typeof o||Array.isArray(o)||null===n||"object"!=typeof n||Array.isArray(n)?void 0!==o&&(i[t]=s(o)):i[t]=f(n,o)}return i}function g(t,e){const s=t.children(e);if(s.length>0)return s;let i=null;if(t.children().each(((t,s)=>{const n=$(s).children(e);if(n.length>0)return i=n,!1})),i)return i;throw new Error(`Element not found ${e}`)}function b(t){return t.prop("dir")||document.documentElement.dir||""}function S(t,e){t.prop("dir",e)}function v(t,e,s=[]){const i=$.Event(e);return t.trigger(i,s),!i.isDefaultPrevented()}function w(...t){u($.fn.finish)&&$(t).finish()}const m={default:function(t,e,s,i,n){e&&e.hide(),t.show(),n()},fade:function(t,e,s,i,n){if(!u(t.fadeOut))return void m.default(t,e,s,i,n);const{speed:o,easing:a}=i.getOptions().transition,r=()=>t.fadeIn(o,a,n);e?e.fadeOut(o,a,r):r()},slideHorizontal:function(t,e,s,i,n){if(!u(t.animate))return void m.default(t,e,s,i,n);const{speed:o,easing:a}=i.getOptions().transition,r=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},o,a,i)};if(e){const t=e.css(["position","left"]);l(e,0,r*("backward"==s?1:-1),(()=>{e.hide().css(t)}))}const h=t.css(["position"]);l(t,r*("backward"==s?-2:1),0,(()=>{t.css(h),n()}))},slideVertical:function(t,e,s,i,n){if(!u(t.animate))return void m.default(t,e,s,i,n);const{speed:o,easing:a}=i.getOptions().transition,r=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},o,a,i)};if(e){const t=e.css(["position","top"]);l(e,0,r*("backward"==s?1:-1),(()=>{e.hide().css(t)}))}const h=t.css(["position"]);l(t,r*("backward"==s?-2:1),0,(()=>{t.css(h),n()}))},slideSwing:function(t,e,s,i,n){if(!u(t.slideDown))return void m.default(t,e,s,i,n);const{speed:o,easing:a}=i.getOptions().transition,r=()=>t.slideDown(o,a,n);e?e.slideUp(o,a,r):r()},css:function(t,e,i,n,o){const{prefix:a,forward:r,backward:l}=n.getOptions().transition.css;if(0==r.show.length||0==l.show.length)return void m.default(t,e,i,n,o);const h=(t,e,i)=>{if(!e||0==e.length)return void i();t.show();let n=!1;const o=s=>{n||(n=!0,t.removeClass(e),i(s))};t.addClass(e).one(s.ANIMATIONEND,(()=>o())).one(s.ANIMATIONCANCEL,(()=>o("cancel")))},c=()=>{const e=a+" "+("backward"==i?l.show:r.show);h(t,e,(()=>{o()}))};if(e){const t=a+" "+("backward"==i?l.hide:r.hide);h(e,t,(()=>{e.hide(),c()}))}else c()}};class y{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=f(c,e??{}),this.main=$(t),this.setup(),this.init(),requestAnimationFrame((()=>{this.load()}))}setup(){this.container=g(this.main,"."+this.options.styles.content.container),this.nav=g(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=b(this.main),this.contentDirection??S(this.main,this.contentDirection),this.currentStepIndex=-1,this.isInitialized=!1}init(){this.setElements(),this.setToolbar(),this.setNav(),!0!==this.isInitialized&&(this.setEvents(),v(this.main,s.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),v(this.main,s.LOADED)}getInitialStep(){let t=null;if(this.options.behavior.useUrlHash){const e=p();t=e?this.getStepByAnchor(e):null}const e=t??this.options.initialStep;return this.getShowable(e-1,i.Forward)??(e>0?this.getShowable(-1,i.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(h.THEME),"none"!==t)if("dark"===t)this.main.attr(h.THEME,"dark");else if("light"===t)this.main.attr(h.THEME,"light");else if("auto"===t){const t=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(this.main.attr(h.THEME,t?"dark":"light"),window.matchMedia){const t=window.matchMedia("(prefers-color-scheme: dark)"),e=t=>{this.main.attr(h.THEME,t.matches?"dark":"light")};t.addEventListener?t.addEventListener("change",e):t.addListener&&t.addListener(e)}}}setEvents(){this.steps.on(s.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(s.CLICK,(t=>{const e=$(t.target);e.hasClass(this.options.styles.buttons.next)?(t.preventDefault(),this.navigate(i.Forward)):e.hasClass(this.options.styles.buttons.previous)?(t.preventDefault(),this.navigate(i.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(s.SCROLLEND,(()=>{this.scrollCheck()})),this.nav.on(s.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(s.KEYUP,(t=>{this.keyNav(t)})),$(window).on(s.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(s.RESIZE,(()=>{null!==t&&cancelAnimationFrame(t),t=requestAnimationFrame((()=>{this.fixHeight(this.currentStepIndex),this.scrollCheck()}))})),this.container.on(s.TOUCHSTART,(t=>{const e=t.originalEvent.touches[0];this.touchStartX=e.clientX,this.touchStartY=e.clientY})),this.container.on(s.TOUCHEND,(t=>{if(!this.options.swipeNavigation.enabled)return;const e=t.originalEvent.changedTouches[0],s=e.clientX-this.touchStartX,n=e.clientY-this.touchStartY;if(Math.abs(s)<Math.abs(n))return;const{threshold:o}=this.options.swipeNavigation;s<-o?this.navigate(i.Forward):s>o&&this.navigate(i.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 s="";!1!==this.options.navigation.completed.enabled&&(s+=this.options.styles.anchorStates.completed,!1!==this.options.navigation.completed.clearOnBack&&this.getStepDirection(t)===i.Backward&&(e+=" "+this.options.styles.anchorStates.completed)),this.steps.eq(this.currentStepIndex).addClass(s).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,i.Forward)&&this.main.find("."+this.options.styles.buttons.next).addClass(this.options.styles.anchorStates.disabled),null===this.getShowable(t,i.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==i.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(l.TOOLBAR_ELM).remove();const t=this.options.toolbar.position;t!==a.None&&(t==a.Both?(this.container.before(this.createToolbar(a.Top)),this.container.after(this.createToolbar(a.Bottom))):t==a.Top?this.container.before(this.createToolbar(a.Top)):this.container.after(this.createToolbar(a.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=p();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,n=s?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight;let o=s?e.scrollLeft:e.scrollTop;o+="right"===t||"next"===t?i:-i,o=Math.max(0,Math.min(o,n)),"function"==typeof e.scrollTo?e.scrollTo({[s?"left":"top"]:o,behavior:"smooth"}):s?e.scrollLeft=o:e.scrollTop=o}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,n=e?t.clientWidth:t.clientHeight,o=i>n;if(this.nav.find("."+this.options.styles.buttons.scroll).toggle(o),!o)return;const a=s>0,r=Math.ceil(n+s)<i;this.nav.find("."+this.options.styles.buttons.scrollPrevious).toggle(a),this.nav.find("."+this.options.styles.buttons.scrollNext).toggle(r)}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"),n=i.length>0?i.get(0):e.get(0);if(!n)return;const o="column"!==window.getComputedStyle(s).flexDirection;let a=o?n.offsetLeft:n.offsetTop;if(n.offsetParent!==s){const t=s.getBoundingClientRect(),e=n.getBoundingClientRect();a=o?e.left-t.left+s.scrollLeft:e.top-t.top+s.scrollTop}const r=o?n.offsetWidth:n.offsetHeight,l=o?s.clientWidth:s.clientHeight,h=o?s.scrollWidth-s.clientWidth:s.scrollHeight-s.clientHeight,c=a+r/2-l/2,p=Math.max(0,Math.min(c,h));"function"==typeof s.scrollTo?s.scrollTo({[o?"left":"top"]:p,behavior:"smooth"}):o?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 s=t.key;s&&(this.options.keyboardNavigation.keys.left.includes(s)?(this.navigate(i.Backward),t.preventDefault()):this.options.keyboardNavigation.keys.right.includes(s)&&(this.navigate(i.Forward),t.preventDefault()))}getStepDirection(t){return t>this.currentStepIndex?i.Forward:i.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){w(this.pages,this.container);let n=m[this.options.transition.effect]??null;n=u(n)?n:m.default,n(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")),n=($(e).outerHeight(!0)??0)+s+i;u(this.container.finish)&&u(this.container.animate)&&n>0?this.container.finish().animate({height:n},this.options.transition.speed):this.container.css({height:n>0?n:"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 e=this.getStepDirection(t);if(-1!==this.currentStepIndex){const i={stepIndex:this.currentStepIndex,nextStepIndex:t,stepElement:this.getStepAnchor(this.currentStepIndex),stepDirection:e,stepPosition:this.getStepPosition(this.currentStepIndex)};if(!1===v(this.main,s.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&&d(t)}this.setAnchor(t),this.options.scrollToView&&this.scrollNavToStep(t);const n=this.getStepPage(this.currentStepIndex),o=this.getStepPage(t);null!=o&&(this.transit($(o),n?$(n):null,e,(()=>{this.fixHeight(t);const n={stepIndex:t,stepElement:i,stepDirection:e,stepPosition:this.getStepPosition(t)};v(this.main,s.SHOWSTEP,n)})),this.currentStepIndex=t,this.setButtons(t),this.setProgressbar(t))}))}loadContent(t,e){if(!this.options.contentLoader||!u(this.options.contentLoader))return void e();let s=this.getStepPage(t);if(!s)return void e();s=$(s);const i=this.getStepDirection(t),n=this.getStepPosition(t);let o=this.getStepAnchor(t);null!=o?(o=$(o),this.options.contentLoader(t,i,n,o,(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(i.Forward)}prev(){this.navigate(i.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&&d("#"),this.init(),this.load()}setState(t,e){this.changeState(t,e,!0)}unsetState(t,e){this.changeState(t,e,!1)}setOptions(t){this.options=f(this.options,t),this.init(),this.load()}getOptions(){return this.options}getContentDirection(){return this.contentDirection||n.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 y($(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 y&&"function"==typeof e[t]?e[t].apply(e,Array.prototype.slice.call(arguments,1)):this}}}),$.fn.smartWizard.transitions=m,t.CONTENT_DIRECTION=n,t.CSS_PROPERTIES=r,t.DATA_ATTRIBUTES=h,t.EVENTS=s,t.EVENT_NAMESPACE=e,t.SELECTORS=l,t.STEP_DIRECTION=i,t.STEP_POSITION=o,t.TOOLBAR_POSITION=a,t.Wizard=y,t.deepMerge=f,t.default=y,t.defaults=c,t.getContentDirection=b,t.getFirstDescendant=g,t.getUrlHash=p,t.isFunction=u,t.scrollToView=function(t){t[0]?.scrollIntoView({behavior:"smooth"})},t.setContentDirection=S,t.setUrlHash=d,t.stopAnimations=w,t.transitions=m,t.triggerEvent=v,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=jquery.smartWizard.min.js.map