PageSourceSearch

https://www.bodylab.dk/theme/b15f317276263b8cf3120f98b282bbbe/js/f…/fel-enhanced-variation.js?1789457597

js bodylab.dk collected 2026-09-24 17:49:06 UTC 18,333 bytes, 1 lines download raw bytes

1(()=>{"use strict";var e={857:e=>{var t=function(e){var t;return!!e&&"object"==typeof e&&"[object RegExp]"!==(t=Object.prototype.toString.call(e))&&"[object Date]"!==t&&e.$$typeof!==r},r="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function i(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a(Array.isArray(e)?[]:{},e,t):e}function n(e,t,r){return e.concat(t).map(function(e){return i(e,r)})}function s(e){return Object.keys(e).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[])}function o(e,t){try{return t in e}catch(e){return!1}}function a(e,r,l){(l=l||{}).arrayMerge=l.arrayMerge||n,l.isMergeableObject=l.isMergeableObject||t,l.cloneUnlessOtherwiseSpecified=i;var c,d,h=Array.isArray(r);return h!==Array.isArray(e)?i(r,l):h?l.arrayMerge(e,r,l):(d={},(c=l).isMergeableObject(e)&&s(e).forEach(function(t){d[t]=i(e[t],c)}),s(r).forEach(function(t){(!o(e,t)||Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))&&(o(e,t)&&c.isMergeableObject(r[t])?d[t]=(function(e,t){if(!t.customMerge)return a;var r=t.customMerge(e);return"function"==typeof r?r:a})(t,c)(e[t],r[t],c):d[t]=i(r[t],c))}),d)}a.all=function(e,t){if(!Array.isArray(e))throw Error("first argument should be an array");return e.reduce(function(e,r){return a(e,r,t)},{})},e.exports=a}},t={};function r(i){var n=t[i];if(void 0!==n)return n.exports;var s=t[i]={exports:{}};return e[i](s,s.exports,r),s.exports}(()=>{r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t}})(),(()=>{r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})}})(),(()=>{r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{class e{static debounce(e,t){let r,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return function(){for(var n=arguments.length,s=Array(n),o=0;o<n;o++)s[o]=arguments[o];i&&!r&&setTimeout(e.bind(e,...s),0),clearTimeout(r),r=setTimeout(e.bind(e,...s),t)}}}class t{static ucFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}static lcFirst(e){return e.charAt(0).toLowerCase()+e.slice(1)}static toDashCase(e){return e.replace(/([A-Z])/g,"-$1").replace(/^-/,"").toLowerCase()}static toLowerCamelCase(e,r){let i=t.toUpperCamelCase(e,r);return t.lcFirst(i)}static toUpperCamelCase(e,r){return r?e.split(r).map(e=>t.ucFirst(e.toLowerCase())).join(""):t.ucFirst(e.toLowerCase())}static parsePrimitive(e){try{return/^\d+(.|,)\d+$/.test(e)&&(e=e.replace(",",".")),JSON.parse(e)}catch(t){return e.toString()}}}class i{static isNode(e){return"object"==typeof e&&null!==e&&(e===document||e===window||e instanceof Node)}static hasAttribute(e,t){if(!i.isNode(e))throw Error("The element must be a valid HTML Node!");return"function"==typeof e.hasAttribute&&e.hasAttribute(t)}static getAttribute(e,t){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(r&&!1===i.hasAttribute(e,t))throw Error('The required property "'.concat(t,'" does not exist!'));if("function"!=typeof e.getAttribute){if(r)throw Error("This node doesn't support the getAttribute function!");return}return e.getAttribute(t)}static getDataAttribute(e,r){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],s=r.replace(/^data(|-)/,""),o=t.toLowerCamelCase(s,"-");if(!i.isNode(e)){if(n)throw Error("The passed node is not a valid HTML Node!");return}if(void 0===e.dataset){if(n)throw Error("This node doesn't support the dataset attribute!");return}let a=e.dataset[o];if(void 0===a){if(n)throw Error('The required data attribute "'.concat(r,'" does not exist on ').concat(e,"!"));return a}return t.parsePrimitive(a)}static querySelector(e,t){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(r&&!i.isNode(e))throw Error("The parent node is not a valid HTML Node!");let n=e.querySelector(t)||!1;if(r&&!1===n)throw Error('The required element "'.concat(t,'" does not exist in parent node!'));return n}static querySelectorAll(e,t){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(r&&!i.isNode(e))throw Error("The parent node is not a valid HTML Node!");let n=e.querySelectorAll(t);if(0===n.length&&(n=!1),r&&!1===n)throw Error('At least one item of "'.concat(t,'" must exist in parent node!'));return n}static getFocusableElements(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return e.querySelectorAll('\n            input:not([tabindex^="-"]):not([disabled]):not([type="hidden"]),\n            select:not([tabindex^="-"]):not([disabled]),\n            textarea:not([tabindex^="-"]):not([disabled]),\n            button:not([tabindex^="-"]):not([disabled]),\n            a[href]:not([tabindex^="-"]):not([disabled]),\n            [tabindex]:not
1([tabindex^="-"]):not([disabled])\n        ')}static getFirstFocusableElement(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return this.getFocusableElements(e)[0]}static getLastFocusableElement(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=this.getFocusableElements(e);return t[t.length-1]}}class n{static iterate(e,t){if(e instanceof Map||Array.isArray(e))return e.forEach(t);if(e instanceof FormData){for(var r of e.entries())t(r[1],r[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(r=>{t(e[r],r)});throw Error("The element type ".concat(typeof e," is not iterable!"))}}var s=r(857),o=r.n(s);class a{publish(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=new CustomEvent(e,{detail:t,cancelable:r});return this.el.dispatchEvent(i),i}subscribe(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this,n=e.split("."),s=r.scope?t.bind(r.scope):t;if(r.once&&!0===r.once){let t=s;s=function(r){i.unsubscribe(e),t(r)}}return this.el.addEventListener(n[0],s),this.listeners.push({splitEventName:n,opts:r,cb:s}),!0}unsubscribe(e){let t=e.split(".");return this.listeners=this.listeners.reduce((e,r)=>([...r.splitEventName].sort().toString()===t.sort().toString()?this.el.removeEventListener(r.splitEventName[0],r.cb):e.push(r),e),[]),!0}reset(){return this.listeners.forEach(e=>{this.el.removeEventListener(e.splitEventName[0],e.cb)}),this.listeners=[],!0}get el(){return this._el}set el(e){this._el=e}get listeners(){return this._listeners}set listeners(e){this._listeners=e}constructor(e=document){this._el=e,e.$emitter=this,this._listeners=[]}}class l{init(){throw Error('The "init" method for the plugin "'.concat(this._pluginName,'" is not defined.'))}update(){}_init(){this._initialized||(this.init(),this._initialized=!0)}_update(){this._initialized&&this.update()}_mergeOptions(e){let r=t.toDashCase(this._pluginName),n=i.getDataAttribute(this.el,"data-".concat(r,"-config"),!1),s=i.getAttribute(this.el,"data-".concat(r,"-options"),!1),a=[this.constructor.options,this.options,e];n&&a.push(window.PluginConfigManager.get(this._pluginName,n));try{s&&a.push(JSON.parse(s))}catch(e){throw console.error(this.el),Error('The data attribute "data-'.concat(r,'-options" could not be parsed to json: ').concat(e.message))}return o().all(a.filter(e=>e instanceof Object&&!(e instanceof Array)).map(e=>e||{}))}_registerInstance(){window.PluginManager.getPluginInstancesFromElement(this.el).set(this._pluginName,this),window.PluginManager.getPlugin(this._pluginName,!1).get("instances").push(this)}_getPluginName(e){return e||(e=this.constructor.name),e}constructor(e,t={},r=!1){if(!i.isNode(e))throw Error("There is no valid element given.");this.el=e,this.$emitter=new a(this.el),this._pluginName=this._getPluginName(r),this.options=this._mergeOptions(t),this._initialized=!1,this._registerInstance(),this._init()}}class c{get(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",i=this._createPreparedRequest("GET",e,r);return this._sendRequest(i,null,t)}post(e,t,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";i=this._getContentType(t,i);let n=this._createPreparedRequest("POST",e,i);return this._sendRequest(n,t,r)}delete(e,t,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";i=this._getContentType(t,i);let n=this._createPreparedRequest("DELETE",e,i);return this._sendRequest(n,t,r)}patch(e,t,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";i=this._getContentType(t,i);let n=this._createPreparedRequest("PATCH",e,i);return this._sendRequest(n,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 ".concat(e.responseURL," was aborted"))}),e.addEventListener("error",()=>{console.warn("the request to ".concat(e.responseURL," failed with status ").concat(e.status))}),e.addEventListener("timeout",()=>{console.warn("the request to ".concat(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}constructor(){this._request=null,this._errorHandlingInternal=!1}}class d extends l{init(){this.setPluginOptions()&&(this.setPluginVars(),this.registerEvents())}setPluginVars(){this._client=new c,this.eventsRegistered=!1,this.isLoading=!1,this.configOptionSelector='.product-detail-configurator-option-input[type="radio"]',this.getProductDetailEl=document.querySelector(".fel-enva-wrapper"),this.options.eventHandlerMap=this.getProductDetailEl?[[this.getProductDetailEl,"click.felBtn",!0]]:[]}setPluginOptions(){var e=document.getElementById("enhanced-variation-plugin-options");return!!(e&&(e=e.dataset.options)&&"string"==typeof e&&(e=JSON.parse(e)))&&(this.options=this.objectMerge(this.options,e),!0)}registerEvents(){this.handleEvent=e=>{if("click"===e.type)return this.clickEventCallback(e,e.target)},this.setEventHandler("add"),window.addEventListener("pagehide",()=>{this.removeLoadingIndicator()})}clickEventCallback(e,t){if(t.classList.contains("fel-btn")){t.dataset.preventDefault&&e.preventDefault(),t.dataset.stopPropagation&&e.stopPropagation(),t.dataset.blur&&t.blur();var r=t.dataset.callback;if(r){if("function"==typeof this[r])return this[r](...arguments);if("function"==typeof window[r])return window[r](...arguments)}}}addLoadingIndicator(){this.putHtml(document.body,"beforeend",'<div class="modal-backdrop modal-backdrop-open fel-loader">\n			<div class="loader" role="status"></div>\n		</div>')}removeLoadingIndicator(){var e=document.querySelector(".modal-backdrop-open.fel-loader");e&&e.remove(),this.removeButtonLoader()}setButtonLoader(e){e.classList.contains("fel-label-loader")||(this.isLoading=!0,e.classList.add("fel-label-loader"),this.putHtml(e,"beforeend",'<div class="fel-btn-loader"><span class="loader"></span></div>'))}removeButtonLoader(){this.isLoading=!1;var e=document.querySelectorAll(".fel-label-loader");e.length&&this.foreach(e,(e,t)=>{t.classList.remove("fel-label-loader");var r=t.querySelector(".fel-btn-loader");r&&r.remove()})}removeParent(e,t){return t.parentNode.classList.add("fel-fade-out"),this.debounce(()=>{t.parentNode.remove()},500)}toggleNextOptionGroup(e,t){let r=t.parentNode.parentNode.querySelectorAll(t.dataset.target);r.length&&(this.foreach(r,(e,t)=>{t.classList.add("hide-filter"),t.classList.remove("show-filter")}),t.parentNode.querySelector(t.dataset.target).classList.add("show-filter","fel-fade-in"))}productPickNextBest(e,t){var r=document.querySelector(t.dataset.target);if(r){if(r.classList.contains("fel-is-combinable")){var i=this.getProductDetailEl.querySelectorAll("input.fel-is-combinable");i&&(this.foreach(this.getProductDetailEl.querySelectorAll(".product-detail-configurator-option.active input:checked"),(e,t)=>{0===e&&t.parentNode.classList.remove("active"),t.checked=!1}),this.foreach(i,(e,t)=>{t.checked=0!==e}))}r.dispatchEvent(new MouseEvent("click",{bubbles:!0}))}else t.after("failed: ".concat(t.dataset.target)),t.remove()}resetVariantSelection(){if(this.filterForm=document.querySelector("[data-fel-enhanced-variation]"),this.filterForm){var e=this.getCheckedOptions();e.length&&this.foreach(e,(e,t)=>{var r=this.filterForm.querySelector('[value="'.concat(t,'"]'));r.checked=!1,r.disabled=null}),this._handleVariantSelection(null,!1),this.removeNotifications(),this.filterForm.classList.remove("fel-filter-form-checked","active-variant")}}handleVariantSelection(e,t){var r=t.parentNode.querySelector(this.configOptionSelector);if(this.isLoading)return e.preventDefault(),!1;if(r){if(this.filterForm=t.form,this.removeNotifications(),r.checked)return r.form.classList.contains("active-variant")||(e.preventDefault(),r.checked=!1,this._handleVariantSelection(r)),!1;e.preventDefault(),r.checked=!0,this.setVariantGroupChecked(r.name),this._handleVariantSelection(r)}}_handleVariantSelection(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],r=this.checkIfAllOptionsAreSetted(),i=this.options.controller_url,n=this.getCheckedOptions(e);if(this.markActiveFilterGroups(e,n,r),r&&("button"===this.options.loadingIndicator?this.setButtonLoader(e.nextElementSibling):this.addLoadingIndicator(),"default"===this.options.strategy))return this.filterForm.dispatchEvent(new Event("change",{bubbles:!0}));t&&n.length&&(i+="?"+new URLSearchParams({checked:n.join("|")}).toString(),this.options.switchUrl&&(i+="&switchUrl=true")),this._client.get(i,t=>{if(t=JSON.parse(t),r){if(void 0!==t.url){if(t.url)return location.href=t.url;e.checked=!1,e.disabled=!0,this.notification(e.parentNode.parentNode.parentNode,"warning",this.options.message.variation_not_found)}}else this.setCombinables(t);this.removeLoadingIndicator(),this.$emitter.publish("felEnhancedVariationFinished")})}markActiveFilterGroups(e,t,r){if(e&&void 0!==e.parentNode&&null!==e.parentNode){var i=e.parentNode.offsetParent;e.checked?i.classList.add("fel-active-group"):i.classList.remove("fel-active-group"),0===t.length&&this.filterForm.classList.remove("fel-filter-form-checked"),!this.filterForm.classList.contains("active-variant")&&void 0!==this.filterForm.dataset.requireFirstFilterOneByOne&&(this.foreach(this.filterForm.querySelectorAll(".product-detail-configurator-option-label.fel-pe-none"),(e,t)=>{t.classList.remove("fel-pe-none")}),0===t.length?void 0!==e.nextElementSibling&&e.nextElementSibling.classList.remove("fel-pe-none"):1<t.length&&!1===r&&this.foreach(t,(e,r)=>{var i=this.filterForm.querySelector('[value="'.concat(r,'"]'));i&&t.length!==e+1&&i.nextElementSibling.classList.add("fel-pe-none")}))}}
1setCombinables(e){void 0!==e.options&&this.foreach(this.filterForm.querySelectorAll(this.configOptionSelector),(t,r)=>{r.disabled=null,e.options.includes(r.value)?r.classList.add("is-combinable"):r.classList.remove("is-combinable")})}getCheckedOptions(){let e=[];return this.foreach(this.filterForm.querySelectorAll("".concat(this.configOptionSelector,":checked")),(t,r)=>{e.push(r.value)}),e}checkIfAllOptionsAreSetted(){return Math.round(this.filterForm.dataset.configuratorCount)===this.getCheckedOptions().length}setVariantGroupChecked(e){var t=this.filterForm.querySelector('[data-option-group-id="'.concat(e,'"]'));t&&!t.classList.contains("fel-group-checked")&&t.classList.add("fel-group-checked"),this.filterForm.classList.contains("fel-filter-form-checked")||this.filterForm.classList.add("fel-filter-form-checked")}notification(e,t,r){this.putHtml(e,"afterbegin",'<div class="fel-notification fel-fade-in py-1">\n			<span class="alert-'.concat(t,' p-1 px-2 me-1 fel-btn" data-callback="removeNotifications">').concat(r,'</span>\n			<span class="fel-btn bg-light p-1 px-2" data-callback="resetVariantSelection">X</span>\n		</div>'))}removeNotifications(){var e=document.querySelectorAll(".fel-notification");e.length&&this.foreach(e,(e,t)=>{t.remove()})}debounce(){return"function"==typeof arguments[0]?setTimeout(()=>{arguments[0].apply()},arguments[1]||0):void 0}domGet(e,t){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];return i.querySelector(e,t,r)}domGetAll(e,t){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];return i.querySelectorAll(e,t,r)}foreach(e,t){return n.iterate(e,function(e,r){t(r,e)})}objectMerge(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];var i=(e,t)=>(Object.entries(t).forEach(t=>{let[r,n]=t;e[r]=n&&"object"==typeof n?i(e[r]||{},n):n}),e);return t.reduce(i,{})}putHtml(e,t,r){e.insertAdjacentHTML(t,r)}removeEvents(){this.setEventHandler("remove")}resetEvents(){this.removeEvents(),this.registerEvents()}setEventHandler(e){var t={add:"addEventListener",remove:"removeEventListener"};if("remove"===e&&!this.eventsRegistered)return!1;"add"===e&&this.eventsRegistered&&this.removeEvents(),this.foreach(this.options.eventHandlerMap,(r,i)=>{if(void 0!==i[1]){var n=i[1].split(".");i[0][t[e]](n[0],this,i[2]||!0)}}),this.eventsRegistered="add"===e}}d.options={strategy:"default"};let h=window.PluginManager;h.register("FelEnhancedVariation",d,"[data-fel-enhanced-variation]"),h.register("FelPreselect",class extends l{init(){var t=this.el.dataset.felSetPreselect;if(t&&(t=t.split("|")).length){var r=e=>(this.dispatchCustomEvent(e[0]),delete e[0],e.shift(),e);t=r(t);var i=PluginManager.getPluginInstances("FelEnhancedVariation");i.length&&i[0].$emitter.subscribe("felEnhancedVariationFinished",n=>{t.length&&e.debounce(()=>{(t=r(t)).length||i[0].$emitter.unsubscribe("felEnhancedVariationFinished")},150).apply()})}}dispatchCustomEvent(e){var t=i.querySelector(this.el,'input[value="'.concat(e,'"]'),!1);if(t&&!t.checked){var r=t.parentNode.querySelector("label");r&&t.classList.contains("is-combinable")&&!t.classList.contains("fel-is-combinable")&&r.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0}))}}},"[data-fel-set-preselect]")})()})();

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.