PageSourceSearch

https://www.bodylab.dk/theme/3ab2d93ce5f24a33193ab0ea349d4511/js/w…/login-modal.plugin.1616a6.js

js bodylab.dk collected 2026-10-02 03:20:34 UTC 11,322 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([["login-modal.plugin"],{724:(e,t,s)=>{s.r(t),s.d(t,{default:()=>y});var a=s(49),i=s(206),o=s(266);let n="modal-backdrop",r="modal-backdrop-open",l="no-scroll",c={ON_CLICK:"backdrop/onclick"};class d{create(e){this._removeExistingBackdrops(),document.body.insertAdjacentHTML("beforeend",this._getTemplate());let t=document.body.lastChild;document.documentElement.classList.add(l),setTimeout(function(){t.classList.add(r),"function"==typeof e&&e()},75),this._dispatchEvents()}remove(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:350,t=this._getBackdrops();o.Z.iterate(t,e=>e.classList.remove(r)),setTimeout(this._removeExistingBackdrops.bind(this),e),document.documentElement.classList.remove(l)}_dispatchEvents(){let e=i.Z.isTouchDevice()?"touchstart":"click";document.addEventListener(e,function(e){e.target.classList.contains(n)&&document.dispatchEvent(new CustomEvent(c.ON_CLICK))})}_getBackdrops(){return document.querySelectorAll(".".concat(n))}_removeExistingBackdrops(){if(!1===this._exists())return;let e=this._getBackdrops();o.Z.iterate(e,e=>e.remove())}_exists(){return document.querySelectorAll(".".concat(n)).length>0}_getTemplate(){return'<div class="'.concat(n,'"></div>')}constructor(){return d.instance||(d.instance=this),d.instance}}Object.freeze(new d);let h="js-pseudo-modal";class u{open(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:350;this._hideExistingModal(),this._create(),setTimeout(this._open.bind(this,e),t)}close(){let e=this.getModal();this._modalInstance=bootstrap.Modal.getInstance(e),this._modalInstance.hide()}getModal(){return this._modal||this._create(),this._modal}updatePosition(){this._modalInstance.handleUpdate()}updateContent(e,t){this._content=e,this._setModalContent(e),this.updatePosition(),"function"==typeof t&&t.bind(this)()}_hideExistingModal(){try{let e=a.Z.querySelector(document,".".concat(h," .modal"),!1);if(!e)return;let t=bootstrap.Modal.getInstance(e);if(!t)return;t.hide()}catch(e){console.warn("[PseudoModalUtil] Unable to hide existing pseudo modal before opening pseudo modal: ".concat(e.message))}}_open(e){this.getModal(),this._modal.addEventListener("hidden.bs.modal",this._modalWrapper.remove),this._modal.addEventListener("shown.bs.modal",e),this._modalInstance.show()}_create(){this._modalMarkupEl=a.Z.querySelector(document,this._templateSelector),this._createModalWrapper(),this._modalWrapper.innerHTML=this._content,this._modal=this._createModalMarkup(),this._modalInstance=new bootstrap.Modal(this._modal,{backdrop:this._useBackdrop}),document.body.insertAdjacentElement("beforeend",this._modalWrapper)}_createModalWrapper(){this._modalWrapper=a.Z.querySelector(document,".".concat(h),!1),this._modalWrapper||(this._modalWrapper=document.createElement("div"),this._modalWrapper.classList.add(h))}_createModalMarkup(){let e=a.Z.querySelector(this._modalWrapper,".modal",!1);if(e)return e;let t=this._modalWrapper.innerHTML;return this._modalWrapper.innerHTML=this._modalMarkupEl.innerHTML,this._setModalContent(t),a.Z.querySelector(this._modalWrapper,".modal")}_setModalTitle(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{a.Z.querySelector(this._modalWrapper,this._templateTitleSelector).innerHTML=e}catch(e){}}_setModalContent(e){let t=a.Z.querySelector(this._modalWrapper,this._templateContentSelector);t.innerHTML=e;try{let e=a.Z.querySelector(t,this._templateTitleSelector);e&&(this._setModalTitle(e.innerHTML),e.parentNode.removeChild(e))}catch(e){}}constructor(e,t=!0,s=".".concat("js-pseudo-modal-template"),a=".".concat("js-pseudo-modal-template-content-element"),i=".".concat("js-pseudo-modal-template-title-element")){this._content=e,this._useBackdrop=t,this._templateSelector=s,this._templateContentSelector=a,this._templateTitleSelector=i}}var m=s(363),f=s(830);let p="offcanvas";class v{open(e,t,s,a,i,o,n){this._removeExistingOffCanvas();let r=this._createOffCanvas(s,o,n,a);this.setContent(e,a,i),this._openOffcanvas(r,t)}setContent(e,t){let s=this.getOffCanvas();s[0]&&(s[0].innerHTML=e,this._registerEvents(t))}setAdditionalClassName(e){this.getOffCanvas()[0].classList.add(e)}getOffCanvas(){return document.querySelectorAll(".".concat(p))}close(e){let t=this.getOffCanvas();o.Z.iterate(t,e=>{bootstrap.Offcanvas.getInstance(e).hide()}),setTimeout(()=>{this.$emitter.publish("onCloseOffcanvas",{offCanvasContent:t})},e)}goBackInHistory(){window.history.back()}exists(){return this.getOffCanvas().length>0}_openOffcanvas(e,t){window.focusHandler.saveFocusState("offcanvas"),v.bsOffcanvas.show(),window.history.pushState("offcanvas-open",""),"function"==typeof t&&t()}_registerEvents(e){let t=i.Z.isTouchDevice()?"touchend":"click",
1s=this.getOffCanvas();o.Z.iterate(s,t=>{let a=()=>{setTimeout(()=>{t.remove(),window.focusHandler.resumeFocusState("offcanvas"),this.$emitter.publish("onCloseOffcanvas",{offCanvasContent:s})},e),t.removeEventListener("hide.bs.offcanvas",a)};t.addEventListener("hide.bs.offcanvas",a)}),window.addEventListener("popstate",this.close.bind(this,e),{once:!0});let a=document.querySelectorAll(".".concat("js-offcanvas-close"));o.Z.iterate(a,s=>s.addEventListener(t,this.close.bind(this,e)))}_removeExistingOffCanvas(){v.bsOffcanvas=null;let e=this.getOffCanvas();return o.Z.iterate(e,e=>e.remove())}_getPositionClass(e){return"left"===e?"offcanvas-start":"right"===e?"offcanvas-end":"offcanvas-".concat(e)}_createOffCanvas(e,t,s,a){let i=document.createElement("div");if(i.classList.add(p),i.classList.add(this._getPositionClass(e)),i.setAttribute("tabindex","-1"),!0===t&&i.classList.add("is-fullwidth"),s){let e=typeof s;if("string"===e)i.classList.add(s);else if(Array.isArray(s))s.forEach(e=>{i.classList.add(e)});else throw Error('The type "'.concat(e,'" is not supported. Please pass an array or a string.'))}return document.body.appendChild(i),v.bsOffcanvas=new bootstrap.Offcanvas(i,{backdrop:!1!==a||"static"}),i}constructor(){this.$emitter=new f.Z}}let _=Object.freeze(new v);class g{static open(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"left",a=!(arguments.length>3)||void 0===arguments[3]||arguments[3],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:350,o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],n=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"";_.open(e,t,s,a,i,o,n)}static setContent(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:350;_.setContent(e,t,s)}static setAdditionalClassName(e){_.setAdditionalClassName(e)}static close(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:350;_.close(e)}static exists(){return _.exists()}static getOffCanvas(){return _.getOffCanvas()}static REMOVE_OFF_CANVAS_DELAY(){return 350}}let w=window.PluginBaseClass,b="[data-login-modal]",E=!1;class y extends w{init(){E||(E=!0,document.addEventListener("click",e=>{let t=e.target.closest(b);t&&t.dataset.loginModalUrl&&(e.preventDefault(),this._open(t.dataset.loginModalUrl,{redirect:t.dataset.loginModalRedirect||null,cartChangedRedirect:t.dataset.loginModalCartChangedRedirect||null}))}))}async _open(e,t){g.exists()&&g.close(),this._redirects=t,this._modal=new u(m.Z.getTemplate()),this._modal.open(),this._sizeDialog();try{let t=await fetch(e,{headers:{"X-Requested-With":"XMLHttpRequest"}});if(!t.ok)throw Error("Login modal responded ".concat(t.status));this._modal.updateContent(await t.text(),()=>this._bindForm())}catch(e){console.error(e),window.location.assign(this._fallbackUrl())}}_sizeDialog(){var e;let t=this._modal.getModal();t.classList.remove("modal-lg"),t.classList.add("login-modal-dialog"),(e=t.querySelector(".modal-dialog"))===null||void 0===e||e.classList.add("modal-dialog-centered")}_bindForm(){var e;let t=this._modal.getModal();this._form=t.querySelector(".login-modal-form"),this._error=t.querySelector(".login-modal-error"),this._submit=t.querySelector(".login-modal-submit"),window.PluginManager.initializePlugins(),this._form.addEventListener("submit",e=>this._onSubmit(e)),(e=this._form.querySelector('input[name="username"]'))===null||void 0===e||e.focus()}async _onSubmit(e){if(e.preventDefault(),!this._form.checkValidity()){this._form.classList.add("was-validated");return}this._setBusy(!0);try{let e=await fetch(this._form.action,{method:"POST",body:new FormData(this._form),headers:{"X-Requested-With":"XMLHttpRequest"}}),t=await e.json();if(t.success){this._afterLogin(t.cartChanged);return}if(t.redirectUrl){window.location.assign(t.redirectUrl);return}this._showError(t.message)}catch(e){console.error(e),window.location.assign(this._fallbackUrl())}}_afterLogin(e){let{redirect:t,cartChangedRedirect:s}=this._redirects,a=e&&s||t;a?window.location.assign(a):window.location.reload()}_showError(e){this._setBusy(!1),this._error.textContent=e,this._error.classList.remove("d-none"),this._form.querySelector('input[name="password"]').value=""}_setBusy(e){this._submit.disabled=e,this._submit.classList.toggle("is-loading",e)}_fallbackUrl(){var e;return((e=document.querySelector(b))===null||void 0===e?void 0:e.getAttribute("href"))||"/account/login"}}},206:(e,t,s)=>{s.d(t,{Z:()=>a});class a{static isTouchDevice(){return"ontouchstart"in document.documentElement}static isIOSDevice(){return a.isIPhoneDevice()||a.isIPadDevice()}static isNativeWindowsBrowser(){return a.isIEBrowser()||a.isEdgeBrowser()}static isIPhoneDevice(){return!!navigator.userAgent.match(/iPhone/i)}static isIPadDevice(){return!!navigator.userAgent.match(/iPad/i)}static isIEBrowser(){return -1!==navigator.userAgent.toLowerCase().indexOf("msie")||!!navigator.userAgent.match(/Trident.*rv:\d+\./)}static isEdgeBrowser(){return!!navigator.userAgent.match(/Edge\/\d+/i)}static getList(){return{"is-touch":a.isTouchDevice(),"is-ios":a.isIOSDevice(),"is-native-windows":a.isNativeWindowsBrowser(),"is-iphone":a.isIPhoneDevice(),"is-ipad":a.isIPadDevice(),"is-ie"
1:a.isIEBrowser(),"is-edge":a.isEdgeBrowser()}}}},266:(e,t,s)=>{s.d(t,{Z:()=>a});class a{static iterate(e,t){if(e instanceof Map||Array.isArray(e))return e.forEach(t);if(e instanceof FormData){for(var s of e.entries())t(s[1],s[0]);return}if(e instanceof NodeList)return e.forEach(t);if(e instanceof HTMLCollection)return Array.from(e).forEach(t);if(e instanceof Object)return Object.keys(e).forEach(s=>{t(e[s],s)});throw Error("The element type ".concat(typeof e," is not iterable!"))}}},363:(e,t,s)=>{s.d(t,{Z:()=>n});var a=s(266);let i="loader",o={BEFORE:"before",INNER:"inner"};class n{create(){if(!this.exists()){if(this.position===o.INNER){this.parent.innerHTML=n.getTemplate();return}this.parent.insertAdjacentHTML(this._getPosition(),n.getTemplate())}}remove(){let e=this.parent.querySelectorAll(".".concat(i));a.Z.iterate(e,e=>e.remove())}exists(){return this.parent.querySelectorAll(".".concat(i)).length>0}_getPosition(){return this.position===o.BEFORE?"afterbegin":"beforeend"}static getTemplate(){return'<div class="'.concat(i,'" role="status">\n                    <span class="').concat("visually-hidden",'">Loading...</span>\n                </div>')}static SELECTOR_CLASS(){return i}constructor(e,t=o.BEFORE){this.parent=e instanceof Element?e:document.body.querySelector(e),this.position=t}}}}]);

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.