@everymatrix/bonus-elevate-levels 1.94.36 → 1.94.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bonus-elevate-levels/bonus-elevate-levels.esm.js +1 -1
- package/dist/bonus-elevate-levels/bonus-elevate-levels_5.entry.js +1 -1
- package/dist/cjs/bonus-elevate-levels.cjs.js +1 -1
- package/dist/cjs/bonus-elevate-levels_5.cjs.entry.js +192 -31
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/elevate-level-list/elevate-level-list.css +14 -0
- package/dist/collection/components/elevate-level-list/elevate-level-list.js +197 -30
- package/dist/esm/bonus-elevate-levels.js +1 -1
- package/dist/esm/bonus-elevate-levels_5.entry.js +192 -31
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/elevate-level-list/elevate-level-list.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e,b as l}from"./index-422aaa76.js";export{s as setNonce}from"./index-422aaa76.js";import{g as
|
|
1
|
+
import{p as e,b as l}from"./index-422aaa76.js";export{s as setNonce}from"./index-422aaa76.js";import{g as n}from"./app-globals-0f993ce5.js";(()=>{const l=import.meta.url,n={};return""!==l&&(n.resourcesUrl=new URL(".",l).href),e(n)})().then((async e=>(await n(),l([["bonus-elevate-levels_5",[[1,"bonus-elevate-levels",{clientStyling:[513,"client-styling"],clientStylingUrl:[513,"client-styling-url"],mbSource:[513,"mb-source"],endpoint:[513],language:[513],translationUrl:[513,"translation-url"],selectedLevelId:[1537,"selected-level-id"],showDefault:[4,"show-default"],elevateLevelParamProxy:[32],elevateLevels:[32],currentLevel:[32],errorMessage:[32]},[[0,"selectedLevelChanged","selectedLevelChangedHandler"],[2,"elevateLevelsDataChange","elevateLevelsDataChangeHandler"]],{selectedLevelId:["selectedLevelIdChangedHandler"],elevateLevels:["selectedLevelIdChangedHandler"],endpoint:["onSessionOrEndpointChange"],language:["onSessionOrEndpointChange"],translationUrl:["handleNewTranslations"]}],[0,"elevate-level-list",{levels:[16],language:[1],selectedLevelId:[1537,"selected-level-id"],showSliderButton:[32],touchPosStart:[32],touchPosEnd:[32],offset:[32]},[[1,"touchstart","onTouchStart"],[1,"touchmove","onTouchMove"],[1,"touchend","onTouchEnd"],[9,"resize","handleResize"]],{selectedLevelId:["levelsChangedHandler"]}],[0,"elevate-level-presentation",{elevateLevel:[16]}],[0,"elevate-levels-data",{scopeParams:[1544,"scope-params"]}],[4,"general-styling-wrapper",{clientStyling:[1,"client-styling"],clientStylingUrl:[1,"client-styling-url"],mbSource:[1,"mb-source"],translationUrl:[1,"translation-url"],targetTranslations:[16]},null,{mbSource:["handleMbSourceChange"],clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingUrlChange"]}]]]],e))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,h as t,c as i,H as s,g as l}from"./index-422aaa76.js";const n={en:{level:"level",seeAll:"See All",termsAndConditions:"Terms & Conditions",loadElevateLevelErrorMessage:"Error when load elevate levels",noLevelsSet:"There is no level set",points:"Points"},fr:{level:"level",seeAll:"See All",termsAndConditions:"Terms & Conditions",loadElevateLevelErrorMessage:"Error when load elevate levels",noLevelsSet:"There is no level set",points:"Points"},hr:{level:"Razina",seeAll:"Vidi sve",privilegesFor:"Privilegije za",termsAndConditions:"Uvjeti i odredbe",noLevelsSet:"There is no level set",points:"Points"},ro:{level:"level",seeAll:"See All",termsAndConditions:"Terms & Conditions",loadElevateLevelErrorMessage:"Error when load elevate levels",noLevelsSet:"There is no level set",points:"Points"},tr:{level:"seviye",seeAll:"Tümünü Gör",termsAndConditions:"Şartlar ve Koşullar",loadElevateLevelErrorMessage:"Seviyeler yüklenirken hata oluştu",noLevelsSet:"Tanımlı seviye bulunmuyor",points:"Puanlar"}},o=e=>new Promise((t=>{fetch(e).then((e=>e.json())).then((e=>{Object.keys(e).forEach((t=>{n[t]||(n[t]={});for(let i in e[t])n[t][i]=e[t][i]})),t(!0)})).catch((e=>{console.error("Failed to load translations:",e),t(!1)}))})),a=(e,t,i)=>{let s=n[void 0!==t&&t in n?t:"en"][e]||e;if(null==i?void 0:i.values)for(const[e,t]of Object.entries(i.values)){const i=new RegExp(`{${e}}`,"g");s=s.replace(i,t)}return s},r=class{constructor(t){e(this,t),this.clientStyling="",this.clientStylingUrl="",this.mbSource=void 0,this.endpoint=void 0,this.language="en",this.translationUrl="",this.selectedLevelId=void 0,this.showDefault=void 0,this.elevateLevelParamProxy=void 0,this.elevateLevels=[],this.currentLevel=void 0,this.errorMessage=void 0}selectedLevelChangedHandler(e){e.detail&&(this.currentLevel=Object.assign({},e.detail.level))}selectedLevelIdChangedHandler(){if(this.selectedLevelId&&this.elevateLevels){const e=this.elevateLevels.filter((e=>e.id==this.selectedLevelId))[0];this.currentLevel=Object.assign({},e)}}onSessionOrEndpointChange(){this.elevateLevelParamProxy=Object.assign(Object.assign({},this.elevateLevelParamProxy),{endpoint:this.endpoint,language:this.language})}elevateLevelsDataChangeHandler(e){e.detail&&(e.detail.currentLevel&&(this.currentLevel=Object.assign({},e.detail.currentLevel)),e.detail.elevateLevels&&(this.elevateLevels=[...e.detail.elevateLevels]),e.detail.clearError&&(this.errorMessage=null),e.detail.errorMessage&&e.detail.errorMessage.errorWhenLoadElevateLevels&&(this.errorMessage=a("loadElevateLevelErrorMessage",this.language)))}onTCClick(){window.postMessage({type:"termAndConditionClicked"},window.location.href)}handleNewTranslations(){o(this.translationUrl)}async componentWillLoad(){this.elevateLevelParamProxy={endpoint:this.endpoint,language:this.language,selectedLevelId:this.selectedLevelId,showDefault:this.showDefault},this.translationUrl&&await o(this.translationUrl)}render(){var e;return t("div",{key:"c506affafae3a59eb45b22d0a73d0f3e070767a4",class:"ElevateLevelContent"},t("elevate-levels-data",{key:"90159b78c27186afbda74016cce2172fa051430d",scopeParams:this.elevateLevelParamProxy}),t("div",{key:"02518d5c73df9144f274891778d10c4df04bff92",class:"LevelContent"},(null===(e=this.elevateLevels)||void 0===e?void 0:e.length)?t("elevate-level-list",{language:this.language,selectedLevelId:this.selectedLevelId,levels:this.elevateLevels}):a("noLevelsSet",this.language),this.currentLevel&&t("elevate-level-presentation",{key:"3c25372f312b38a780ad1d5823a3872d3a9de929",elevateLevel:this.currentLevel})),this.errorMessage&&t("div",{key:"00ee0bdab9f324a309a925f3d1465eceffae502d"},this.errorMessage),t("general-styling-wrapper",{key:"e9e36fd78d644bb2035256ff06a4118d776b1778",clientStyling:this.clientStyling,clientStylingUrl:this.clientStylingUrl,targetTranslations:n,translationUrl:this.translationUrl,mbSource:this.mbSource}))}static get watchers(){return{selectedLevelId:["selectedLevelIdChangedHandler"],elevateLevels:["selectedLevelIdChangedHandler"],endpoint:["onSessionOrEndpointChange"],language:["onSessionOrEndpointChange"],translationUrl:["handleNewTranslations"]}}};var h;r.style=":host{display:block}.ElevateLevelContent{padding:20px;position:relative}.ElevateLevelContent .Privileges{padding-bottom:30px}.ElevateLevelContent .tc{position:absolute;right:10px;bottom:10px;text-align:right;display:none}",function(e){e[e.slideToRight=1]="slideToRight",e[e.slideToLeft=-1]="slideToLeft"}(h||(h={}));const d=class{constructor(t){var s;e(this,t),this.selectedLevelChanged=i(this,"selectedLevelChanged",7),this.minOffset=0,this.isMobile=!!((s=window.navigator.userAgent).toLowerCase().match(/android/i)||s.toLowerCase().match(/blackberry|bb/i)||s.toLowerCase().match(/iphone|ipad|ipod/i)||s.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i)),this.levels=void 0,this.language=void 0,this.selectedLevelId=void 0,this.showSliderButton=!1,this.touchPosStart=void 0,this.touchPosEnd=void 0,this.offset=0}onLevelClicked(e){this.selectedLevelChanged.emit({level:e}),this.selectedLevelId=e.id}levelsChangedHandler(){this.initOffsetOfLevelItems()}initOffsetOfLevelItems(){if(!this.levels||0==this.levels.length||!this.selectedLevelId)return;const e=this.levels.findIndex((e=>this.selectedLevelId==e.id));if(this.onLevelClicked(this.levels[-1==e?0:e]),this.levels.length<=this.moveCountForOneTouch)return;let t=Math.floor((-1==e?1:e+1)/this.moveCountForOneTouch)*this.moveCountForOneTouch*this.childElementWidth*-1;this.offset=t<=this.minOffset?this.minOffset:t>=0?0:t}onTouchStart(e){this.touchPosStart={clientX:e.touches[0].clientX,clientY:e.touches[0].clientY}}onTouchMove(e){this.touchPosEnd={clientX:e.touches[0].clientX,clientY:e.touches[0].clientY};const t=this.touchPosEnd.clientX-this.touchPosStart.clientX,i=this.touchPosEnd.clientY-this.touchPosStart.clientY;Math.abs(t)>Math.abs(i)&&this.slideTo(t>0?h.slideToRight:h.slideToLeft)}slideTo(e){let t=this.levelsElement.offsetLeft+this.childElementWidth*this.moveCountForOneTouch*e;if(t%this.childElementWidth!=0){const i=Math.floor(t/this.childElementWidth)*this.childElementWidth,s=Math.ceil(t/this.childElementWidth)*this.childElementWidth;t=e==h.slideToRight?i:s}this.offset=t<this.minOffset?this.minOffset:t>=0?0:t}initLevelSlider(){var e;if(!(null===(e=this.levelsElement)||void 0===e?void 0:e.firstElementChild))return void console.log("Widget[elevate-level-list] DOM is not ready.");this.showSliderButton=!this.isMobile&&this.levelsElement.clientWidth>this.levelsElement.parentElement.clientWidth,this.minOffset=this.levelsElement.parentElement.clientWidth-this.levelsElement.clientWidth,this.childElementWidth=this.levelsElement.firstElementChild.clientWidth,this.moveCountForOneTouch=Math.ceil(this.levelsElement.parentElement.clientWidth/this.childElementWidth)-1;const t=this.levelsElement.childElementCount;this.childElementWidth+=(this.levelsElement.clientWidth-this.childElementWidth*t)/(t-1)}debounce(e,t){{let i;return()=>{clearTimeout(i),i=setTimeout((()=>{e()}),t)}}}convertNumberToCompactForm(e){return e>=1e9?(e/1e9).toFixed(1).replace(/\.0$/,"")+"b":e>=1e6?(e/1e6).toFixed(1).replace(/\.0$/,"")+"m":e>=1e3?(e/1e3).toFixed(1).replace(/\.0$/,"")+"k":e.toString()}handleResize(){this.debounce(this.initLevelSlider.bind(this),200)()}componentDidRender(){this.host.componentOnReady().then((()=>{this.initLevelSlider()}))}render(){return t(s,{key:"c2eb983ff3df4868204eec8e527efa08c9e5afa0"},this.levels&&[t("div",{key:"9f6563c030a7725761b9a73cffb8e2d8d8f47c32",class:`SliderButton LeftButton ${0==this.offset?"Disabled":""} ${this.showSliderButton?"":"Hidden"}`,onClick:()=>this.slideTo(h.slideToRight)},t("svg",{key:"9e3d3422bd2171d26821c1f74e3ab7418b97643d",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},t("path",{key:"ac0002e40e037edd0c0893c9250f36e18e451f16","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 19l-7-7 7-7"}))),t("div",{key:"242903f38deb464844d722e0e7fe90665de99d6a",class:"LevelItemsWrapper"},t("div",{key:"739328ff99ecd777b9e2ff6914034a5bbc7eac90",style:{left:`${this.offset}px`},class:"LevelItems "+(this.isMobile?"Mobile":""),id:"levelItems",ref:e=>{this.levelsElement=e}},this.levels.map(((e,i)=>t("div",{class:"Item "+(this.selectedLevelId==e.id?"Active":""),onClick:this.onLevelClicked.bind(this,e)},t("img",{alt:`Presentation Icon for ${e.presentation.displayName}`,class:"LevelImg",src:e.presentation.asset}),t("span",{class:"LevelName",title:e.presentation.displayName},e.presentation.displayName),t("span",{class:"LevelPoints"},0==i?"":">",this.convertNumberToCompactForm(e.firstEntryPoints)," ",a("points",this.language))))))),t("div",{key:"2366c09b46bfec309bd4f8d5991d457f04dbf038",class:`SliderButton RightButton ${this.offset<=this.minOffset?"Disabled":""} ${this.showSliderButton?"":"Hidden"}`,onClick:()=>this.slideTo(h.slideToLeft)},t("svg",{key:"c52ef4f99444d1185e9b8ce4287f0f2886c622ae",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},t("path",{key:"acc266646133bb636b52f8776380e6aedc93f937","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"})))])}get host(){return l(this)}static get watchers(){return{selectedLevelId:["levelsChangedHandler"]}}};d.style="elevate-level-list{display:flex;flex-direction:row}.LevelItemsWrapper{display:flex;flex:1;margin-top:10px;min-height:30px;transition-property:all;position:relative;height:138px;overflow-x:hidden}.Mobile.LevelItems{overflow-x:hidden}.LevelItems{overflow-x:auto;display:flex;flex-direction:row;gap:10px;left:0;position:absolute;transition:left 0.5s ease-in-out}.LevelItems .Item:hover,.LevelItems .Item.Active{background-color:var(--emw--color-gray-50, rgb(244, 244, 244));box-shadow:0px 4px 13px 0px rgba(0, 0, 0, 0.25)}.LevelItems .Item{width:86px;height:125px;border-radius:15px;text-align:center;display:flex;flex-direction:column;cursor:pointer}.LevelItems .Item .LevelName{font-size:13px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.LevelItems .Item .LevelPoints{color:var(--emw--color-gray-100, rgb(118, 113, 113));font-size:10px}.LevelItems .Item .LevelImg{width:65px;height:68px;margin:11px auto}.SliderButton{display:flex;width:29px;align-items:center;cursor:pointer}.SliderButton.Disabled svg{stroke:var(--emw--color-gray-50, #cbc5c5)}.SliderButton.Hidden{display:none}";const c=class{constructor(t){e(this,t),this.elevateLevel=void 0}render(){return t(s,{key:"16d128717e716f7ca7d3bb77fc3a2e67209318b6"},t("div",{key:"658657abdfc64844bd2af40562efe40385e1735a",class:"Row Desc"},t("h3",{key:"ec5871c2f810c8c120bf99510717381175bc1ef4"},this.elevateLevel.presentation.displayName),t("p",{key:"865915c6eea90295238fb47eaa91c8f968199ca5"},t("span",{key:"2b90c6c5d6957b73fc4a0f53d53da0ca023a4f0a",class:"TxtDesc",innerHTML:this.elevateLevel.presentation.description}))))}};c.style=":host{display:block}.PriviliegeList{padding-inline-start:5px}.PriviliegeList li{display:flex}.PriviliegeList li .Img{width:80px}.PriviliegeList li .Img img{width:60px;margin:10px}.PriviliegeList li .Content h4{text-transform:capitalize;margin-block-start:10px}";var v,f,p,g="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},u={exports:{}};v=u,f=u.exports,p=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==g)return g;throw new Error("unable to locate global object")}(),v.exports=f=p.fetch,p.fetch&&(f.default=p.fetch.bind(p)),f.Headers=p.Headers,f.Request=p.Request,f.Response=p.Response;const b=u.exports,w=class{constructor(t){e(this,t),this.elevateLevelsDataChange=i(this,"elevateLevelsDataChange",7),this.scopeParams=void 0}async componentWillRender(){if(!this.scopeParams.endpoint)return;let e=new URL(`${this.scopeParams.endpoint}/v1/elevate/levels?language=${this.scopeParams.language}`);await b(e.href).then((e=>e.json())).then((e=>{const t=e.data.sort(((e,t)=>e.firstEntryPoints<t.firstEntryPoints?-1:1));let i=this.scopeParams.selectedLevelId;if(!i&&this.scopeParams.showDefault&&t.length>0&&(i=t[0].id),i){const e=t.filter((e=>e.id==i))[0];this.elevateLevelsDataChange.emit({currentLevel:e})}this.elevateLevelsDataChange.emit({clearError:!0}),this.elevateLevelsDataChange.emit({elevateLevels:t})})).catch((e=>{this.elevateLevelsDataChange.emit({errorMessage:{type:"errorWhenLoadElevateLevels",err:e}}),console.error(e)}))}};w.style=":host{display:block}";const m="__WIDGET_GLOBAL_STYLE_CACHE__";function y(e,t){if(e){const i=document.createElement("style");i.innerHTML=t,e.appendChild(i)}}function L(e,t){if(!e||!t)return;const i=new URL(t);fetch(i.href).then((e=>e.text())).then((t=>{const i=document.createElement("style");i.innerHTML=t,e&&e.appendChild(i)})).catch((e=>{console.error("There was an error while trying to load client styling from URL",e)}))}function x(e,t,i,s=!1){if(!window.emMessageBus)return;if(!("adoptedStyleSheets"in Document.prototype)||!s)return i=function(e,t){const i=document.createElement("style");return window.emMessageBus.subscribe(t,(t=>{e&&(i.innerHTML=t,e.appendChild(i))}))}(e,t),i;window[m]||(window[m]={}),i=function(e,t){return window.emMessageBus.subscribe(t,(i=>{if(!e)return;const s=e.getRootNode(),l=window[m];let n=l[t]&&l[t].sheet;n?l[t].refCount=l[t].refCount+1:(n=new CSSStyleSheet,n.replaceSync(i),l[t]={sheet:n,refCount:1});const o=s.adoptedStyleSheets||[];o.includes(n)||(s.adoptedStyleSheets=[...o,n])}))}(e,t);const l=i.unsubscribe.bind(i);return i.unsubscribe=()=>{if(window[m][t]){const e=window[m][t];e.refCount>1?e.refCount=e.refCount-1:delete window[m][t]}l()},i}const C=class{constructor(t){e(this,t),this.stylingAppends=!1,this.clientStyling="",this.clientStylingUrl="",this.mbSource=void 0,this.translationUrl="",this.targetTranslations=void 0}componentDidLoad(){this.el&&(this.mbSource&&x(this.el,`${this.mbSource}.Style`,this.stylingSubscription),this.clientStyling&&y(this.el,this.clientStyling),this.clientStylingUrl&&L(this.el,this.clientStylingUrl),this.stylingAppends=!0)}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}handleMbSourceChange(e,t){e!=t&&x(this.el,`${this.mbSource}.Style`,this.stylingSubscription)}handleClientStylingChange(e,t){e!=t&&y(this.el,this.clientStyling)}handleClientStylingUrlChange(e,t){e!=t&&this.clientStylingUrl&&L(this.el,this.clientStylingUrl)}componentDidRender(){this.stylingAppends||(this.clientStyling&&y(this.el,this.clientStyling),this.clientStylingUrl&&L(this.el,this.clientStylingUrl),this.stylingAppends=!0)}async componentWillLoad(){const e=[];if(this.translationUrl){const s=(t=this.translationUrl,i=this.targetTranslations,new Promise((e=>{fetch(t).then((e=>e.json())).then((t=>{Object.keys(t).forEach((e=>{i[e]=i[e]||{},Object.keys(t[e]).forEach((s=>{if(!i.en[s])return;const l=i.en[s];"object"==typeof t[e][s]?(i[e][s]=i[e][s]||Object.assign({},l),Object.keys(t[e][s]).forEach((l=>{i[e][s][l]=t[e][s][l]}))):i[e][s]=t[e][s]||Object.assign({},l)}))})),e(!0)})).catch((t=>{console.error("Failed to load translations:",t),e(!1)}))})));e.push(s)}var t,i;return await Promise.all(e)}render(){return t("div",{key:"e660ceb69f5e848c788c3924fc814c0fa7a777a2",class:"StyleShell"},t("slot",{key:"35014b6c0c32532af11e6a629ba9b13942504d21",name:"mainContent"}))}get el(){return l(this)}static get watchers(){return{mbSource:["handleMbSourceChange"],clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingUrlChange"]}}};C.style=":host{display:block}";export{r as bonus_elevate_levels,d as elevate_level_list,c as elevate_level_presentation,w as elevate_levels_data,C as general_styling_wrapper}
|
|
1
|
+
import{r as e,h as t,c as i,H as s,g as n}from"./index-422aaa76.js";const l={en:{level:"level",seeAll:"See All",termsAndConditions:"Terms & Conditions",loadElevateLevelErrorMessage:"Error when load elevate levels",noLevelsSet:"There is no level set",points:"Points"},fr:{level:"level",seeAll:"See All",termsAndConditions:"Terms & Conditions",loadElevateLevelErrorMessage:"Error when load elevate levels",noLevelsSet:"There is no level set",points:"Points"},hr:{level:"Razina",seeAll:"Vidi sve",privilegesFor:"Privilegije za",termsAndConditions:"Uvjeti i odredbe",noLevelsSet:"There is no level set",points:"Points"},ro:{level:"level",seeAll:"See All",termsAndConditions:"Terms & Conditions",loadElevateLevelErrorMessage:"Error when load elevate levels",noLevelsSet:"There is no level set",points:"Points"},tr:{level:"seviye",seeAll:"Tümünü Gör",termsAndConditions:"Şartlar ve Koşullar",loadElevateLevelErrorMessage:"Seviyeler yüklenirken hata oluştu",noLevelsSet:"Tanımlı seviye bulunmuyor",points:"Puanlar"}},o=e=>new Promise((t=>{fetch(e).then((e=>e.json())).then((e=>{Object.keys(e).forEach((t=>{l[t]||(l[t]={});for(let i in e[t])l[t][i]=e[t][i]})),t(!0)})).catch((e=>{console.error("Failed to load translations:",e),t(!1)}))})),a=(e,t,i)=>{let s=l[void 0!==t&&t in l?t:"en"][e]||e;if(null==i?void 0:i.values)for(const[e,t]of Object.entries(i.values)){const i=new RegExp(`{${e}}`,"g");s=s.replace(i,t)}return s},r=class{constructor(t){e(this,t),this.clientStyling="",this.clientStylingUrl="",this.mbSource=void 0,this.endpoint=void 0,this.language="en",this.translationUrl="",this.selectedLevelId=void 0,this.showDefault=void 0,this.elevateLevelParamProxy=void 0,this.elevateLevels=[],this.currentLevel=void 0,this.errorMessage=void 0}selectedLevelChangedHandler(e){e.detail&&(this.currentLevel=Object.assign({},e.detail.level))}selectedLevelIdChangedHandler(){if(this.selectedLevelId&&this.elevateLevels){const e=this.elevateLevels.filter((e=>e.id==this.selectedLevelId))[0];this.currentLevel=Object.assign({},e)}}onSessionOrEndpointChange(){this.elevateLevelParamProxy=Object.assign(Object.assign({},this.elevateLevelParamProxy),{endpoint:this.endpoint,language:this.language})}elevateLevelsDataChangeHandler(e){e.detail&&(e.detail.currentLevel&&(this.currentLevel=Object.assign({},e.detail.currentLevel)),e.detail.elevateLevels&&(this.elevateLevels=[...e.detail.elevateLevels]),e.detail.clearError&&(this.errorMessage=null),e.detail.errorMessage&&e.detail.errorMessage.errorWhenLoadElevateLevels&&(this.errorMessage=a("loadElevateLevelErrorMessage",this.language)))}onTCClick(){window.postMessage({type:"termAndConditionClicked"},window.location.href)}handleNewTranslations(){o(this.translationUrl)}async componentWillLoad(){this.elevateLevelParamProxy={endpoint:this.endpoint,language:this.language,selectedLevelId:this.selectedLevelId,showDefault:this.showDefault},this.translationUrl&&await o(this.translationUrl)}render(){var e;return t("div",{key:"c506affafae3a59eb45b22d0a73d0f3e070767a4",class:"ElevateLevelContent"},t("elevate-levels-data",{key:"90159b78c27186afbda74016cce2172fa051430d",scopeParams:this.elevateLevelParamProxy}),t("div",{key:"02518d5c73df9144f274891778d10c4df04bff92",class:"LevelContent"},(null===(e=this.elevateLevels)||void 0===e?void 0:e.length)?t("elevate-level-list",{language:this.language,selectedLevelId:this.selectedLevelId,levels:this.elevateLevels}):a("noLevelsSet",this.language),this.currentLevel&&t("elevate-level-presentation",{key:"3c25372f312b38a780ad1d5823a3872d3a9de929",elevateLevel:this.currentLevel})),this.errorMessage&&t("div",{key:"00ee0bdab9f324a309a925f3d1465eceffae502d"},this.errorMessage),t("general-styling-wrapper",{key:"e9e36fd78d644bb2035256ff06a4118d776b1778",clientStyling:this.clientStyling,clientStylingUrl:this.clientStylingUrl,targetTranslations:l,translationUrl:this.translationUrl,mbSource:this.mbSource}))}static get watchers(){return{selectedLevelId:["selectedLevelIdChangedHandler"],elevateLevels:["selectedLevelIdChangedHandler"],endpoint:["onSessionOrEndpointChange"],language:["onSessionOrEndpointChange"],translationUrl:["handleNewTranslations"]}}};var h;r.style=":host{display:block}.ElevateLevelContent{padding:20px;position:relative}.ElevateLevelContent .Privileges{padding-bottom:30px}.ElevateLevelContent .tc{position:absolute;right:10px;bottom:10px;text-align:right;display:none}",function(e){e[e.slideToRight=1]="slideToRight",e[e.slideToLeft=-1]="slideToLeft"}(h||(h={}));const d=class{constructor(t){var s;e(this,t),this.selectedLevelChanged=i(this,"selectedLevelChanged",7),this.minOffset=0,this.isMobile=!!((s=window.navigator.userAgent).toLowerCase().match(/android/i)||s.toLowerCase().match(/blackberry|bb/i)||s.toLowerCase().match(/iphone|ipad|ipod/i)||s.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i)),this.levels=void 0,this.language=void 0,this.selectedLevelId=void 0,this.showSliderButton=!1,this.touchPosStart=void 0,this.touchPosEnd=void 0,this.offset=0}centerLevelItem(e){if(!this.isMobile||!this.levelsElement||e<0||!this.levelsElement.children[e])return;const t=this.levelsElement.parentElement;if(!t)return;const i=this.levelsElement.children[e],s=t.clientWidth,n=Math.min(0,s-this.levelsElement.scrollWidth);let l=s/2-(i.offsetLeft+i.offsetWidth/2);l=l<n?n:l>0?0:l,this.minOffset=n,this.offset=l}moveToLevelItem(e,t=!1){if(!this.levelsElement||e<0||!this.levelsElement.children[e])return;const i=this.levelsElement.parentElement;if(!i)return;const s=this.levelsElement.children[e],n=i.clientWidth,l=this.isMobile?this.levelsElement.scrollWidth:this.levelsElement.clientWidth,o=Math.min(0,n-l);if(l<=n)return this.minOffset=0,void(this.offset=0);const a=s.offsetLeft,r=s.offsetWidth;let h;if(t)h=n/2-(a+r/2);else{const e=-this.offset,t=a+r;if(a>=e&&t<=e+n)return;h=a<e?-a:n-t}h=h<o?o:h>0?0:h,this.minOffset=o,this.offset=h}onLevelClicked(e){var t,i;if(this.selectedLevelChanged.emit({level:e}),this.selectedLevelId=e.id,this.isMobile){const s=null!==(i=null===(t=this.levels)||void 0===t?void 0:t.findIndex((t=>t.id===e.id)))&&void 0!==i?i:-1;requestAnimationFrame((()=>{this.centerLevelItem(s)}))}}levelsChangedHandler(){this.initOffsetOfLevelItems()}initOffsetOfLevelItems(){if(!this.levels||0===this.levels.length||!this.selectedLevelId)return;const e=this.levels.findIndex((e=>this.selectedLevelId===e.id));if(-1===e&&this.levels[0])return void(this.selectedLevelId=this.levels[0].id);if(this.levels.length<=1)return void(this.offset=0);const t=-1===e?0:e;requestAnimationFrame((()=>{var e;if(this.isMobile)return void this.moveToLevelItem(t,!0);const i=null===(e=this.levelsElement)||void 0===e?void 0:e.parentElement;return i&&this.levelsElement?this.levelsElement.clientWidth<=i.clientWidth?(this.offset=0,void(this.minOffset=0)):void this.moveToLevelItem(t,!1):void 0}))}onTouchStart(e){this.isMobile&&(this.touchPosStart={clientX:e.touches[0].clientX,clientY:e.touches[0].clientY},this.touchPosEnd=this.touchPosStart)}onTouchMove(e){this.isMobile&&(this.touchPosEnd={clientX:e.touches[0].clientX,clientY:e.touches[0].clientY})}onTouchEnd(){if(!this.isMobile||!this.touchPosStart||!this.touchPosEnd||!this.levels||this.levels.length<=1)return;const e=this.touchPosEnd.clientX-this.touchPosStart.clientX,t=this.touchPosEnd.clientY-this.touchPosStart.clientY;Math.abs(e)<=30||Math.abs(e)<=Math.abs(t)||this.slideTo(e>0?h.slideToRight:h.slideToLeft)}slideTo(e){if(!this.levelsElement||!this.childElementWidth||!this.moveCountForOneTouch||this.levelsElement.childElementCount<=1)return void(this.offset=0);let t=(this.isMobile?this.offset:this.levelsElement.offsetLeft)+this.childElementWidth*this.moveCountForOneTouch*e;if(t%this.childElementWidth!=0){const i=Math.floor(t/this.childElementWidth)*this.childElementWidth,s=Math.ceil(t/this.childElementWidth)*this.childElementWidth;t=e===h.slideToRight?i:s}this.offset=t<this.minOffset?this.minOffset:t>=0?0:t}initLevelSlider(){var e;if(!(null===(e=this.levelsElement)||void 0===e?void 0:e.firstElementChild))return void console.log("Widget[elevate-level-list] DOM is not ready.");const t=this.levelsElement.parentElement.clientWidth,i=this.isMobile?this.levelsElement.scrollWidth:this.levelsElement.clientWidth,s=this.levelsElement.childElementCount;if(s<=1)return this.showSliderButton=!1,this.minOffset=0,this.offset=0,this.childElementWidth=this.levelsElement.firstElementChild.clientWidth,void(this.moveCountForOneTouch=1);this.showSliderButton=!this.isMobile&&this.levelsElement.clientWidth>t,this.minOffset=t-i,this.childElementWidth=this.levelsElement.firstElementChild.clientWidth,s>1&&(this.childElementWidth+=(i-this.childElementWidth*s)/(s-1)),this.moveCountForOneTouch=Math.max(1,Math.ceil(t/this.childElementWidth)-1)}debounce(e,t){{let i;return()=>{clearTimeout(i),i=setTimeout((()=>{e()}),t)}}}convertNumberToCompactForm(e){return e>=1e9?(e/1e9).toFixed(1).replace(/\.0$/,"")+"b":e>=1e6?(e/1e6).toFixed(1).replace(/\.0$/,"")+"m":e>=1e3?(e/1e3).toFixed(1).replace(/\.0$/,"")+"k":e.toString()}handleResize(){this.debounce(this.initLevelSlider.bind(this),200)()}componentDidRender(){this.host.componentOnReady().then((()=>{this.initLevelSlider()}))}render(){var e;return t(s,{key:"780e54c101e1dd10513f959b08e3b7425ebba3ec"},this.levels&&[t("div",{key:"70e7265746f1cb4788d137c43b9addf1443a6ae3",class:`SliderButton LeftButton ${0==this.offset?"Disabled":""} ${this.showSliderButton?"":"Hidden"}`,onClick:()=>this.slideTo(h.slideToRight)},t("svg",{key:"20184f3e02bebe818f5119b9b71105a1d7e11681",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},t("path",{key:"351e4a93e390f430045642692b585867e9569b6a","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 19l-7-7 7-7"}))),t("div",{key:"d21722ad058c4e83d23dfaa6822850557de4e620",class:"LevelItemsWrapper"},t("div",{key:"03dccfd305222e9e4eb53277efeef43711f3b664",style:{left:`${this.offset}px`},class:`LevelItems ${this.isMobile?"Mobile":""} ${this.isMobile&&1===(null===(e=this.levels)||void 0===e?void 0:e.length)?"SingleItem":""}`,id:"levelItems",ref:e=>{this.levelsElement=e}},this.levels.map(((e,i)=>t("div",{class:"Item "+(this.selectedLevelId==e.id?"Active":""),onClick:this.onLevelClicked.bind(this,e)},t("img",{alt:`Presentation Icon for ${e.presentation.displayName}`,class:"LevelImg",src:e.presentation.asset}),t("span",{class:"LevelName",title:e.presentation.displayName},e.presentation.displayName),t("span",{class:"LevelPoints"},0==i?"":">",this.convertNumberToCompactForm(e.firstEntryPoints)," ",a("points",this.language))))))),t("div",{key:"6fe81dc6338a8dc29e2a9dc7aedcbdb618660c82",class:`SliderButton RightButton ${this.offset<=this.minOffset?"Disabled":""} ${this.showSliderButton?"":"Hidden"}`,onClick:()=>this.slideTo(h.slideToLeft)},t("svg",{key:"26e11511a54ac6d43fab18d39f0483f86af470cf",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},t("path",{key:"6f3d02eb56c674a82a008022b0f8304a9c4bd72f","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"})))])}get host(){return n(this)}static get watchers(){return{selectedLevelId:["levelsChangedHandler"]}}};d.style="elevate-level-list{display:flex;flex-direction:row}.LevelItemsWrapper{display:flex;flex:1;margin-top:10px;min-height:30px;transition-property:all;position:relative;height:138px;overflow-x:hidden}.Mobile.LevelItems{overflow-x:hidden}.LevelItems{overflow-x:auto;display:flex;flex-direction:row;gap:10px;left:0;position:absolute;transition:left 0.5s ease-in-out}.LevelItems .Item:hover,.LevelItems .Item.Active{background-color:var(--emw--color-gray-50, rgb(244, 244, 244));box-shadow:0px 4px 13px 0px rgba(0, 0, 0, 0.25)}.LevelItems .Item{width:86px;height:125px;border-radius:15px;text-align:center;display:flex;flex-direction:column;cursor:pointer}.LevelItems .Item .LevelName{font-size:13px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.LevelItems .Item .LevelPoints{color:var(--emw--color-gray-100, rgb(118, 113, 113));font-size:10px}.LevelItems .Item .LevelImg{width:65px;height:68px;margin:11px auto}.SliderButton{display:flex;width:29px;align-items:center;cursor:pointer}.SliderButton.Disabled svg{stroke:var(--emw--color-gray-50, #cbc5c5)}.SliderButton.Hidden{display:none}.LevelItems.Mobile.SingleItem{left:0 !important;width:100%;display:flex;justify-content:center;flex-wrap:nowrap;padding:0}.LevelItems.Mobile.SingleItem .Item{flex-grow:0;flex-shrink:0}";const c=class{constructor(t){e(this,t),this.elevateLevel=void 0}render(){return t(s,{key:"16d128717e716f7ca7d3bb77fc3a2e67209318b6"},t("div",{key:"658657abdfc64844bd2af40562efe40385e1735a",class:"Row Desc"},t("h3",{key:"ec5871c2f810c8c120bf99510717381175bc1ef4"},this.elevateLevel.presentation.displayName),t("p",{key:"865915c6eea90295238fb47eaa91c8f968199ca5"},t("span",{key:"2b90c6c5d6957b73fc4a0f53d53da0ca023a4f0a",class:"TxtDesc",innerHTML:this.elevateLevel.presentation.description}))))}};c.style=":host{display:block}.PriviliegeList{padding-inline-start:5px}.PriviliegeList li{display:flex}.PriviliegeList li .Img{width:80px}.PriviliegeList li .Img img{width:60px;margin:10px}.PriviliegeList li .Content h4{text-transform:capitalize;margin-block-start:10px}";var v,f,u,p="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},g={exports:{}};v=g,f=g.exports,u=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==p)return p;throw new Error("unable to locate global object")}(),v.exports=f=u.fetch,u.fetch&&(f.default=u.fetch.bind(u)),f.Headers=u.Headers,f.Request=u.Request,f.Response=u.Response;const b=g.exports,m=class{constructor(t){e(this,t),this.elevateLevelsDataChange=i(this,"elevateLevelsDataChange",7),this.scopeParams=void 0}async componentWillRender(){if(!this.scopeParams.endpoint)return;let e=new URL(`${this.scopeParams.endpoint}/v1/elevate/levels?language=${this.scopeParams.language}`);await b(e.href).then((e=>e.json())).then((e=>{const t=e.data.sort(((e,t)=>e.firstEntryPoints<t.firstEntryPoints?-1:1));let i=this.scopeParams.selectedLevelId;if(!i&&this.scopeParams.showDefault&&t.length>0&&(i=t[0].id),i){const e=t.filter((e=>e.id==i))[0];this.elevateLevelsDataChange.emit({currentLevel:e})}this.elevateLevelsDataChange.emit({clearError:!0}),this.elevateLevelsDataChange.emit({elevateLevels:t})})).catch((e=>{this.elevateLevelsDataChange.emit({errorMessage:{type:"errorWhenLoadElevateLevels",err:e}}),console.error(e)}))}};m.style=":host{display:block}";const w="__WIDGET_GLOBAL_STYLE_CACHE__";function y(e,t){if(e){const i=document.createElement("style");i.innerHTML=t,e.appendChild(i)}}function L(e,t){if(!e||!t)return;const i=new URL(t);fetch(i.href).then((e=>e.text())).then((t=>{const i=document.createElement("style");i.innerHTML=t,e&&e.appendChild(i)})).catch((e=>{console.error("There was an error while trying to load client styling from URL",e)}))}function x(e,t,i,s=!1){if(!window.emMessageBus)return;if(!("adoptedStyleSheets"in Document.prototype)||!s)return i=function(e,t){const i=document.createElement("style");return window.emMessageBus.subscribe(t,(t=>{e&&(i.innerHTML=t,e.appendChild(i))}))}(e,t),i;window[w]||(window[w]={}),i=function(e,t){return window.emMessageBus.subscribe(t,(i=>{if(!e)return;const s=e.getRootNode(),n=window[w];let l=n[t]&&n[t].sheet;l?n[t].refCount=n[t].refCount+1:(l=new CSSStyleSheet,l.replaceSync(i),n[t]={sheet:l,refCount:1});const o=s.adoptedStyleSheets||[];o.includes(l)||(s.adoptedStyleSheets=[...o,l])}))}(e,t);const n=i.unsubscribe.bind(i);return i.unsubscribe=()=>{if(window[w][t]){const e=window[w][t];e.refCount>1?e.refCount=e.refCount-1:delete window[w][t]}n()},i}const C=class{constructor(t){e(this,t),this.stylingAppends=!1,this.clientStyling="",this.clientStylingUrl="",this.mbSource=void 0,this.translationUrl="",this.targetTranslations=void 0}componentDidLoad(){this.el&&(this.mbSource&&x(this.el,`${this.mbSource}.Style`,this.stylingSubscription),this.clientStyling&&y(this.el,this.clientStyling),this.clientStylingUrl&&L(this.el,this.clientStylingUrl),this.stylingAppends=!0)}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}handleMbSourceChange(e,t){e!=t&&x(this.el,`${this.mbSource}.Style`,this.stylingSubscription)}handleClientStylingChange(e,t){e!=t&&y(this.el,this.clientStyling)}handleClientStylingUrlChange(e,t){e!=t&&this.clientStylingUrl&&L(this.el,this.clientStylingUrl)}componentDidRender(){this.stylingAppends||(this.clientStyling&&y(this.el,this.clientStyling),this.clientStylingUrl&&L(this.el,this.clientStylingUrl),this.stylingAppends=!0)}async componentWillLoad(){const e=[];if(this.translationUrl){const s=(t=this.translationUrl,i=this.targetTranslations,new Promise((e=>{fetch(t).then((e=>e.json())).then((t=>{Object.keys(t).forEach((e=>{i[e]=i[e]||{},Object.keys(t[e]).forEach((s=>{if(!i.en[s])return;const n=i.en[s];"object"==typeof t[e][s]?(i[e][s]=i[e][s]||Object.assign({},n),Object.keys(t[e][s]).forEach((n=>{i[e][s][n]=t[e][s][n]}))):i[e][s]=t[e][s]||Object.assign({},n)}))})),e(!0)})).catch((t=>{console.error("Failed to load translations:",t),e(!1)}))})));e.push(s)}var t,i;return await Promise.all(e)}render(){return t("div",{key:"e660ceb69f5e848c788c3924fc814c0fa7a777a2",class:"StyleShell"},t("slot",{key:"35014b6c0c32532af11e6a629ba9b13942504d21",name:"mainContent"}))}get el(){return n(this)}static get watchers(){return{mbSource:["handleMbSourceChange"],clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingUrlChange"]}}};C.style=":host{display:block}";export{r as bonus_elevate_levels,d as elevate_level_list,c as elevate_level_presentation,m as elevate_levels_data,C as general_styling_wrapper}
|
|
@@ -19,7 +19,7 @@ var patchBrowser = () => {
|
|
|
19
19
|
|
|
20
20
|
patchBrowser().then(async (options) => {
|
|
21
21
|
await appGlobals.globalScripts();
|
|
22
|
-
return index.bootstrapLazy([["bonus-elevate-levels_5.cjs",[[1,"bonus-elevate-levels",{"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"mbSource":[513,"mb-source"],"endpoint":[513],"language":[513],"translationUrl":[513,"translation-url"],"selectedLevelId":[1537,"selected-level-id"],"showDefault":[4,"show-default"],"elevateLevelParamProxy":[32],"elevateLevels":[32],"currentLevel":[32],"errorMessage":[32]},[[0,"selectedLevelChanged","selectedLevelChangedHandler"],[2,"elevateLevelsDataChange","elevateLevelsDataChangeHandler"]],{"selectedLevelId":["selectedLevelIdChangedHandler"],"elevateLevels":["selectedLevelIdChangedHandler"],"endpoint":["onSessionOrEndpointChange"],"language":["onSessionOrEndpointChange"],"translationUrl":["handleNewTranslations"]}],[0,"elevate-level-list",{"levels":[16],"language":[1],"selectedLevelId":[1537,"selected-level-id"],"showSliderButton":[32],"touchPosStart":[32],"touchPosEnd":[32],"offset":[32]},[[1,"touchstart","onTouchStart"],[1,"touchmove","onTouchMove"],[9,"resize","handleResize"]],{"selectedLevelId":["levelsChangedHandler"]}],[0,"elevate-level-presentation",{"elevateLevel":[16]}],[0,"elevate-levels-data",{"scopeParams":[1544,"scope-params"]}],[4,"general-styling-wrapper",{"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"mbSource":[1,"mb-source"],"translationUrl":[1,"translation-url"],"targetTranslations":[16]},null,{"mbSource":["handleMbSourceChange"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"]}]]]], options);
|
|
22
|
+
return index.bootstrapLazy([["bonus-elevate-levels_5.cjs",[[1,"bonus-elevate-levels",{"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"mbSource":[513,"mb-source"],"endpoint":[513],"language":[513],"translationUrl":[513,"translation-url"],"selectedLevelId":[1537,"selected-level-id"],"showDefault":[4,"show-default"],"elevateLevelParamProxy":[32],"elevateLevels":[32],"currentLevel":[32],"errorMessage":[32]},[[0,"selectedLevelChanged","selectedLevelChangedHandler"],[2,"elevateLevelsDataChange","elevateLevelsDataChangeHandler"]],{"selectedLevelId":["selectedLevelIdChangedHandler"],"elevateLevels":["selectedLevelIdChangedHandler"],"endpoint":["onSessionOrEndpointChange"],"language":["onSessionOrEndpointChange"],"translationUrl":["handleNewTranslations"]}],[0,"elevate-level-list",{"levels":[16],"language":[1],"selectedLevelId":[1537,"selected-level-id"],"showSliderButton":[32],"touchPosStart":[32],"touchPosEnd":[32],"offset":[32]},[[1,"touchstart","onTouchStart"],[1,"touchmove","onTouchMove"],[1,"touchend","onTouchEnd"],[9,"resize","handleResize"]],{"selectedLevelId":["levelsChangedHandler"]}],[0,"elevate-level-presentation",{"elevateLevel":[16]}],[0,"elevate-levels-data",{"scopeParams":[1544,"scope-params"]}],[4,"general-styling-wrapper",{"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"mbSource":[1,"mb-source"],"translationUrl":[1,"translation-url"],"targetTranslations":[16]},null,{"mbSource":["handleMbSourceChange"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"]}]]]], options);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
exports.setNonce = index.setNonce;
|
|
@@ -183,7 +183,7 @@ var MOVE_TO;
|
|
|
183
183
|
MOVE_TO[MOVE_TO["slideToLeft"] = -1] = "slideToLeft";
|
|
184
184
|
})(MOVE_TO || (MOVE_TO = {}));
|
|
185
185
|
|
|
186
|
-
const elevateLevelListCss = "elevate-level-list{display:flex;flex-direction:row}.LevelItemsWrapper{display:flex;flex:1;margin-top:10px;min-height:30px;transition-property:all;position:relative;height:138px;overflow-x:hidden}.Mobile.LevelItems{overflow-x:hidden}.LevelItems{overflow-x:auto;display:flex;flex-direction:row;gap:10px;left:0;position:absolute;transition:left 0.5s ease-in-out}.LevelItems .Item:hover,.LevelItems .Item.Active{background-color:var(--emw--color-gray-50, rgb(244, 244, 244));box-shadow:0px 4px 13px 0px rgba(0, 0, 0, 0.25)}.LevelItems .Item{width:86px;height:125px;border-radius:15px;text-align:center;display:flex;flex-direction:column;cursor:pointer}.LevelItems .Item .LevelName{font-size:13px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.LevelItems .Item .LevelPoints{color:var(--emw--color-gray-100, rgb(118, 113, 113));font-size:10px}.LevelItems .Item .LevelImg{width:65px;height:68px;margin:11px auto}.SliderButton{display:flex;width:29px;align-items:center;cursor:pointer}.SliderButton.Disabled svg{stroke:var(--emw--color-gray-50, #cbc5c5)}.SliderButton.Hidden{display:none}";
|
|
186
|
+
const elevateLevelListCss = "elevate-level-list{display:flex;flex-direction:row}.LevelItemsWrapper{display:flex;flex:1;margin-top:10px;min-height:30px;transition-property:all;position:relative;height:138px;overflow-x:hidden}.Mobile.LevelItems{overflow-x:hidden}.LevelItems{overflow-x:auto;display:flex;flex-direction:row;gap:10px;left:0;position:absolute;transition:left 0.5s ease-in-out}.LevelItems .Item:hover,.LevelItems .Item.Active{background-color:var(--emw--color-gray-50, rgb(244, 244, 244));box-shadow:0px 4px 13px 0px rgba(0, 0, 0, 0.25)}.LevelItems .Item{width:86px;height:125px;border-radius:15px;text-align:center;display:flex;flex-direction:column;cursor:pointer}.LevelItems .Item .LevelName{font-size:13px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.LevelItems .Item .LevelPoints{color:var(--emw--color-gray-100, rgb(118, 113, 113));font-size:10px}.LevelItems .Item .LevelImg{width:65px;height:68px;margin:11px auto}.SliderButton{display:flex;width:29px;align-items:center;cursor:pointer}.SliderButton.Disabled svg{stroke:var(--emw--color-gray-50, #cbc5c5)}.SliderButton.Hidden{display:none}.LevelItems.Mobile.SingleItem{left:0 !important;width:100%;display:flex;justify-content:center;flex-wrap:nowrap;padding:0}.LevelItems.Mobile.SingleItem .Item{flex-grow:0;flex-shrink:0}";
|
|
187
187
|
const ElevateLevelListStyle0 = elevateLevelListCss;
|
|
188
188
|
|
|
189
189
|
const ElevateLevelList = class {
|
|
@@ -200,51 +200,189 @@ const ElevateLevelList = class {
|
|
|
200
200
|
this.touchPosEnd = undefined;
|
|
201
201
|
this.offset = 0;
|
|
202
202
|
}
|
|
203
|
+
centerLevelItem(index) {
|
|
204
|
+
if (!this.isMobile ||
|
|
205
|
+
!this.levelsElement ||
|
|
206
|
+
index < 0 ||
|
|
207
|
+
!this.levelsElement.children[index]) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const wrapper = this.levelsElement.parentElement;
|
|
211
|
+
if (!wrapper) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const item = this.levelsElement.children[index];
|
|
215
|
+
const wrapperWidth = wrapper.clientWidth;
|
|
216
|
+
const contentWidth = this.levelsElement.scrollWidth;
|
|
217
|
+
const minOffset = Math.min(0, wrapperWidth - contentWidth);
|
|
218
|
+
const itemLeft = item.offsetLeft;
|
|
219
|
+
const itemWidth = item.offsetWidth;
|
|
220
|
+
let newOffset = wrapperWidth / 2 - (itemLeft + itemWidth / 2);
|
|
221
|
+
newOffset = newOffset < minOffset
|
|
222
|
+
? minOffset
|
|
223
|
+
: newOffset > 0
|
|
224
|
+
? 0
|
|
225
|
+
: newOffset;
|
|
226
|
+
this.minOffset = minOffset;
|
|
227
|
+
this.offset = newOffset;
|
|
228
|
+
}
|
|
229
|
+
moveToLevelItem(index, centerItem = false) {
|
|
230
|
+
if (!this.levelsElement ||
|
|
231
|
+
index < 0 ||
|
|
232
|
+
!this.levelsElement.children[index]) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const wrapper = this.levelsElement.parentElement;
|
|
236
|
+
if (!wrapper) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
const item = this.levelsElement.children[index];
|
|
240
|
+
const wrapperWidth = wrapper.clientWidth;
|
|
241
|
+
const contentWidth = this.isMobile
|
|
242
|
+
? this.levelsElement.scrollWidth
|
|
243
|
+
: this.levelsElement.clientWidth;
|
|
244
|
+
const minOffset = Math.min(0, wrapperWidth - contentWidth);
|
|
245
|
+
if (contentWidth <= wrapperWidth) {
|
|
246
|
+
this.minOffset = 0;
|
|
247
|
+
this.offset = 0;
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const itemLeft = item.offsetLeft;
|
|
251
|
+
const itemWidth = item.offsetWidth;
|
|
252
|
+
let newOffset;
|
|
253
|
+
if (centerItem) {
|
|
254
|
+
newOffset = wrapperWidth / 2 - (itemLeft + itemWidth / 2);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
const currentLeft = -this.offset;
|
|
258
|
+
const currentRight = currentLeft + wrapperWidth;
|
|
259
|
+
const itemRight = itemLeft + itemWidth;
|
|
260
|
+
if (itemLeft >= currentLeft && itemRight <= currentRight) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
newOffset = itemLeft < currentLeft
|
|
264
|
+
? -itemLeft
|
|
265
|
+
: wrapperWidth - itemRight;
|
|
266
|
+
}
|
|
267
|
+
newOffset = newOffset < minOffset
|
|
268
|
+
? minOffset
|
|
269
|
+
: newOffset > 0
|
|
270
|
+
? 0
|
|
271
|
+
: newOffset;
|
|
272
|
+
this.minOffset = minOffset;
|
|
273
|
+
this.offset = newOffset;
|
|
274
|
+
}
|
|
203
275
|
onLevelClicked(elevateLevel) {
|
|
276
|
+
var _a, _b;
|
|
204
277
|
this.selectedLevelChanged.emit({ level: elevateLevel });
|
|
205
278
|
this.selectedLevelId = elevateLevel.id;
|
|
279
|
+
if (this.isMobile) {
|
|
280
|
+
const levelIndex = (_b = (_a = this.levels) === null || _a === void 0 ? void 0 : _a.findIndex((level) => level.id === elevateLevel.id)) !== null && _b !== void 0 ? _b : -1;
|
|
281
|
+
requestAnimationFrame(() => {
|
|
282
|
+
this.centerLevelItem(levelIndex);
|
|
283
|
+
});
|
|
284
|
+
}
|
|
206
285
|
}
|
|
207
286
|
levelsChangedHandler() {
|
|
208
287
|
this.initOffsetOfLevelItems();
|
|
209
288
|
}
|
|
210
289
|
initOffsetOfLevelItems() {
|
|
211
|
-
if (!this.levels || this.levels.length
|
|
290
|
+
if (!this.levels || this.levels.length === 0 || !this.selectedLevelId) {
|
|
212
291
|
return;
|
|
213
292
|
}
|
|
214
293
|
const currentLevelIndex = this.levels.findIndex((item) => {
|
|
215
|
-
return this.selectedLevelId
|
|
294
|
+
return this.selectedLevelId === item.id;
|
|
216
295
|
});
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if (this.levels.length <= this.moveCountForOneTouch) {
|
|
296
|
+
if (currentLevelIndex === -1 && this.levels[0]) {
|
|
297
|
+
this.selectedLevelId = this.levels[0].id;
|
|
220
298
|
return;
|
|
221
299
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
300
|
+
if (this.levels.length <= 1) {
|
|
301
|
+
this.offset = 0;
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
const targetIndex = currentLevelIndex === -1 ? 0 : currentLevelIndex;
|
|
305
|
+
requestAnimationFrame(() => {
|
|
306
|
+
var _a;
|
|
307
|
+
if (this.isMobile) {
|
|
308
|
+
this.moveToLevelItem(targetIndex, true);
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
const wrapper = (_a = this.levelsElement) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
312
|
+
if (!wrapper || !this.levelsElement) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const wrapperWidth = wrapper.clientWidth;
|
|
316
|
+
const contentWidth = this.levelsElement.clientWidth;
|
|
317
|
+
if (contentWidth <= wrapperWidth) {
|
|
318
|
+
this.offset = 0;
|
|
319
|
+
this.minOffset = 0;
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
// Desktop carousel
|
|
323
|
+
this.moveToLevelItem(targetIndex, false);
|
|
324
|
+
});
|
|
226
325
|
}
|
|
227
326
|
onTouchStart(e) {
|
|
228
|
-
this.
|
|
327
|
+
if (!this.isMobile) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
this.touchPosStart = {
|
|
331
|
+
clientX: e.touches[0].clientX,
|
|
332
|
+
clientY: e.touches[0].clientY
|
|
333
|
+
};
|
|
334
|
+
this.touchPosEnd = this.touchPosStart;
|
|
229
335
|
}
|
|
230
336
|
onTouchMove(e) {
|
|
231
|
-
this.
|
|
337
|
+
if (!this.isMobile) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
this.touchPosEnd = {
|
|
341
|
+
clientX: e.touches[0].clientX,
|
|
342
|
+
clientY: e.touches[0].clientY
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
onTouchEnd() {
|
|
346
|
+
if (!this.isMobile || !this.touchPosStart || !this.touchPosEnd || !this.levels || this.levels.length <= 1) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
232
349
|
const diffX = this.touchPosEnd.clientX - this.touchPosStart.clientX;
|
|
233
350
|
const diffY = this.touchPosEnd.clientY - this.touchPosStart.clientY;
|
|
234
|
-
|
|
235
|
-
|
|
351
|
+
const threshold = 30;
|
|
352
|
+
if (Math.abs(diffX) <= threshold || Math.abs(diffX) <= Math.abs(diffY)) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
if (diffX > 0) {
|
|
356
|
+
// Move right, Go to previous item
|
|
357
|
+
this.slideTo(MOVE_TO.slideToRight);
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
// Move left, Go to next item
|
|
361
|
+
this.slideTo(MOVE_TO.slideToLeft);
|
|
236
362
|
}
|
|
237
363
|
}
|
|
238
364
|
slideTo(direction) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
const leftOfPreNode = (Math.floor(newOffset / this.childElementWidth)) * this.childElementWidth;
|
|
243
|
-
const leftOfNextNode = (Math.ceil(newOffset / this.childElementWidth)) * this.childElementWidth;
|
|
244
|
-
//touchmove to right, get left of pre-node; touchmove to left, get left of next-node
|
|
245
|
-
newOffset = direction == MOVE_TO.slideToRight ? leftOfPreNode : leftOfNextNode;
|
|
365
|
+
if (!this.levelsElement || !this.childElementWidth || !this.moveCountForOneTouch || this.levelsElement.childElementCount <= 1) {
|
|
366
|
+
this.offset = 0;
|
|
367
|
+
return;
|
|
246
368
|
}
|
|
247
|
-
|
|
369
|
+
const currentOffset = this.isMobile
|
|
370
|
+
? this.offset
|
|
371
|
+
: this.levelsElement.offsetLeft;
|
|
372
|
+
let newOffset = currentOffset +
|
|
373
|
+
this.childElementWidth * this.moveCountForOneTouch * direction;
|
|
374
|
+
if (newOffset % this.childElementWidth !== 0) {
|
|
375
|
+
const leftOfPreNode = Math.floor(newOffset / this.childElementWidth) * this.childElementWidth;
|
|
376
|
+
const leftOfNextNode = Math.ceil(newOffset / this.childElementWidth) * this.childElementWidth;
|
|
377
|
+
newOffset = direction === MOVE_TO.slideToRight
|
|
378
|
+
? leftOfPreNode
|
|
379
|
+
: leftOfNextNode;
|
|
380
|
+
}
|
|
381
|
+
this.offset = newOffset < this.minOffset
|
|
382
|
+
? this.minOffset
|
|
383
|
+
: newOffset >= 0
|
|
384
|
+
? 0
|
|
385
|
+
: newOffset;
|
|
248
386
|
}
|
|
249
387
|
initLevelSlider() {
|
|
250
388
|
var _a;
|
|
@@ -252,12 +390,34 @@ const ElevateLevelList = class {
|
|
|
252
390
|
console.log('Widget[elevate-level-list] DOM is not ready.');
|
|
253
391
|
return;
|
|
254
392
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
393
|
+
const wrapperWidth = this.levelsElement.parentElement.clientWidth;
|
|
394
|
+
// Desktop, Use clientWidth
|
|
395
|
+
// Mobile, Use scrollWidth
|
|
396
|
+
const contentWidth = this.isMobile
|
|
397
|
+
? this.levelsElement.scrollWidth
|
|
398
|
+
: this.levelsElement.clientWidth;
|
|
259
399
|
const childElementCount = this.levelsElement.childElementCount;
|
|
260
|
-
|
|
400
|
+
// If childElementCount === 0 or 1, No carousel
|
|
401
|
+
if (childElementCount <= 1) {
|
|
402
|
+
this.showSliderButton = false;
|
|
403
|
+
this.minOffset = 0;
|
|
404
|
+
this.offset = 0;
|
|
405
|
+
this.childElementWidth = this.levelsElement.firstElementChild.clientWidth;
|
|
406
|
+
this.moveCountForOneTouch = 1;
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
// keep original logic for desktop
|
|
410
|
+
this.showSliderButton =
|
|
411
|
+
!this.isMobile &&
|
|
412
|
+
this.levelsElement.clientWidth > wrapperWidth;
|
|
413
|
+
this.minOffset = wrapperWidth - contentWidth;
|
|
414
|
+
this.childElementWidth = this.levelsElement.firstElementChild.clientWidth;
|
|
415
|
+
if (childElementCount > 1) {
|
|
416
|
+
const gap = (contentWidth - this.childElementWidth * childElementCount) /
|
|
417
|
+
(childElementCount - 1);
|
|
418
|
+
this.childElementWidth += gap;
|
|
419
|
+
}
|
|
420
|
+
this.moveCountForOneTouch = Math.max(1, Math.ceil(wrapperWidth / this.childElementWidth) - 1);
|
|
261
421
|
}
|
|
262
422
|
debounce(callback, delay) {
|
|
263
423
|
{
|
|
@@ -289,12 +449,13 @@ const ElevateLevelList = class {
|
|
|
289
449
|
});
|
|
290
450
|
}
|
|
291
451
|
render() {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
index.h("div", { key: '
|
|
452
|
+
var _a;
|
|
453
|
+
return (index.h(index.Host, { key: '780e54c101e1dd10513f959b08e3b7425ebba3ec' }, this.levels && [
|
|
454
|
+
index.h("div", { key: '70e7265746f1cb4788d137c43b9addf1443a6ae3', class: `SliderButton LeftButton ${this.offset == 0 ? 'Disabled' : ''} ${this.showSliderButton ? '' : 'Hidden'}`, onClick: () => this.slideTo(MOVE_TO.slideToRight) }, index.h("svg", { key: '20184f3e02bebe818f5119b9b71105a1d7e11681', fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, index.h("path", { key: '351e4a93e390f430045642692b585867e9569b6a', "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M15 19l-7-7 7-7" }))),
|
|
455
|
+
index.h("div", { key: 'd21722ad058c4e83d23dfaa6822850557de4e620', class: 'LevelItemsWrapper' }, index.h("div", { key: '03dccfd305222e9e4eb53277efeef43711f3b664', style: { 'left': `${this.offset}px` }, class: `LevelItems ${this.isMobile ? 'Mobile' : ''} ${this.isMobile && ((_a = this.levels) === null || _a === void 0 ? void 0 : _a.length) === 1 ? 'SingleItem' : ''}`, id: 'levelItems', ref: (el) => { this.levelsElement = el; } }, this.levels.map((level, idx) => {
|
|
295
456
|
return (index.h("div", { class: `Item ${this.selectedLevelId == level.id ? 'Active' : ''}`, onClick: this.onLevelClicked.bind(this, level) }, index.h("img", { alt: `Presentation Icon for ${level.presentation.displayName}`, class: "LevelImg", src: level.presentation.asset }), index.h("span", { class: "LevelName", title: level.presentation.displayName }, level.presentation.displayName), index.h("span", { class: "LevelPoints" }, idx == 0 ? '' : '>', this.convertNumberToCompactForm(level.firstEntryPoints), ' ', translate('points', this.language))));
|
|
296
457
|
}))),
|
|
297
|
-
index.h("div", { key: '
|
|
458
|
+
index.h("div", { key: '6fe81dc6338a8dc29e2a9dc7aedcbdb618660c82', class: `SliderButton RightButton ${this.offset <= this.minOffset ? 'Disabled' : ''} ${this.showSliderButton ? '' : 'Hidden'}`, onClick: () => this.slideTo(MOVE_TO.slideToLeft) }, index.h("svg", { key: '26e11511a54ac6d43fab18d39f0483f86af470cf', fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, index.h("path", { key: '6f3d02eb56c674a82a008022b0f8304a9c4bd72f', "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M9 5l7 7-7 7" })))
|
|
298
459
|
]));
|
|
299
460
|
}
|
|
300
461
|
get host() { return index.getElement(this); }
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -8,7 +8,7 @@ const appGlobals = require('./app-globals-3a1e7e63.js');
|
|
|
8
8
|
const defineCustomElements = async (win, options) => {
|
|
9
9
|
if (typeof window === 'undefined') return undefined;
|
|
10
10
|
await appGlobals.globalScripts();
|
|
11
|
-
return index.bootstrapLazy([["bonus-elevate-levels_5.cjs",[[1,"bonus-elevate-levels",{"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"mbSource":[513,"mb-source"],"endpoint":[513],"language":[513],"translationUrl":[513,"translation-url"],"selectedLevelId":[1537,"selected-level-id"],"showDefault":[4,"show-default"],"elevateLevelParamProxy":[32],"elevateLevels":[32],"currentLevel":[32],"errorMessage":[32]},[[0,"selectedLevelChanged","selectedLevelChangedHandler"],[2,"elevateLevelsDataChange","elevateLevelsDataChangeHandler"]],{"selectedLevelId":["selectedLevelIdChangedHandler"],"elevateLevels":["selectedLevelIdChangedHandler"],"endpoint":["onSessionOrEndpointChange"],"language":["onSessionOrEndpointChange"],"translationUrl":["handleNewTranslations"]}],[0,"elevate-level-list",{"levels":[16],"language":[1],"selectedLevelId":[1537,"selected-level-id"],"showSliderButton":[32],"touchPosStart":[32],"touchPosEnd":[32],"offset":[32]},[[1,"touchstart","onTouchStart"],[1,"touchmove","onTouchMove"],[9,"resize","handleResize"]],{"selectedLevelId":["levelsChangedHandler"]}],[0,"elevate-level-presentation",{"elevateLevel":[16]}],[0,"elevate-levels-data",{"scopeParams":[1544,"scope-params"]}],[4,"general-styling-wrapper",{"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"mbSource":[1,"mb-source"],"translationUrl":[1,"translation-url"],"targetTranslations":[16]},null,{"mbSource":["handleMbSourceChange"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"]}]]]], options);
|
|
11
|
+
return index.bootstrapLazy([["bonus-elevate-levels_5.cjs",[[1,"bonus-elevate-levels",{"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"mbSource":[513,"mb-source"],"endpoint":[513],"language":[513],"translationUrl":[513,"translation-url"],"selectedLevelId":[1537,"selected-level-id"],"showDefault":[4,"show-default"],"elevateLevelParamProxy":[32],"elevateLevels":[32],"currentLevel":[32],"errorMessage":[32]},[[0,"selectedLevelChanged","selectedLevelChangedHandler"],[2,"elevateLevelsDataChange","elevateLevelsDataChangeHandler"]],{"selectedLevelId":["selectedLevelIdChangedHandler"],"elevateLevels":["selectedLevelIdChangedHandler"],"endpoint":["onSessionOrEndpointChange"],"language":["onSessionOrEndpointChange"],"translationUrl":["handleNewTranslations"]}],[0,"elevate-level-list",{"levels":[16],"language":[1],"selectedLevelId":[1537,"selected-level-id"],"showSliderButton":[32],"touchPosStart":[32],"touchPosEnd":[32],"offset":[32]},[[1,"touchstart","onTouchStart"],[1,"touchmove","onTouchMove"],[1,"touchend","onTouchEnd"],[9,"resize","handleResize"]],{"selectedLevelId":["levelsChangedHandler"]}],[0,"elevate-level-presentation",{"elevateLevel":[16]}],[0,"elevate-levels-data",{"scopeParams":[1544,"scope-params"]}],[4,"general-styling-wrapper",{"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"mbSource":[1,"mb-source"],"translationUrl":[1,"translation-url"],"targetTranslations":[16]},null,{"mbSource":["handleMbSourceChange"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"]}]]]], options);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
exports.setNonce = index.setNonce;
|
|
@@ -67,4 +67,18 @@ elevate-level-list {
|
|
|
67
67
|
}
|
|
68
68
|
.SliderButton.Hidden {
|
|
69
69
|
display: none;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.LevelItems.Mobile.SingleItem {
|
|
73
|
+
left: 0 !important;
|
|
74
|
+
width: 100%;
|
|
75
|
+
display: flex;
|
|
76
|
+
justify-content: center;
|
|
77
|
+
flex-wrap: nowrap;
|
|
78
|
+
padding: 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.LevelItems.Mobile.SingleItem .Item {
|
|
82
|
+
flex-grow: 0;
|
|
83
|
+
flex-shrink: 0;
|
|
70
84
|
}
|
|
@@ -13,51 +13,189 @@ export class ElevateLevelList {
|
|
|
13
13
|
this.touchPosEnd = undefined;
|
|
14
14
|
this.offset = 0;
|
|
15
15
|
}
|
|
16
|
+
centerLevelItem(index) {
|
|
17
|
+
if (!this.isMobile ||
|
|
18
|
+
!this.levelsElement ||
|
|
19
|
+
index < 0 ||
|
|
20
|
+
!this.levelsElement.children[index]) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const wrapper = this.levelsElement.parentElement;
|
|
24
|
+
if (!wrapper) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const item = this.levelsElement.children[index];
|
|
28
|
+
const wrapperWidth = wrapper.clientWidth;
|
|
29
|
+
const contentWidth = this.levelsElement.scrollWidth;
|
|
30
|
+
const minOffset = Math.min(0, wrapperWidth - contentWidth);
|
|
31
|
+
const itemLeft = item.offsetLeft;
|
|
32
|
+
const itemWidth = item.offsetWidth;
|
|
33
|
+
let newOffset = wrapperWidth / 2 - (itemLeft + itemWidth / 2);
|
|
34
|
+
newOffset = newOffset < minOffset
|
|
35
|
+
? minOffset
|
|
36
|
+
: newOffset > 0
|
|
37
|
+
? 0
|
|
38
|
+
: newOffset;
|
|
39
|
+
this.minOffset = minOffset;
|
|
40
|
+
this.offset = newOffset;
|
|
41
|
+
}
|
|
42
|
+
moveToLevelItem(index, centerItem = false) {
|
|
43
|
+
if (!this.levelsElement ||
|
|
44
|
+
index < 0 ||
|
|
45
|
+
!this.levelsElement.children[index]) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const wrapper = this.levelsElement.parentElement;
|
|
49
|
+
if (!wrapper) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const item = this.levelsElement.children[index];
|
|
53
|
+
const wrapperWidth = wrapper.clientWidth;
|
|
54
|
+
const contentWidth = this.isMobile
|
|
55
|
+
? this.levelsElement.scrollWidth
|
|
56
|
+
: this.levelsElement.clientWidth;
|
|
57
|
+
const minOffset = Math.min(0, wrapperWidth - contentWidth);
|
|
58
|
+
if (contentWidth <= wrapperWidth) {
|
|
59
|
+
this.minOffset = 0;
|
|
60
|
+
this.offset = 0;
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const itemLeft = item.offsetLeft;
|
|
64
|
+
const itemWidth = item.offsetWidth;
|
|
65
|
+
let newOffset;
|
|
66
|
+
if (centerItem) {
|
|
67
|
+
newOffset = wrapperWidth / 2 - (itemLeft + itemWidth / 2);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const currentLeft = -this.offset;
|
|
71
|
+
const currentRight = currentLeft + wrapperWidth;
|
|
72
|
+
const itemRight = itemLeft + itemWidth;
|
|
73
|
+
if (itemLeft >= currentLeft && itemRight <= currentRight) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
newOffset = itemLeft < currentLeft
|
|
77
|
+
? -itemLeft
|
|
78
|
+
: wrapperWidth - itemRight;
|
|
79
|
+
}
|
|
80
|
+
newOffset = newOffset < minOffset
|
|
81
|
+
? minOffset
|
|
82
|
+
: newOffset > 0
|
|
83
|
+
? 0
|
|
84
|
+
: newOffset;
|
|
85
|
+
this.minOffset = minOffset;
|
|
86
|
+
this.offset = newOffset;
|
|
87
|
+
}
|
|
16
88
|
onLevelClicked(elevateLevel) {
|
|
89
|
+
var _a, _b;
|
|
17
90
|
this.selectedLevelChanged.emit({ level: elevateLevel });
|
|
18
91
|
this.selectedLevelId = elevateLevel.id;
|
|
92
|
+
if (this.isMobile) {
|
|
93
|
+
const levelIndex = (_b = (_a = this.levels) === null || _a === void 0 ? void 0 : _a.findIndex((level) => level.id === elevateLevel.id)) !== null && _b !== void 0 ? _b : -1;
|
|
94
|
+
requestAnimationFrame(() => {
|
|
95
|
+
this.centerLevelItem(levelIndex);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
19
98
|
}
|
|
20
99
|
levelsChangedHandler() {
|
|
21
100
|
this.initOffsetOfLevelItems();
|
|
22
101
|
}
|
|
23
102
|
initOffsetOfLevelItems() {
|
|
24
|
-
if (!this.levels || this.levels.length
|
|
103
|
+
if (!this.levels || this.levels.length === 0 || !this.selectedLevelId) {
|
|
25
104
|
return;
|
|
26
105
|
}
|
|
27
106
|
const currentLevelIndex = this.levels.findIndex((item) => {
|
|
28
|
-
return this.selectedLevelId
|
|
107
|
+
return this.selectedLevelId === item.id;
|
|
29
108
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
109
|
+
if (currentLevelIndex === -1 && this.levels[0]) {
|
|
110
|
+
this.selectedLevelId = this.levels[0].id;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (this.levels.length <= 1) {
|
|
114
|
+
this.offset = 0;
|
|
33
115
|
return;
|
|
34
116
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
117
|
+
const targetIndex = currentLevelIndex === -1 ? 0 : currentLevelIndex;
|
|
118
|
+
requestAnimationFrame(() => {
|
|
119
|
+
var _a;
|
|
120
|
+
if (this.isMobile) {
|
|
121
|
+
this.moveToLevelItem(targetIndex, true);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const wrapper = (_a = this.levelsElement) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
125
|
+
if (!wrapper || !this.levelsElement) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const wrapperWidth = wrapper.clientWidth;
|
|
129
|
+
const contentWidth = this.levelsElement.clientWidth;
|
|
130
|
+
if (contentWidth <= wrapperWidth) {
|
|
131
|
+
this.offset = 0;
|
|
132
|
+
this.minOffset = 0;
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
// Desktop carousel
|
|
136
|
+
this.moveToLevelItem(targetIndex, false);
|
|
137
|
+
});
|
|
39
138
|
}
|
|
40
139
|
onTouchStart(e) {
|
|
41
|
-
this.
|
|
140
|
+
if (!this.isMobile) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
this.touchPosStart = {
|
|
144
|
+
clientX: e.touches[0].clientX,
|
|
145
|
+
clientY: e.touches[0].clientY
|
|
146
|
+
};
|
|
147
|
+
this.touchPosEnd = this.touchPosStart;
|
|
42
148
|
}
|
|
43
149
|
onTouchMove(e) {
|
|
44
|
-
this.
|
|
150
|
+
if (!this.isMobile) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
this.touchPosEnd = {
|
|
154
|
+
clientX: e.touches[0].clientX,
|
|
155
|
+
clientY: e.touches[0].clientY
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
onTouchEnd() {
|
|
159
|
+
if (!this.isMobile || !this.touchPosStart || !this.touchPosEnd || !this.levels || this.levels.length <= 1) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
45
162
|
const diffX = this.touchPosEnd.clientX - this.touchPosStart.clientX;
|
|
46
163
|
const diffY = this.touchPosEnd.clientY - this.touchPosStart.clientY;
|
|
47
|
-
|
|
48
|
-
|
|
164
|
+
const threshold = 30;
|
|
165
|
+
if (Math.abs(diffX) <= threshold || Math.abs(diffX) <= Math.abs(diffY)) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (diffX > 0) {
|
|
169
|
+
// Move right, Go to previous item
|
|
170
|
+
this.slideTo(MOVE_TO.slideToRight);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
// Move left, Go to next item
|
|
174
|
+
this.slideTo(MOVE_TO.slideToLeft);
|
|
49
175
|
}
|
|
50
176
|
}
|
|
51
177
|
slideTo(direction) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const leftOfPreNode = (Math.floor(newOffset / this.childElementWidth)) * this.childElementWidth;
|
|
56
|
-
const leftOfNextNode = (Math.ceil(newOffset / this.childElementWidth)) * this.childElementWidth;
|
|
57
|
-
//touchmove to right, get left of pre-node; touchmove to left, get left of next-node
|
|
58
|
-
newOffset = direction == MOVE_TO.slideToRight ? leftOfPreNode : leftOfNextNode;
|
|
178
|
+
if (!this.levelsElement || !this.childElementWidth || !this.moveCountForOneTouch || this.levelsElement.childElementCount <= 1) {
|
|
179
|
+
this.offset = 0;
|
|
180
|
+
return;
|
|
59
181
|
}
|
|
60
|
-
|
|
182
|
+
const currentOffset = this.isMobile
|
|
183
|
+
? this.offset
|
|
184
|
+
: this.levelsElement.offsetLeft;
|
|
185
|
+
let newOffset = currentOffset +
|
|
186
|
+
this.childElementWidth * this.moveCountForOneTouch * direction;
|
|
187
|
+
if (newOffset % this.childElementWidth !== 0) {
|
|
188
|
+
const leftOfPreNode = Math.floor(newOffset / this.childElementWidth) * this.childElementWidth;
|
|
189
|
+
const leftOfNextNode = Math.ceil(newOffset / this.childElementWidth) * this.childElementWidth;
|
|
190
|
+
newOffset = direction === MOVE_TO.slideToRight
|
|
191
|
+
? leftOfPreNode
|
|
192
|
+
: leftOfNextNode;
|
|
193
|
+
}
|
|
194
|
+
this.offset = newOffset < this.minOffset
|
|
195
|
+
? this.minOffset
|
|
196
|
+
: newOffset >= 0
|
|
197
|
+
? 0
|
|
198
|
+
: newOffset;
|
|
61
199
|
}
|
|
62
200
|
initLevelSlider() {
|
|
63
201
|
var _a;
|
|
@@ -65,12 +203,34 @@ export class ElevateLevelList {
|
|
|
65
203
|
console.log('Widget[elevate-level-list] DOM is not ready.');
|
|
66
204
|
return;
|
|
67
205
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
206
|
+
const wrapperWidth = this.levelsElement.parentElement.clientWidth;
|
|
207
|
+
// Desktop, Use clientWidth
|
|
208
|
+
// Mobile, Use scrollWidth
|
|
209
|
+
const contentWidth = this.isMobile
|
|
210
|
+
? this.levelsElement.scrollWidth
|
|
211
|
+
: this.levelsElement.clientWidth;
|
|
72
212
|
const childElementCount = this.levelsElement.childElementCount;
|
|
73
|
-
|
|
213
|
+
// If childElementCount === 0 or 1, No carousel
|
|
214
|
+
if (childElementCount <= 1) {
|
|
215
|
+
this.showSliderButton = false;
|
|
216
|
+
this.minOffset = 0;
|
|
217
|
+
this.offset = 0;
|
|
218
|
+
this.childElementWidth = this.levelsElement.firstElementChild.clientWidth;
|
|
219
|
+
this.moveCountForOneTouch = 1;
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
// keep original logic for desktop
|
|
223
|
+
this.showSliderButton =
|
|
224
|
+
!this.isMobile &&
|
|
225
|
+
this.levelsElement.clientWidth > wrapperWidth;
|
|
226
|
+
this.minOffset = wrapperWidth - contentWidth;
|
|
227
|
+
this.childElementWidth = this.levelsElement.firstElementChild.clientWidth;
|
|
228
|
+
if (childElementCount > 1) {
|
|
229
|
+
const gap = (contentWidth - this.childElementWidth * childElementCount) /
|
|
230
|
+
(childElementCount - 1);
|
|
231
|
+
this.childElementWidth += gap;
|
|
232
|
+
}
|
|
233
|
+
this.moveCountForOneTouch = Math.max(1, Math.ceil(wrapperWidth / this.childElementWidth) - 1);
|
|
74
234
|
}
|
|
75
235
|
debounce(callback, delay) {
|
|
76
236
|
{
|
|
@@ -102,12 +262,13 @@ export class ElevateLevelList {
|
|
|
102
262
|
});
|
|
103
263
|
}
|
|
104
264
|
render() {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
h("div", { key: '
|
|
265
|
+
var _a;
|
|
266
|
+
return (h(Host, { key: '780e54c101e1dd10513f959b08e3b7425ebba3ec' }, this.levels && [
|
|
267
|
+
h("div", { key: '70e7265746f1cb4788d137c43b9addf1443a6ae3', class: `SliderButton LeftButton ${this.offset == 0 ? 'Disabled' : ''} ${this.showSliderButton ? '' : 'Hidden'}`, onClick: () => this.slideTo(MOVE_TO.slideToRight) }, h("svg", { key: '20184f3e02bebe818f5119b9b71105a1d7e11681', fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, h("path", { key: '351e4a93e390f430045642692b585867e9569b6a', "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M15 19l-7-7 7-7" }))),
|
|
268
|
+
h("div", { key: 'd21722ad058c4e83d23dfaa6822850557de4e620', class: 'LevelItemsWrapper' }, h("div", { key: '03dccfd305222e9e4eb53277efeef43711f3b664', style: { 'left': `${this.offset}px` }, class: `LevelItems ${this.isMobile ? 'Mobile' : ''} ${this.isMobile && ((_a = this.levels) === null || _a === void 0 ? void 0 : _a.length) === 1 ? 'SingleItem' : ''}`, id: 'levelItems', ref: (el) => { this.levelsElement = el; } }, this.levels.map((level, idx) => {
|
|
108
269
|
return (h("div", { class: `Item ${this.selectedLevelId == level.id ? 'Active' : ''}`, onClick: this.onLevelClicked.bind(this, level) }, h("img", { alt: `Presentation Icon for ${level.presentation.displayName}`, class: "LevelImg", src: level.presentation.asset }), h("span", { class: "LevelName", title: level.presentation.displayName }, level.presentation.displayName), h("span", { class: "LevelPoints" }, idx == 0 ? '' : '>', this.convertNumberToCompactForm(level.firstEntryPoints), ' ', translate('points', this.language))));
|
|
109
270
|
}))),
|
|
110
|
-
h("div", { key: '
|
|
271
|
+
h("div", { key: '6fe81dc6338a8dc29e2a9dc7aedcbdb618660c82', class: `SliderButton RightButton ${this.offset <= this.minOffset ? 'Disabled' : ''} ${this.showSliderButton ? '' : 'Hidden'}`, onClick: () => this.slideTo(MOVE_TO.slideToLeft) }, h("svg", { key: '26e11511a54ac6d43fab18d39f0483f86af470cf', fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, h("path", { key: '6f3d02eb56c674a82a008022b0f8304a9c4bd72f', "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M9 5l7 7-7 7" })))
|
|
111
272
|
]));
|
|
112
273
|
}
|
|
113
274
|
static get is() { return "elevate-level-list"; }
|
|
@@ -230,6 +391,12 @@ export class ElevateLevelList {
|
|
|
230
391
|
"target": undefined,
|
|
231
392
|
"capture": false,
|
|
232
393
|
"passive": true
|
|
394
|
+
}, {
|
|
395
|
+
"name": "touchend",
|
|
396
|
+
"method": "onTouchEnd",
|
|
397
|
+
"target": undefined,
|
|
398
|
+
"capture": false,
|
|
399
|
+
"passive": true
|
|
233
400
|
}, {
|
|
234
401
|
"name": "resize",
|
|
235
402
|
"method": "handleResize",
|
|
@@ -16,5 +16,5 @@ var patchBrowser = () => {
|
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(async (options) => {
|
|
18
18
|
await globalScripts();
|
|
19
|
-
return bootstrapLazy([["bonus-elevate-levels_5",[[1,"bonus-elevate-levels",{"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"mbSource":[513,"mb-source"],"endpoint":[513],"language":[513],"translationUrl":[513,"translation-url"],"selectedLevelId":[1537,"selected-level-id"],"showDefault":[4,"show-default"],"elevateLevelParamProxy":[32],"elevateLevels":[32],"currentLevel":[32],"errorMessage":[32]},[[0,"selectedLevelChanged","selectedLevelChangedHandler"],[2,"elevateLevelsDataChange","elevateLevelsDataChangeHandler"]],{"selectedLevelId":["selectedLevelIdChangedHandler"],"elevateLevels":["selectedLevelIdChangedHandler"],"endpoint":["onSessionOrEndpointChange"],"language":["onSessionOrEndpointChange"],"translationUrl":["handleNewTranslations"]}],[0,"elevate-level-list",{"levels":[16],"language":[1],"selectedLevelId":[1537,"selected-level-id"],"showSliderButton":[32],"touchPosStart":[32],"touchPosEnd":[32],"offset":[32]},[[1,"touchstart","onTouchStart"],[1,"touchmove","onTouchMove"],[9,"resize","handleResize"]],{"selectedLevelId":["levelsChangedHandler"]}],[0,"elevate-level-presentation",{"elevateLevel":[16]}],[0,"elevate-levels-data",{"scopeParams":[1544,"scope-params"]}],[4,"general-styling-wrapper",{"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"mbSource":[1,"mb-source"],"translationUrl":[1,"translation-url"],"targetTranslations":[16]},null,{"mbSource":["handleMbSourceChange"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"]}]]]], options);
|
|
19
|
+
return bootstrapLazy([["bonus-elevate-levels_5",[[1,"bonus-elevate-levels",{"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"mbSource":[513,"mb-source"],"endpoint":[513],"language":[513],"translationUrl":[513,"translation-url"],"selectedLevelId":[1537,"selected-level-id"],"showDefault":[4,"show-default"],"elevateLevelParamProxy":[32],"elevateLevels":[32],"currentLevel":[32],"errorMessage":[32]},[[0,"selectedLevelChanged","selectedLevelChangedHandler"],[2,"elevateLevelsDataChange","elevateLevelsDataChangeHandler"]],{"selectedLevelId":["selectedLevelIdChangedHandler"],"elevateLevels":["selectedLevelIdChangedHandler"],"endpoint":["onSessionOrEndpointChange"],"language":["onSessionOrEndpointChange"],"translationUrl":["handleNewTranslations"]}],[0,"elevate-level-list",{"levels":[16],"language":[1],"selectedLevelId":[1537,"selected-level-id"],"showSliderButton":[32],"touchPosStart":[32],"touchPosEnd":[32],"offset":[32]},[[1,"touchstart","onTouchStart"],[1,"touchmove","onTouchMove"],[1,"touchend","onTouchEnd"],[9,"resize","handleResize"]],{"selectedLevelId":["levelsChangedHandler"]}],[0,"elevate-level-presentation",{"elevateLevel":[16]}],[0,"elevate-levels-data",{"scopeParams":[1544,"scope-params"]}],[4,"general-styling-wrapper",{"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"mbSource":[1,"mb-source"],"translationUrl":[1,"translation-url"],"targetTranslations":[16]},null,{"mbSource":["handleMbSourceChange"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"]}]]]], options);
|
|
20
20
|
});
|
|
@@ -179,7 +179,7 @@ var MOVE_TO;
|
|
|
179
179
|
MOVE_TO[MOVE_TO["slideToLeft"] = -1] = "slideToLeft";
|
|
180
180
|
})(MOVE_TO || (MOVE_TO = {}));
|
|
181
181
|
|
|
182
|
-
const elevateLevelListCss = "elevate-level-list{display:flex;flex-direction:row}.LevelItemsWrapper{display:flex;flex:1;margin-top:10px;min-height:30px;transition-property:all;position:relative;height:138px;overflow-x:hidden}.Mobile.LevelItems{overflow-x:hidden}.LevelItems{overflow-x:auto;display:flex;flex-direction:row;gap:10px;left:0;position:absolute;transition:left 0.5s ease-in-out}.LevelItems .Item:hover,.LevelItems .Item.Active{background-color:var(--emw--color-gray-50, rgb(244, 244, 244));box-shadow:0px 4px 13px 0px rgba(0, 0, 0, 0.25)}.LevelItems .Item{width:86px;height:125px;border-radius:15px;text-align:center;display:flex;flex-direction:column;cursor:pointer}.LevelItems .Item .LevelName{font-size:13px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.LevelItems .Item .LevelPoints{color:var(--emw--color-gray-100, rgb(118, 113, 113));font-size:10px}.LevelItems .Item .LevelImg{width:65px;height:68px;margin:11px auto}.SliderButton{display:flex;width:29px;align-items:center;cursor:pointer}.SliderButton.Disabled svg{stroke:var(--emw--color-gray-50, #cbc5c5)}.SliderButton.Hidden{display:none}";
|
|
182
|
+
const elevateLevelListCss = "elevate-level-list{display:flex;flex-direction:row}.LevelItemsWrapper{display:flex;flex:1;margin-top:10px;min-height:30px;transition-property:all;position:relative;height:138px;overflow-x:hidden}.Mobile.LevelItems{overflow-x:hidden}.LevelItems{overflow-x:auto;display:flex;flex-direction:row;gap:10px;left:0;position:absolute;transition:left 0.5s ease-in-out}.LevelItems .Item:hover,.LevelItems .Item.Active{background-color:var(--emw--color-gray-50, rgb(244, 244, 244));box-shadow:0px 4px 13px 0px rgba(0, 0, 0, 0.25)}.LevelItems .Item{width:86px;height:125px;border-radius:15px;text-align:center;display:flex;flex-direction:column;cursor:pointer}.LevelItems .Item .LevelName{font-size:13px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.LevelItems .Item .LevelPoints{color:var(--emw--color-gray-100, rgb(118, 113, 113));font-size:10px}.LevelItems .Item .LevelImg{width:65px;height:68px;margin:11px auto}.SliderButton{display:flex;width:29px;align-items:center;cursor:pointer}.SliderButton.Disabled svg{stroke:var(--emw--color-gray-50, #cbc5c5)}.SliderButton.Hidden{display:none}.LevelItems.Mobile.SingleItem{left:0 !important;width:100%;display:flex;justify-content:center;flex-wrap:nowrap;padding:0}.LevelItems.Mobile.SingleItem .Item{flex-grow:0;flex-shrink:0}";
|
|
183
183
|
const ElevateLevelListStyle0 = elevateLevelListCss;
|
|
184
184
|
|
|
185
185
|
const ElevateLevelList = class {
|
|
@@ -196,51 +196,189 @@ const ElevateLevelList = class {
|
|
|
196
196
|
this.touchPosEnd = undefined;
|
|
197
197
|
this.offset = 0;
|
|
198
198
|
}
|
|
199
|
+
centerLevelItem(index) {
|
|
200
|
+
if (!this.isMobile ||
|
|
201
|
+
!this.levelsElement ||
|
|
202
|
+
index < 0 ||
|
|
203
|
+
!this.levelsElement.children[index]) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
const wrapper = this.levelsElement.parentElement;
|
|
207
|
+
if (!wrapper) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const item = this.levelsElement.children[index];
|
|
211
|
+
const wrapperWidth = wrapper.clientWidth;
|
|
212
|
+
const contentWidth = this.levelsElement.scrollWidth;
|
|
213
|
+
const minOffset = Math.min(0, wrapperWidth - contentWidth);
|
|
214
|
+
const itemLeft = item.offsetLeft;
|
|
215
|
+
const itemWidth = item.offsetWidth;
|
|
216
|
+
let newOffset = wrapperWidth / 2 - (itemLeft + itemWidth / 2);
|
|
217
|
+
newOffset = newOffset < minOffset
|
|
218
|
+
? minOffset
|
|
219
|
+
: newOffset > 0
|
|
220
|
+
? 0
|
|
221
|
+
: newOffset;
|
|
222
|
+
this.minOffset = minOffset;
|
|
223
|
+
this.offset = newOffset;
|
|
224
|
+
}
|
|
225
|
+
moveToLevelItem(index, centerItem = false) {
|
|
226
|
+
if (!this.levelsElement ||
|
|
227
|
+
index < 0 ||
|
|
228
|
+
!this.levelsElement.children[index]) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const wrapper = this.levelsElement.parentElement;
|
|
232
|
+
if (!wrapper) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const item = this.levelsElement.children[index];
|
|
236
|
+
const wrapperWidth = wrapper.clientWidth;
|
|
237
|
+
const contentWidth = this.isMobile
|
|
238
|
+
? this.levelsElement.scrollWidth
|
|
239
|
+
: this.levelsElement.clientWidth;
|
|
240
|
+
const minOffset = Math.min(0, wrapperWidth - contentWidth);
|
|
241
|
+
if (contentWidth <= wrapperWidth) {
|
|
242
|
+
this.minOffset = 0;
|
|
243
|
+
this.offset = 0;
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const itemLeft = item.offsetLeft;
|
|
247
|
+
const itemWidth = item.offsetWidth;
|
|
248
|
+
let newOffset;
|
|
249
|
+
if (centerItem) {
|
|
250
|
+
newOffset = wrapperWidth / 2 - (itemLeft + itemWidth / 2);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
const currentLeft = -this.offset;
|
|
254
|
+
const currentRight = currentLeft + wrapperWidth;
|
|
255
|
+
const itemRight = itemLeft + itemWidth;
|
|
256
|
+
if (itemLeft >= currentLeft && itemRight <= currentRight) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
newOffset = itemLeft < currentLeft
|
|
260
|
+
? -itemLeft
|
|
261
|
+
: wrapperWidth - itemRight;
|
|
262
|
+
}
|
|
263
|
+
newOffset = newOffset < minOffset
|
|
264
|
+
? minOffset
|
|
265
|
+
: newOffset > 0
|
|
266
|
+
? 0
|
|
267
|
+
: newOffset;
|
|
268
|
+
this.minOffset = minOffset;
|
|
269
|
+
this.offset = newOffset;
|
|
270
|
+
}
|
|
199
271
|
onLevelClicked(elevateLevel) {
|
|
272
|
+
var _a, _b;
|
|
200
273
|
this.selectedLevelChanged.emit({ level: elevateLevel });
|
|
201
274
|
this.selectedLevelId = elevateLevel.id;
|
|
275
|
+
if (this.isMobile) {
|
|
276
|
+
const levelIndex = (_b = (_a = this.levels) === null || _a === void 0 ? void 0 : _a.findIndex((level) => level.id === elevateLevel.id)) !== null && _b !== void 0 ? _b : -1;
|
|
277
|
+
requestAnimationFrame(() => {
|
|
278
|
+
this.centerLevelItem(levelIndex);
|
|
279
|
+
});
|
|
280
|
+
}
|
|
202
281
|
}
|
|
203
282
|
levelsChangedHandler() {
|
|
204
283
|
this.initOffsetOfLevelItems();
|
|
205
284
|
}
|
|
206
285
|
initOffsetOfLevelItems() {
|
|
207
|
-
if (!this.levels || this.levels.length
|
|
286
|
+
if (!this.levels || this.levels.length === 0 || !this.selectedLevelId) {
|
|
208
287
|
return;
|
|
209
288
|
}
|
|
210
289
|
const currentLevelIndex = this.levels.findIndex((item) => {
|
|
211
|
-
return this.selectedLevelId
|
|
290
|
+
return this.selectedLevelId === item.id;
|
|
212
291
|
});
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
if (this.levels.length <= this.moveCountForOneTouch) {
|
|
292
|
+
if (currentLevelIndex === -1 && this.levels[0]) {
|
|
293
|
+
this.selectedLevelId = this.levels[0].id;
|
|
216
294
|
return;
|
|
217
295
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
296
|
+
if (this.levels.length <= 1) {
|
|
297
|
+
this.offset = 0;
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
const targetIndex = currentLevelIndex === -1 ? 0 : currentLevelIndex;
|
|
301
|
+
requestAnimationFrame(() => {
|
|
302
|
+
var _a;
|
|
303
|
+
if (this.isMobile) {
|
|
304
|
+
this.moveToLevelItem(targetIndex, true);
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
const wrapper = (_a = this.levelsElement) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
308
|
+
if (!wrapper || !this.levelsElement) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
const wrapperWidth = wrapper.clientWidth;
|
|
312
|
+
const contentWidth = this.levelsElement.clientWidth;
|
|
313
|
+
if (contentWidth <= wrapperWidth) {
|
|
314
|
+
this.offset = 0;
|
|
315
|
+
this.minOffset = 0;
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
// Desktop carousel
|
|
319
|
+
this.moveToLevelItem(targetIndex, false);
|
|
320
|
+
});
|
|
222
321
|
}
|
|
223
322
|
onTouchStart(e) {
|
|
224
|
-
this.
|
|
323
|
+
if (!this.isMobile) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
this.touchPosStart = {
|
|
327
|
+
clientX: e.touches[0].clientX,
|
|
328
|
+
clientY: e.touches[0].clientY
|
|
329
|
+
};
|
|
330
|
+
this.touchPosEnd = this.touchPosStart;
|
|
225
331
|
}
|
|
226
332
|
onTouchMove(e) {
|
|
227
|
-
this.
|
|
333
|
+
if (!this.isMobile) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
this.touchPosEnd = {
|
|
337
|
+
clientX: e.touches[0].clientX,
|
|
338
|
+
clientY: e.touches[0].clientY
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
onTouchEnd() {
|
|
342
|
+
if (!this.isMobile || !this.touchPosStart || !this.touchPosEnd || !this.levels || this.levels.length <= 1) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
228
345
|
const diffX = this.touchPosEnd.clientX - this.touchPosStart.clientX;
|
|
229
346
|
const diffY = this.touchPosEnd.clientY - this.touchPosStart.clientY;
|
|
230
|
-
|
|
231
|
-
|
|
347
|
+
const threshold = 30;
|
|
348
|
+
if (Math.abs(diffX) <= threshold || Math.abs(diffX) <= Math.abs(diffY)) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
if (diffX > 0) {
|
|
352
|
+
// Move right, Go to previous item
|
|
353
|
+
this.slideTo(MOVE_TO.slideToRight);
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
// Move left, Go to next item
|
|
357
|
+
this.slideTo(MOVE_TO.slideToLeft);
|
|
232
358
|
}
|
|
233
359
|
}
|
|
234
360
|
slideTo(direction) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
const leftOfPreNode = (Math.floor(newOffset / this.childElementWidth)) * this.childElementWidth;
|
|
239
|
-
const leftOfNextNode = (Math.ceil(newOffset / this.childElementWidth)) * this.childElementWidth;
|
|
240
|
-
//touchmove to right, get left of pre-node; touchmove to left, get left of next-node
|
|
241
|
-
newOffset = direction == MOVE_TO.slideToRight ? leftOfPreNode : leftOfNextNode;
|
|
361
|
+
if (!this.levelsElement || !this.childElementWidth || !this.moveCountForOneTouch || this.levelsElement.childElementCount <= 1) {
|
|
362
|
+
this.offset = 0;
|
|
363
|
+
return;
|
|
242
364
|
}
|
|
243
|
-
|
|
365
|
+
const currentOffset = this.isMobile
|
|
366
|
+
? this.offset
|
|
367
|
+
: this.levelsElement.offsetLeft;
|
|
368
|
+
let newOffset = currentOffset +
|
|
369
|
+
this.childElementWidth * this.moveCountForOneTouch * direction;
|
|
370
|
+
if (newOffset % this.childElementWidth !== 0) {
|
|
371
|
+
const leftOfPreNode = Math.floor(newOffset / this.childElementWidth) * this.childElementWidth;
|
|
372
|
+
const leftOfNextNode = Math.ceil(newOffset / this.childElementWidth) * this.childElementWidth;
|
|
373
|
+
newOffset = direction === MOVE_TO.slideToRight
|
|
374
|
+
? leftOfPreNode
|
|
375
|
+
: leftOfNextNode;
|
|
376
|
+
}
|
|
377
|
+
this.offset = newOffset < this.minOffset
|
|
378
|
+
? this.minOffset
|
|
379
|
+
: newOffset >= 0
|
|
380
|
+
? 0
|
|
381
|
+
: newOffset;
|
|
244
382
|
}
|
|
245
383
|
initLevelSlider() {
|
|
246
384
|
var _a;
|
|
@@ -248,12 +386,34 @@ const ElevateLevelList = class {
|
|
|
248
386
|
console.log('Widget[elevate-level-list] DOM is not ready.');
|
|
249
387
|
return;
|
|
250
388
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
389
|
+
const wrapperWidth = this.levelsElement.parentElement.clientWidth;
|
|
390
|
+
// Desktop, Use clientWidth
|
|
391
|
+
// Mobile, Use scrollWidth
|
|
392
|
+
const contentWidth = this.isMobile
|
|
393
|
+
? this.levelsElement.scrollWidth
|
|
394
|
+
: this.levelsElement.clientWidth;
|
|
255
395
|
const childElementCount = this.levelsElement.childElementCount;
|
|
256
|
-
|
|
396
|
+
// If childElementCount === 0 or 1, No carousel
|
|
397
|
+
if (childElementCount <= 1) {
|
|
398
|
+
this.showSliderButton = false;
|
|
399
|
+
this.minOffset = 0;
|
|
400
|
+
this.offset = 0;
|
|
401
|
+
this.childElementWidth = this.levelsElement.firstElementChild.clientWidth;
|
|
402
|
+
this.moveCountForOneTouch = 1;
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
// keep original logic for desktop
|
|
406
|
+
this.showSliderButton =
|
|
407
|
+
!this.isMobile &&
|
|
408
|
+
this.levelsElement.clientWidth > wrapperWidth;
|
|
409
|
+
this.minOffset = wrapperWidth - contentWidth;
|
|
410
|
+
this.childElementWidth = this.levelsElement.firstElementChild.clientWidth;
|
|
411
|
+
if (childElementCount > 1) {
|
|
412
|
+
const gap = (contentWidth - this.childElementWidth * childElementCount) /
|
|
413
|
+
(childElementCount - 1);
|
|
414
|
+
this.childElementWidth += gap;
|
|
415
|
+
}
|
|
416
|
+
this.moveCountForOneTouch = Math.max(1, Math.ceil(wrapperWidth / this.childElementWidth) - 1);
|
|
257
417
|
}
|
|
258
418
|
debounce(callback, delay) {
|
|
259
419
|
{
|
|
@@ -285,12 +445,13 @@ const ElevateLevelList = class {
|
|
|
285
445
|
});
|
|
286
446
|
}
|
|
287
447
|
render() {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
h("div", { key: '
|
|
448
|
+
var _a;
|
|
449
|
+
return (h(Host, { key: '780e54c101e1dd10513f959b08e3b7425ebba3ec' }, this.levels && [
|
|
450
|
+
h("div", { key: '70e7265746f1cb4788d137c43b9addf1443a6ae3', class: `SliderButton LeftButton ${this.offset == 0 ? 'Disabled' : ''} ${this.showSliderButton ? '' : 'Hidden'}`, onClick: () => this.slideTo(MOVE_TO.slideToRight) }, h("svg", { key: '20184f3e02bebe818f5119b9b71105a1d7e11681', fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, h("path", { key: '351e4a93e390f430045642692b585867e9569b6a', "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M15 19l-7-7 7-7" }))),
|
|
451
|
+
h("div", { key: 'd21722ad058c4e83d23dfaa6822850557de4e620', class: 'LevelItemsWrapper' }, h("div", { key: '03dccfd305222e9e4eb53277efeef43711f3b664', style: { 'left': `${this.offset}px` }, class: `LevelItems ${this.isMobile ? 'Mobile' : ''} ${this.isMobile && ((_a = this.levels) === null || _a === void 0 ? void 0 : _a.length) === 1 ? 'SingleItem' : ''}`, id: 'levelItems', ref: (el) => { this.levelsElement = el; } }, this.levels.map((level, idx) => {
|
|
291
452
|
return (h("div", { class: `Item ${this.selectedLevelId == level.id ? 'Active' : ''}`, onClick: this.onLevelClicked.bind(this, level) }, h("img", { alt: `Presentation Icon for ${level.presentation.displayName}`, class: "LevelImg", src: level.presentation.asset }), h("span", { class: "LevelName", title: level.presentation.displayName }, level.presentation.displayName), h("span", { class: "LevelPoints" }, idx == 0 ? '' : '>', this.convertNumberToCompactForm(level.firstEntryPoints), ' ', translate('points', this.language))));
|
|
292
453
|
}))),
|
|
293
|
-
h("div", { key: '
|
|
454
|
+
h("div", { key: '6fe81dc6338a8dc29e2a9dc7aedcbdb618660c82', class: `SliderButton RightButton ${this.offset <= this.minOffset ? 'Disabled' : ''} ${this.showSliderButton ? '' : 'Hidden'}`, onClick: () => this.slideTo(MOVE_TO.slideToLeft) }, h("svg", { key: '26e11511a54ac6d43fab18d39f0483f86af470cf', fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, h("path", { key: '6f3d02eb56c674a82a008022b0f8304a9c4bd72f', "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M9 5l7 7-7 7" })))
|
|
294
455
|
]));
|
|
295
456
|
}
|
|
296
457
|
get host() { return getElement(this); }
|
package/dist/esm/loader.js
CHANGED
|
@@ -5,7 +5,7 @@ import { g as globalScripts } from './app-globals-0f993ce5.js';
|
|
|
5
5
|
const defineCustomElements = async (win, options) => {
|
|
6
6
|
if (typeof window === 'undefined') return undefined;
|
|
7
7
|
await globalScripts();
|
|
8
|
-
return bootstrapLazy([["bonus-elevate-levels_5",[[1,"bonus-elevate-levels",{"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"mbSource":[513,"mb-source"],"endpoint":[513],"language":[513],"translationUrl":[513,"translation-url"],"selectedLevelId":[1537,"selected-level-id"],"showDefault":[4,"show-default"],"elevateLevelParamProxy":[32],"elevateLevels":[32],"currentLevel":[32],"errorMessage":[32]},[[0,"selectedLevelChanged","selectedLevelChangedHandler"],[2,"elevateLevelsDataChange","elevateLevelsDataChangeHandler"]],{"selectedLevelId":["selectedLevelIdChangedHandler"],"elevateLevels":["selectedLevelIdChangedHandler"],"endpoint":["onSessionOrEndpointChange"],"language":["onSessionOrEndpointChange"],"translationUrl":["handleNewTranslations"]}],[0,"elevate-level-list",{"levels":[16],"language":[1],"selectedLevelId":[1537,"selected-level-id"],"showSliderButton":[32],"touchPosStart":[32],"touchPosEnd":[32],"offset":[32]},[[1,"touchstart","onTouchStart"],[1,"touchmove","onTouchMove"],[9,"resize","handleResize"]],{"selectedLevelId":["levelsChangedHandler"]}],[0,"elevate-level-presentation",{"elevateLevel":[16]}],[0,"elevate-levels-data",{"scopeParams":[1544,"scope-params"]}],[4,"general-styling-wrapper",{"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"mbSource":[1,"mb-source"],"translationUrl":[1,"translation-url"],"targetTranslations":[16]},null,{"mbSource":["handleMbSourceChange"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"]}]]]], options);
|
|
8
|
+
return bootstrapLazy([["bonus-elevate-levels_5",[[1,"bonus-elevate-levels",{"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"mbSource":[513,"mb-source"],"endpoint":[513],"language":[513],"translationUrl":[513,"translation-url"],"selectedLevelId":[1537,"selected-level-id"],"showDefault":[4,"show-default"],"elevateLevelParamProxy":[32],"elevateLevels":[32],"currentLevel":[32],"errorMessage":[32]},[[0,"selectedLevelChanged","selectedLevelChangedHandler"],[2,"elevateLevelsDataChange","elevateLevelsDataChangeHandler"]],{"selectedLevelId":["selectedLevelIdChangedHandler"],"elevateLevels":["selectedLevelIdChangedHandler"],"endpoint":["onSessionOrEndpointChange"],"language":["onSessionOrEndpointChange"],"translationUrl":["handleNewTranslations"]}],[0,"elevate-level-list",{"levels":[16],"language":[1],"selectedLevelId":[1537,"selected-level-id"],"showSliderButton":[32],"touchPosStart":[32],"touchPosEnd":[32],"offset":[32]},[[1,"touchstart","onTouchStart"],[1,"touchmove","onTouchMove"],[1,"touchend","onTouchEnd"],[9,"resize","handleResize"]],{"selectedLevelId":["levelsChangedHandler"]}],[0,"elevate-level-presentation",{"elevateLevel":[16]}],[0,"elevate-levels-data",{"scopeParams":[1544,"scope-params"]}],[4,"general-styling-wrapper",{"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"mbSource":[1,"mb-source"],"translationUrl":[1,"translation-url"],"targetTranslations":[16]},null,{"mbSource":["handleMbSourceChange"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"]}]]]], options);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export { defineCustomElements };
|
|
@@ -29,12 +29,15 @@ export declare class ElevateLevelList {
|
|
|
29
29
|
private childElementWidth;
|
|
30
30
|
private minOffset;
|
|
31
31
|
private isMobile;
|
|
32
|
+
private centerLevelItem;
|
|
33
|
+
private moveToLevelItem;
|
|
32
34
|
selectedLevelChanged: EventEmitter;
|
|
33
35
|
onLevelClicked(elevateLevel: ElevateLevel): void;
|
|
34
36
|
levelsChangedHandler(): void;
|
|
35
37
|
initOffsetOfLevelItems(): void;
|
|
36
38
|
onTouchStart(e: TouchEvent): void;
|
|
37
39
|
onTouchMove(e: TouchEvent): void;
|
|
40
|
+
onTouchEnd(): void;
|
|
38
41
|
slideTo(direction: MOVE_TO): void;
|
|
39
42
|
initLevelSlider(): void;
|
|
40
43
|
debounce(callback: Function, delay: number): () => void;
|