advanced.reporting.asset.php
2 weeks ago
advanced.reporting.js
2 weeks ago
calculated.field.asset.php
2 weeks ago
calculated.field.js
2 weeks ago
conditional.block.asset.php
2 weeks ago
conditional.block.js
2 weeks ago
dynamic.value.asset.php
2 weeks ago
dynamic.value.js
2 weeks ago
main.asset.php
2 weeks ago
main.css
2 weeks ago
main.js
2 weeks ago
media.field.asset.php
2 weeks ago
media.field.js
2 weeks ago
media.field.restrictions.asset.php
2 weeks ago
media.field.restrictions.js
2 weeks ago
multi.step.asset.php
2 weeks ago
multi.step.js
2 weeks ago
multi.step.js
1 lines
| 1 | (()=>{"use strict";const{ConditionItem:t}=JetFormBuilderAbstract;function e(){t.call(this),this.isSupported=function(t){return!!t?.page_state?.length},this.setOptions=function({page_state:t}){this.pageState=t},this.isPassed=function(){const t=this.list?.block?.page?.canSwitch?.current;return"active"===this.pageState&&!t}}e.prototype=Object.create(t.prototype);const i=e,{ReactiveVar:s,createConditionalBlock:n}=JetFormBuilderAbstract,{validateInputs:o,getOffsetTop:r,focusOnInvalidInput:a,populateInputs:c}=JetFormBuilderFunctions,{addAction:h,doAction:u}=JetPlugins.hooks;function d(t,e){this.node=t,this.index=+t.dataset.page,this.offset=+t.dataset.pageOffset,this.state=e,this.inputs=[],this.inputBindings=new Map,this.canSwitch=new s(null),this.isShow=new s(1===this.index),this.autoFocus=window.JetFormBuilderSettings?.auto_focus,this.initialObserveState=!1}d.prototype.observe=function(){this.isLast()||this.observeInputs(),this.canSwitch.make(),this.isShow.make(),this.isShow.watch(()=>{this.isShow.current?this.onShow():this.onHide()}),this.addButtonsListeners(),this.isFirst()&&(this.initialObserveState=!0,this.updateStateAsync().then(()=>{}).catch(()=>{})),this.updateOffsetByProgress(),h("jet.fb.observe.input.manual","jet-form-builder/page-state",t=>this.observeInput(t.nodes[0])),u("jet.fb.multistep.page.init",this)},d.prototype.observeInputs=function(){for(const t of this.node.querySelectorAll("[data-jfb-sync]")){const e=this.observeInput(t);e&&u("jet.fb.multistep.page.observed.input",e,this)}},d.prototype.observeInput=function(t){if(!this.isNodeBelongThis(t)||!t.hasOwnProperty("jfbSync")||t.jfbSync.hasParent())return!1;const e=t.jfbSync;return this.registerInput(e)},d.prototype.observeConditionalBlocks=function(){if(!this.isLast())for(const t of this.node.querySelectorAll("[data-jfb-conditional]")){if(!this.isNodeBelongThis(t))continue;const e=n(t,this.state.getRoot());for(const t of e.list.getConditions())if(t instanceof i){e.page=this,this.canSwitch.watch(()=>e.list.onChangeRelated()),e.list.onChangeRelated();break}}},d.prototype.onShow=function(){this.node.classList.remove("jet-form-builder-page--hidden"),this.initialObserveState||(this.initialObserveState=!0,this.updateStateAsync().then(()=>{}).catch(()=>{}))},d.prototype.onHide=function(){this.node.classList.add("jet-form-builder-page--hidden")},d.prototype.updateState=function(){for(const t of this.getInputs())if(!t.reporting.validityState.current&&null!==t.reporting.validityState.current)return void(this.canSwitch.current=!1);this.canSwitch.current=!0},d.prototype.updateStateAsync=async function(t=!0){try{await o(this.getInputs(),t),this.canSwitch.current=!0}catch(t){this.canSwitch.current=!1}},d.prototype.addButtonsListeners=function(){const t=this.node.querySelectorAll(".jet-form-builder__next-page, .jet-form-builder__prev-page");for(const e of t){if(!this.isNodeBelongThis(e))continue;const t=e.classList.contains("jet-form-builder__prev-page");e.addEventListener("click",()=>this.changePage(t))}},d.prototype.changePage=async function(t){t?this.state.index.current=this.index-1:this.isLast()||this.getLockState().current||(await this.updateStateAsync(!1),this.canSwitch.current?this.state.index.current=this.index+1:this.autoFocus&&a(this.getInputs()))},d.prototype.isNodeBelongThis=function(t){const e=t.closest(".jet-form-builder-page");return!!e&&e.isEqualNode(this.node)},d.prototype.getInputs=function(){return c(this.inputs)},d.prototype.getLockState=function(){var t;const e=this.state.getRoot();return(null!==(t=e?.parent?.root?.form)&&void 0!==t?t:e.form).lockState},d.prototype.isLast=function(){return this.state.isLastPage(this)},d.prototype.isFirst=function(){return this.state.isFirstPage(this)},d.prototype.handleInputEnter=function(t){t?.enterKey?.addFilter(()=>{const e=t.root.form;return e?!0===e.canTriggerEnterSubmit&&this.changePage().then(()=>{}).catch(()=>{}):this.changePage().then(()=>{}).catch(()=>{}),!1})},d.prototype.registerInput=function(t,{includeInValidation:e=!0}={}){if(!t||this.inputBindings.has(t))return t;this.handleInputEnter(t);const i={clearLoadingWatch:t.loading.watch(()=>{t.loading.current?this.canSwitch.current=!1:this.updateState()}),clearValidityWatch:null};return t.reporting.restrictions.length&&(this.inputs.push(t),i.clearValidityWatch=t.watchValidity(()=>this.updateState()),e||(this.inputs=this.inputs.filter(e=>e!==t))),this.inputBindings.set(t,i),t},d.prototype.unregisterInput=function(t){if(!this.inputBindings.has(t))return;const e=this.inputBindings.get(t);e?.clearLoadingWatch?.(),e?.clearValidityWatch?.(),this.inputBindings.delete(t),this.inputs=this.inputs.filter(e=>e!==t)},d.prototype.getTrackedInputs=function(){return Array.from(this.inputBindings.keys())},d.prototype.getOffsetTop=function(){return r(this.node)-this.offset},d.prototype.updateOffsetByProgress=function(){this.state?.progress?.node&&(this.offset+=+this.state.progress.node.clientHeight)};const p=d,l=function(t,e){this.node=t,this.state=e,this.state.index.watch(()=>this.updateItems()),this.updateItems=function(){const{current:t}=this.state.index;for(const e of this.node.children){const i=+e.dataset.page;i<t?this.makePassed(e):t===i?this.makeActive(e):this.makeNotPassed(e)}},this.makeActive=function(t){t.classList.remove("passed-page"),t.classList.add("active-page")},this.makePassed=function(t){t.classList.add("passed-page"),t.classList.remove("active-page")},this.makeNotPassed=function(t){t.classList.remove("active-page","passed-page")}},{ConditionalBlock:f,ReactiveVar:g}=JetFormBuilderAbstract,{doAction:m}=JetPlugins.hooks,b=function(){this.root=null,this.block=null,this.index=null,this.elements=[],this.setScope=function(t){t instanceof f?this.block=t:this.root=t},this.setProgress=function(){this.index=new g(1),this.index.make(),this.index.watch(this.onChangeIndex.bind(this));for(const t of this.getScopeNode().children)t.matches(".jet-form-builder-progress-pages")&&(this.progress=new l(t,this))},this.setPages=function(t){this.elements=t.map(t=>new p(t,this)),this.elements.forEach(t=>t.observe()),this.elements.forEach(t=>t.observeConditionalBlocks());const{submitter:e}=this.getRoot().getSubmit();e.hasOwnProperty("status")&&e.watchReset(()=>{this.index.current=1})},this.onChangeIndex=function(){for(const t of this.getPages())t.isShow.current=t.index===this.index.current;window?.jQuery(document)?.trigger("jet-form-builder/switch-page")},this.getCurrentPage=function(){for(const t of this.getPages())if(t.isShow.current)return t;return!1},this.getPages=function(){return this.elements},this.getScopeNode=function(){var t;return null!==(t=this.block?.node)&&void 0!==t?t:this.root.rootNode},this.getRoot=function(){var t;return null!==(t=this.block?.root)&&void 0!==t?t:this.root},this.isLastPage=function(t){return this.elements.at(-1)===t},this.isFirstPage=function(t){return this.elements[0]===t},this.onReady=function(){m("jet.fb.multistep.init",this)}};function y(t){const e=new b;e.setScope(t);const i=[];for(const t of e.getScopeNode().childNodes)t?.classList?.contains("jet-form-builder-page")&&i.push(t);return i.length?(e.setProgress(),e.setPages(i),e):e}const{addAction:S,addFilter:w}=JetPlugins.hooks,{getScrollParent:v}=JetFormBuilderFunctions;S("jet.fb.observe.after","jet-form-builder/multi-step",function(t){const e=y(t);e.getPages()?.length&&(t.multistep=e,e.onReady())},15),S("jet.fb.conditional.init","jet-form-builder/multi-step",function(t){const e=y(t);e.getPages()?.length&&(t.multistep=e,e.onReady())}),w("jet.fb.conditional.types","jet-form-builder/multi-step",function(t){return[i,...t]}),S("jet.fb.multistep.init","jet-form-builder/multi-step/autoscroll",function(t){window?.JetFormBuilderSettings?.scroll_on_next&&t.index.watch(()=>{const e=t.getCurrentPage(),i=v(e.node),s=e.getOffsetTop();i?.scrollTo?.({top:s,behavior:"smooth"})})})})(); |