{"version":3,"sources":["webpack:///./LeLab.Web/src/js/bike-heading.entry.js"],"names":["PageComponent","constructor","node","this","heading","filter","querySelector","specs","slider","openSpecsHandler","openSpecs","bind","focusinSpecsHandler","e","stopPropagation","openMediaViewerHandler","openMediaViewer","addEventListener","sliderOpts","mode","isGallery","container","prevButton","nextButton","navPosition","speed","startIndex","PageState","get","querySelectorAll","length","TinySlider","events","on","i","set","Math","max","displayIndex","clas","classList","contains","add","window","matchMedia","matches","item","target","closest","index","dataset","slideIndex","PageSubset","open","destroy","removeEventListener"],"mappings":"2FAAA,0BAqFA,IAAIA,IAAc,gBAhFlB,MAEIC,aAAY,KAAEC,IACVC,KAAKC,QAAUF,EACfC,KAAKE,OAASF,KAAKC,QAAQE,cAAc,8BACzCH,KAAKI,MAAQJ,KAAKC,QAAQE,cAAc,uBACxCH,KAAKK,OAAS,KAEdL,KAAKM,iBAAmBN,KAAKO,UAAUC,KAAKR,MAC5CA,KAAKS,oBAAsBC,IAEvBA,EAAEC,mBAENX,KAAKY,uBAAyBZ,KAAKa,gBAAgBL,KAAKR,MAExDA,KAAKE,OAAOY,iBAAiB,QAASd,KAAKM,kBAC3CN,KAAKE,OAAOY,iBAAiB,UAAWd,KAAKS,qBAC7CT,KAAKC,QAAQa,iBAAiB,QAASd,KAAKY,wBAE5CZ,KAAKe,WAAa,KAAM,CACpBC,KAAMhB,KAAKiB,YAAc,UAAY,WACrCC,UAAWlB,KAAKC,QAAQE,cAAc,6BACtCgB,WAAYnB,KAAKC,QAAQE,cAAc,2BACvCiB,WAAYpB,KAAKC,QAAQE,cAAc,2BACvCkB,YAAa,SACbC,MAAO,IACPC,WAAYC,IAAUC,IA5BN,4BA4BkC,IAGlDzB,KAAKC,QAAQyB,iBAAiB,6BAA6BC,OAAS,IACpE3B,KAAKK,OAAS,IAAIuB,IAAW5B,KAAKe,YAClCf,KAAKK,OAAOwB,OAAOC,GAAG,eAAgBC,IAClCP,IAAUQ,IAlCE,0BAkCuBC,KAAKC,IAAI,EAAGH,EAAEI,aAAe,OAK5E5B,UAAUG,GAGN,MAAM0B,EAAO,2BACRpC,KAAKI,MAAMiC,UAAUC,SAASF,KAC/BpC,KAAKI,MAAMiC,UAAUE,IAAIH,GACzB1B,EAAEC,mBAIVM,YACI,OAAOuB,OAAOC,WAAW,sBAAsBC,QAGnD7B,gBAAgBH,GACZ,MAAMiC,EAAOjC,EAAEkC,OAAOC,QAAQ,sBAC9B,IAAKF,EAAM,OACX,MAAMG,EAAQH,EAAKI,QAAQC,WAC3BC,IAAWC,KAAK,kBAAmB,CAAE,WAAcjB,KAAKC,IAAI,EAAGY,KAGnEK,UACQnD,KAAKK,QAAUL,KAAKK,OAAO8C,SAC3BnD,KAAKK,OAAO8C,UAGhBnD,KAAKE,OAAOkD,oBAAoB,QAASpD,KAAKM,kBAC9CN,KAAKE,OAAOkD,oBAAoB,UAAWpD,KAAKS,qBAChDT,KAAKC,QAAQmD,oBAAoB,QAASpD,KAAKY,+BAExCZ,KAAKC,eACLD,KAAKE,cACLF,KAAKI,aACLJ,KAAKe,kBACLf,KAAKK,cAELL,KAAKM,wBACLN,KAAKS,2BACLT,KAAKY,4B","file":"bike-heading.js","sourcesContent":["import { PageComponent, PageState, PageSubset } from \"barba\"\r\nimport TinySlider from \"utils/tiny-slider\"\r\n\r\nconst pageStateStartIndex = 'bike-heading-startIndex'\r\n\r\nclass BikeHeadingClass {\r\n\r\n constructor({ node }) {\r\n this.heading = node\r\n this.filter = this.heading.querySelector('.bike-heading-head__filter')\r\n this.specs = this.heading.querySelector('.bike-heading-specs')\r\n this.slider = null\r\n \r\n this.openSpecsHandler = this.openSpecs.bind(this)\r\n this.focusinSpecsHandler = e => {\r\n // Conflict with \"is-within\", for this reason stopPropagation().\r\n e.stopPropagation()\r\n }\r\n this.openMediaViewerHandler = this.openMediaViewer.bind(this)\r\n\r\n this.filter.addEventListener('click', this.openSpecsHandler)\r\n this.filter.addEventListener('focusin', this.focusinSpecsHandler)\r\n this.heading.addEventListener(\"click\", this.openMediaViewerHandler)\r\n\r\n this.sliderOpts = () => ({\r\n mode: this.isGallery() ? 'gallery' : 'carousel',\r\n container: this.heading.querySelector('.bike-heading-slider__tns'),\r\n prevButton: this.heading.querySelector('.bike-heading-ctrl-prev'),\r\n nextButton: this.heading.querySelector('.bike-heading-ctrl-next'),\r\n navPosition: 'bottom',\r\n speed: 500,\r\n startIndex: PageState.get(pageStateStartIndex) || 0\r\n })\r\n \r\n if (this.heading.querySelectorAll('.bike-heading-slider__pic').length > 1) {\r\n this.slider = new TinySlider(this.sliderOpts)\r\n this.slider.events.on('indexChanged', i => {\r\n PageState.set(pageStateStartIndex, Math.max(0, i.displayIndex - 1))\r\n })\r\n }\r\n }\r\n\r\n openSpecs(e) {\r\n // The class is also driven with \"is-within\", \r\n // for this reason we use stopPropagation().\r\n const clas = 'bike-heading-specs--open'\r\n if (!this.specs.classList.contains(clas)) {\r\n this.specs.classList.add(clas)\r\n e.stopPropagation()\r\n }\r\n }\r\n\r\n isGallery() {\r\n return window.matchMedia(\"(min-width: 992px)\").matches\r\n }\r\n\r\n openMediaViewer(e) {\r\n const item = e.target.closest('[data-slide-index]')\r\n if (!item) return\r\n const index = item.dataset.slideIndex\r\n PageSubset.open('mv-bike-heading', { 'startIndex': Math.max(0, index) })\r\n }\r\n\r\n destroy() {\r\n if (this.slider && this.slider.destroy) {\r\n this.slider.destroy()\r\n }\r\n \r\n this.filter.removeEventListener('click', this.openSpecsHandler)\r\n this.filter.removeEventListener('focusin', this.focusinSpecsHandler)\r\n this.heading.removeEventListener('click', this.openMediaViewerHandler)\r\n\r\n delete this.heading\r\n delete this.filter\r\n delete this.specs\r\n delete this.sliderOpts\r\n delete this.slider\r\n\r\n delete this.openSpecsHandler\r\n delete this.focusinSpecsHandler\r\n delete this.openMediaViewerHandler\r\n }\r\n\r\n}\r\n\r\nnew PageComponent(\".bike-heading\", BikeHeadingClass)"],"sourceRoot":""}