{"version":3,"file":"Swipebox-ed9a2b0e.js","names":["define","Moduler","create","defaults","triggerElement","pauseTriggerElement","videoElement","triggerEvent","init","self","this","targetVideo","el","querySelector","options","triggers","querySelectorAll","forEach","trigger","addEventListener","e","play","pause","box","prev","closest","next","touchstartX","touchendX","preventDefault","changedTouches","screenX","click","window","key","document"],"sources":["Swipebox.js"],"mappings":"AAAAA,OAAO,CAAC,YAAY,SAAUC,GAC1B,aAEA,OAAOA,EAAQC,OAAO,CAClBC,SAAU,CACNC,eAAgB,UAChBC,oBAAqB,gBACrBC,aAAc,QACdC,aAAc,SAGlBC,KAAM,WACF,IAAIC,EAAOC,KAEX,IAAIC,EAAcF,EAAKG,GAAGC,cAAcJ,EAAKK,QAAQR,eAAiBG,EAAKG,GAAGC,cAAc,SAExFE,EAAWN,EAAKG,GAAGI,iBAAiBP,EAAKK,QAAQV,iBAAmBK,EAAKG,GAAGC,cAAc,OAE9F,GAAIF,IACAI,EAASE,SAAQC,IACbA,EAAQC,iBAAiBV,EAAKK,QAAQP,cAAc,SAAUa,GAC1DT,EAAYU,MAChB,GAAE,IAEFZ,EAAKK,QAAQT,qBAAqB,CACdI,EAAKG,GAAGI,iBAAiBP,EAAKK,QAAQT,qBAC5CY,SAAQC,IAClBA,EAAQC,iBAAiBV,EAAKK,QAAQP,cAAc,SAAUa,GAC1DT,EAAYW,OAChB,GAAE,GAEV,CAIJb,EAAKG,GAAGI,iBAAiB,gBAAgBC,SAAQM,IAC7C,IAAIC,EAAOD,EAAIE,QAAQ,WAAWZ,cAAc,gBAC5Ca,EAAOH,EAAIE,QAAQ,WAAWZ,cAAc,gBAChD,IAAKW,IAASE,EACV,OAEJ,IAAIC,EAAc,EACdC,EAAY,EAChBL,EAAIJ,iBAAiB,cAAcC,IAC/BA,EAAES,iBACFF,EAAcP,EAAEU,eAAe,GAAGC,OAAO,IAE7CR,EAAIJ,iBAAiB,YAAYC,IAC7BA,EAAES,iBACFD,EAAYR,EAAEU,eAAe,GAAGC,QAC5BL,GAAQE,EAAYD,EAAc,GAClCD,EAAKM,QACER,GAAQI,EAAYD,EAAc,IACzCH,EAAKQ,OACT,GACF,IAINC,OAAOd,iBAAiB,WAAW,SAAUC,GACzC,GAAc,WAAVA,EAAEc,IAAkB,CACpB,IAAIX,EAAMY,SAAStB,cAAc,kDAC7BU,GACAA,EAAIE,QAAQ,WAAWZ,cAAc,iBAAiBmB,OAE9D,CACJ,GACJ,GAER","sourcesContent":["define(['moduler'], function (Moduler) {\r\n 'use strict';\r\n\r\n return Moduler.create({\r\n defaults: {\r\n triggerElement: 'img,svg',\r\n pauseTriggerElement: '.cssbox_close',\r\n videoElement: 'video',\r\n triggerEvent: 'click'\r\n },\r\n\r\n init: function () {\r\n var self = this;\r\n\r\n let targetVideo = self.el.querySelector(self.options.videoElement) ?? self.el.querySelector('video');\r\n\r\n let triggers = self.el.querySelectorAll(self.options.triggerElement) ?? self.el.querySelector('img');\r\n\r\n if (targetVideo) {\r\n triggers.forEach(trigger => {\r\n trigger.addEventListener(self.options.triggerEvent, function (e) {\r\n targetVideo.play();\r\n });\r\n });\r\n if (self.options.pauseTriggerElement) {\r\n let pauseTriggers = self.el.querySelectorAll(self.options.pauseTriggerElement);\r\n pauseTriggers.forEach(trigger => {\r\n trigger.addEventListener(self.options.triggerEvent, function (e) {\r\n targetVideo.pause();\r\n });\r\n });\r\n }\r\n }\r\n\r\n // swipe left+right to change image\r\n self.el.querySelectorAll('.cssbox_full').forEach(box => {\r\n let prev = box.closest('.cssbox').querySelector('.cssbox_prev');\r\n let next = box.closest('.cssbox').querySelector('.cssbox_next');\r\n if (!prev && !next) {\r\n return;\r\n }\r\n let touchstartX = 0;\r\n let touchendX = 0;\r\n box.addEventListener('touchstart', e => {\r\n e.preventDefault();\r\n touchstartX = e.changedTouches[0].screenX;\r\n });\r\n box.addEventListener('touchend', e => {\r\n e.preventDefault();\r\n touchendX = e.changedTouches[0].screenX;\r\n if (next && touchendX < touchstartX - 20) {\r\n next.click();\r\n } else if (prev && touchendX > touchstartX + 20){\r\n prev.click();\r\n }\r\n });\r\n });\r\n\r\n //close any open box on escape key\r\n window.addEventListener('keydown', function (e) {\r\n if (e.key === 'Escape') {\r\n let box = document.querySelector('a:target > img.cssbox_thumb + span.cssbox_full');\r\n if (box) {\r\n box.closest('.cssbox').querySelector('.cssbox_close').click();\r\n }\r\n }\r\n });\r\n }\r\n });\r\n});"]}