{"version":3,"sources":["webpack:///./LeLab.Web/src/js/media-viewer.entry.js"],"names":["PageComponent","constructor","node","this","json","isFirstInit","JSON","parse","querySelector","innerHTML","error","console","setTimeout","history","back","slider","slideCount","slides","length","sliderOpts","container","prevButton","nextButton","nav","loop","speed","startIndex","PageState","get","onInit","autoplay","createHtml","clickHandler","click","bind","addEventListener","querySelectorAll","TinySlider","events","on","i","set","Math","max","displayIndex","forEach","x","parentNode","removeChild","previousLabel","nextLabel","closeLabel","tns","type","appendChild","createImageSlide","createYoutubeSlide","obj","elm","document","createElement","classList","add","setAttribute","src","alt","poster","videoId","picture","e","play","target","closest","slide","video","dataset","iframe","width","frameBorder","allow","allowfullscreen","prepend","destroy","removeEventListener"],"mappings":"4FAAA,iCAwNA,IAAIA,IAAc,gBApNlB,MACIC,aAAY,KAAEC,IACVC,KAAKD,KAAOA,EACZC,KAAKC,KAAO,KACZD,KAAKE,aAAc,EAEnB,IACIF,KAAKC,KAAOE,KAAKC,MAAMJ,KAAKD,KAAKM,cAAc,mCAAmCC,WACpF,MAAOC,GAGL,OAFAC,QAAQD,MAAM,4CACdE,WAAW,IAAMC,QAAQC,OAAQ,KAIrCX,KAAKY,OAAS,KACdZ,KAAKa,WAAab,KAAKC,KAAKa,OAASd,KAAKC,KAAKa,OAAOC,OAAS,EAC/Df,KAAKgB,WAAa,KAAM,CACpBC,UAAWjB,KAAKD,KAAKM,cAAc,sBACnCa,WAAYlB,KAAKD,KAAKM,cAAc,uBACpCc,WAAYnB,KAAKD,KAAKM,cAAc,uBACpCe,KAAK,EACLC,MAAM,EACNC,MAAO,IACPC,WAAYC,IAAUC,IAAI,eAAiB,EAC3CC,OAAQ,IAAM1B,KAAK2B,aAGvB3B,KAAK4B,aAEL5B,KAAK6B,aAAe7B,KAAK8B,MAAMC,KAAK/B,MACpCA,KAAKD,KAAKiC,iBAAiB,QAAShC,KAAK6B,cAErC7B,KAAKD,KAAKkC,iBAAiB,uBAAuBlB,OAAS,GAC3Df,KAAKY,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from \"barba\";\r\nimport TinySlider from \"utils/tiny-slider\";\r\n\r\nclass MediaViewer {\r\n constructor({ node }) {\r\n this.node = node;\r\n this.json = null;\r\n this.isFirstInit = true;\r\n\r\n try {\r\n this.json = JSON.parse(this.node.querySelector('script[type=\"application/json\"]').innerHTML);\r\n } catch (error) {\r\n console.error(\"Media Viewer, error in JSON format.\");\r\n setTimeout(() => history.back(), 1000);\r\n return;\r\n }\r\n\r\n this.slider = null;\r\n this.slideCount = this.json.slides ? this.json.slides.length : 0;\r\n this.sliderOpts = () => ({\r\n container: this.node.querySelector(\".media-viewer__tns\"),\r\n prevButton: this.node.querySelector(\".media-viewer__prev\"),\r\n nextButton: this.node.querySelector(\".media-viewer__next\"),\r\n nav: false,\r\n loop: true,\r\n speed: 500,\r\n startIndex: PageState.get(\"startIndex\") || 0,\r\n onInit: () => this.autoplay()\r\n });\r\n\r\n this.createHtml();\r\n\r\n this.clickHandler = this.click.bind(this);\r\n this.node.addEventListener(\"click\", this.clickHandler);\r\n\r\n if (this.node.querySelectorAll(\".media-viewer__item\").length > 1) {\r\n this.slider = new TinySlider(this.sliderOpts);\r\n this.slider.events.on(\"indexChanged\", (i) => {\r\n PageState.set(\"startIndex\", Math.max(0, i.displayIndex - 1));\r\n // Remove all video iframe\r\n this.node.querySelectorAll(\".media-viewer__iframe\").forEach((x) => {\r\n x.parentNode.removeChild(x);\r\n });\r\n });\r\n } else {\r\n this.autoplay();\r\n }\r\n }\r\n\r\n createHtml() {\r\n this.node.innerHTML = `\r\n \r\n