PageSourceSearch

https://www.cajoy.com/theme/c67b30656d4eb0821d591b608c3c451d/js/st…torefront.form-ajax-submit.plugin.7627f9.js

js cajoy.com collected 2026-09-26 08:42:26 UTC 8,165 bytes, 9 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[48402],{9749:(e,t,r)=>{r.d(t,{A:()=>i});let s=Object.freeze(new class{constructor(){this._domParser=new DOMParser}replaceFromMarkup(e,t){let r=e;"string"==typeof r&&(r=this._createMarkupFromString(r)),"string"==typeof t&&(t=[t]),this._replaceSelectors(r,t)}replaceElement(e,t){return("string"==typeof e&&(e=document.querySelectorAll(e)),"string"==typeof t&&(t=document.querySelectorAll(t)),e instanceof NodeList&&t instanceof NodeList&&t.length>e.length)?(t.forEach(t=>{e.forEach(e=>{e.innerHTML&&e.className===t.className&&(t.innerHTML=e.innerHTML)})}),!0):e instanceof NodeList&&e.length?(e.forEach((e,r)=>{e.innerHTML&&(t[r].innerHTML=e.innerHTML)}),!0):t instanceof NodeList&&t.length?(t.forEach(t=>{e.innerHTML&&(t.innerHTML=e.innerHTML)}),!0):!!t&&!!e&&!!e.innerHTML&&(t.innerHTML=e.innerHTML,!0)}_replaceSelectors(e,t){t.forEach(t=>{let r=e.querySelectorAll(t),s=document.querySelectorAll(t);this.replaceElement(r,s)})}_createMarkupFromString(e){return this._domParser.parseFromString(e,"text/html")}});
1class i{static replaceFromMarkup(e,t){s.replaceFromMarkup(e,t)}static replaceElement(e,t){return s.replaceElement(e,t)}}},8402:(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var s=r(4335),i=r(1088),n=r(9068),o=r(3343),a=r(9749);class l extends s.A{static #e=this.options={replaceSelectors:!1,submitOnChange:!1,submitOnce:!1,redirectTo:!1,forwardTo:!1};init(){if(this.loaded=!1,this.formSubmittedByCaptcha=!1,this._getForm(),!this._form)throw Error(`No form found for the plugin: ${this.constructor.name}`);"string"==typeof this.options.replaceSelectors&&(this.options.replaceSelectors=[this.options.replaceSelectors]),this._callbacks=[],this._client=new n.A,this._registerEvents()}addCallback(e){if("function"!=typeof e)throw Error("The callback must be a function!");this._callbacks.push(e)}_getForm(){this.el&&"FORM"===this.el.nodeName?this._form=this.el:this._form=this.el.closest("form")}_registerEvents(){let e=this._onSubmit.bind(this);this._form.removeEventListener("submit",e),this._form.addEventListener("submit",e),this.options.submitOnChange&&Array.from(this._form.elements).forEach(t=>{void 0!==t.removeEventListener&&(t.removeEventListener("change",e),t.addEventListener("change",e))})}_onSubmit(e){if("submit"===e.type&&!0===e.cancelable&&e.preventDefault(),!1!==this._form.checkValidity()&&(!this.loaded||!this.options.submitOnce)){if(this.$emitter.publish("beforeSubmit"),"change"===e.type&&Array.isArray(this.options.submitOnChange)){let t=e.currentTarget;this.options.submitOnChange.some(e=>{if(t.matches(e))return this._fireRequest(),!0})}else this._fireRequest()}}_fireRequest(){this._createLoadingIndicators(),this.$emitter.publish("beforeSubmit"),this.formSubmittedByCaptcha||this.sendAjaxFormSubmit()}sendAjaxFormSubmit(){let e=this._form.getAttribute("action");"get"===this._form.getAttribute("method")?fetch(e,{headers:{"X-Requested-With":"XMLHttpRequest"}}).then(e=>e.text()).then(e=>this._onAfterAjaxSubmit(e)):fetch(e,{method:"POST",body:this._getFormData(),headers:{"X-Requested-With":"XMLHttpRequest"}}).then(e=>e.text()).then(e=>this._onAfterAjaxSubmit(e))}_getFormData(){let e=i.A.serialize(this._form);return this.options.redirectTo?e.append("redirectTo",this.options.redirectTo):this.options.forwardTo&&e.append("forwardTo",this.options.forwardTo),e}_onAfterAjaxSubmit(e){this.options.replaceSelectors&&(this._removeLoadingIndicators(),a.A.replaceFromMarkup(e,this.options.replaceSelectors),window.PluginManager.initializePlugins()),this._executeCallbacks(),this.loaded=!0,this.$emitter.publish("onAfterAjaxSubmit",{response:e})}_createLoadingIndicators(){this.options.replaceSelectors&&this.options.replaceSelectors.forEach(e=>{document.querySelectorAll(e).forEach(e=>o.A.create(e))}),this.$emitter.publish("createLoadingIndicators")}_removeLoadingIndicators(){this.options.replaceSelectors.forEach(e=>{document.querySelectorAll(e).forEach(e=>o.A.remove(e))}),this.$emitter.publish("createLoadingIndicators")}_executeCallbacks(){this._callbacks.forEach(e=>{if("function"!=typeof e)throw Error("The callback must be a function!");e.apply(this)}),this.$emitter.publish("executeCallbacks")}}},9068:(e,t,r)=>{r.d(t,{A:()=>s});class s{constructor(){this._request=null,this._errorHandlingInternal=!1}get(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",s=this._createPreparedRequest("GET",e,r);return this._sendRequest(s,null,t)}post(e,t,r){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";s=this._getContentType(t,s);let i=this._createPreparedRequest("POST",e,s);return this._sendRequest(i,t,r)}delete(e,t,r){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";s=this._getContentType(t,s);let i=this._createPreparedRequest("DELETE",e,s);return this._sendRequest(i,t,r)}patch(e,t,r){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";s=this._getContentType(t,s);let i=this._createPreparedRequest("PATCH",e,s);return this._sendRequest(i,t,r)}
1abort(){if(this._request)return this._request.abort()}setErrorHandlingInternal(e){this._errorHandlingInternal=e}_registerOnLoaded(e,t){t&&(!0===this._errorHandlingInternal?(e.addEventListener("load",()=>{t(e.responseText,e)}),e.addEventListener("abort",()=>{console.warn(`the request to ${e.responseURL} was aborted`)}),e.addEventListener("error",()=>{console.warn(`the request to ${e.responseURL} failed with status ${e.status}`)}),e.addEventListener("timeout",()=>{console.warn(`the request to ${e.responseURL} timed out`)})):e.addEventListener("loadend",()=>{t(e.responseText,e)}))}_sendRequest(e,t,r){return this._registerOnLoaded(e,r),e.send(t),e}_getContentType(e,t){return e instanceof FormData&&(t=!1),t}_createPreparedRequest(e,t,r){return this._request=new XMLHttpRequest,this._request.open(e,t),this._request.setRequestHeader("X-Requested-With","XMLHttpRequest"),r&&this._request.setRequestHeader("Content-type",r),this._request}}},1088:(e,t,r)=>{r.d(t,{A:()=>s});class s{static serialize(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if("FORM"!==e.nodeName){if(t)throw Error("The passed element is not a form!");return{}}return new FormData(e)}static serializeJson(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],r=s.serialize(e,t);if(!(r instanceof FormData)&&0===Object.keys(r).length||r instanceof FormData&&0===Array.from(r.entries()).length)return{};let i={};for(let[e,t]of r.entries())i[e]=t;return i}}},3343:(e,t,r)=>{r.d(t,{A:()=>n});var s=r(5683);let i="element-loader-backdrop";class n extends s.A{static create(e){e.classList.add("has-element-loader"),n.exists(e)||(n.appendLoader(e),setTimeout(()=>{let t=e.querySelector(`.${i}`);t&&t.classList.add("element-loader-backdrop-open")},1))}static remove(e){e.classList.remove("has-element-loader");let t=e.querySelector(`.${i}`);t&&t.remove()}static exists(e){return e.querySelectorAll(`.${i}`).length>0}static getTemplate(){return`
2        <div class="${i}">
3            <div class="loader" role="status">
4                <span class="visually-hidden">Loading...</span>
5            </div>
6        </div>
7        `}static appendLoader(e){e.insertAdjacentHTML("beforeend",n.getTemplate())}}},5683:(e,t,r)=>{r.d(t,{A:()=>n,c:()=>i});let s="loader",i={BEFORE:"before",AFTER:"after",INNER:"inner"};class n{constructor(e,t=i.BEFORE){this.parent=e instanceof Element?e:document.body.querySelector(e),this.position=t}create(){if(!this.exists()){if(this.position===i.INNER){this._previousHTML=this.parent.innerHTML,this.parent.innerHTML=n.getTemplate();return}this.parent.insertAdjacentHTML(this._getPosition(),n.getTemplate())}}remove(){if(this.position===i.INNER){this.parent.innerHTML=this._previousHTML;return}this.parent.querySelectorAll(`.${s}`).forEach(e=>e.remove())}exists(){return this.parent.querySelectorAll(`.${s}`).length>0}_getPosition(){return this.position===i.BEFORE?"afterbegin":"beforeend"}static getTemplate(){return`<div class="${s}" role="status">
8                    <span class="visually-hidden">Loading...</span>
9                </div>`}static SELECTOR_CLASS(){return s}}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.