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IACoB,GAAvBhC,KAAKG,MAAMkC,GAAGjB,OAAsC,GAAxBpB,KAAKG,MAAMkC,GAAGf,QAAa,WACtD,IAAIgB,EAAQD,EACZ,EAAKlC,MAAMkC,GAAGJ,MAAQ,IAAIC,MAC1B,EAAK/B,MAAMkC,GAAGJ,MAAME,OAAS,WACzB,EAAKC,YAAYE,GAAO,EAC3B,EACD,EAAKnC,MAAMkC,GAAGJ,MAAMf,IAAM,EAAKf,MAAMkC,GAAGnB,GANc,IAUrE,G,yBAED,SAAYqB,EAAGC,GACX,IAAIC,EAAIzC,KAAKG,MAAMoC,GAAGN,MAAMb,MACxBsB,EAAI1C,KAAKG,MAAMoC,GAAGN,MAAMX,OAC5BtB,KAAKG,MAAMoC,GAAGnB,MAAQqB,EACtBzC,KAAKG,MAAMoC,GAAGjB,OAASoB,EACpBF,GACCxC,KAAKE,SAAU,IAAIyC,EAAAA,EAAW,CAC1BC,WAAY5C,KAAKG,MACjBG,KAAMN,KAAKM,KACXgC,MAAOC,IAEXvC,KAAKE,SAAS2C,SAEd7C,KAAKE,SAAS4C,QAAQF,WAAWL,GAAGnB,MAAQqB,EAC5CzC,KAAKE,SAAS4C,QAAQF,WAAWL,GAAGjB,OAASoB,EAC7C1C,KAAKE,SAAS6C,oBAAoBR,GAEzC,G,4BAED,SAAeS,GACXhD,KAAKE,SAAW,IAAIyC,EAAAA,EAAW,CAC3BC,WAAY5C,KAAKG,MACjBG,KAAMN,KAAKM,KACXgC,MAAOU,IAEXhD,KAAKE,SAAS2C,MACjB,M,gFA1FC/C,GA+FC,SAASmD,EAAWC,GACvBA,EAAS1C,SAAQ,SAAC2C,GAEQ,IAAlBA,EAAKC,UACL,IAAItD,EAAaqD,EAExB,GACJ,C","sources":["webpack://nationalspacecentre.web/./wwwroot/app/src/modules/lightboxes-galleries/lightboxes.js"],"sourcesContent":["// *****************************************\r\n// ************* Image Gallery *************\r\n// *****************************************\r\n\r\nimport PhotoSwipe from 'photoswipe';\r\nimport 'photoswipe/style.css';\r\n\r\nimport './image-galleries.scss';\r\n\r\nclass ImageGallery {\r\n\r\n constructor(el) {\r\n this.el = el;\r\n this.imageSizesOkay = true;\r\n this.lightbox = null;\r\n // get items\r\n this.items = [];\r\n let findItems = this.el.querySelectorAll('a');\r\n this.loop = findItems.length > 1;\r\n if(findItems != null) {\r\n [...findItems].forEach((itemElement, itemIndex) => {\r\n let dataWidth = itemElement.dataset.pswpWidth,\r\n dataHeight = itemElement.dataset.pswpHeight,\r\n figCaption = itemElement.querySelector('figcaption');\r\n this.items[itemIndex] = {\r\n src: itemElement.getAttribute('href'),\r\n width: parseFloat(dataWidth) > 0 ? parseFloat(dataWidth) : 0,\r\n height: parseFloat(dataHeight) > 0 ? parseFloat(dataHeight) : 0,\r\n alt: figCaption ? figCaption.innerText : 'Image'\r\n };\r\n this.imageSizesOkay = this.items[itemIndex].width > 0 && this.items[itemIndex].height > 0;\r\n let _this = this;\r\n // behaviour\r\n itemElement.onclick = (e) => {\r\n e.stopPropagation();\r\n e.preventDefault();\r\n if(!_this.imageSizesOkay) {\r\n _this.getImageDimensions(itemIndex);\r\n } else {\r\n this.createLightbox(itemIndex);\r\n }\r\n };\r\n });\r\n }\r\n }\r\n\r\n getImageDimensions(priorityIndex) {\r\n // priority index\r\n if(this.items[priorityIndex].width == 0 || this.items[priorityIndex].height == 0) {\r\n let index = priorityIndex;\r\n this.items[priorityIndex].image = new Image();\r\n this.items[priorityIndex].image.onload = () => {\r\n this.imageLoaded(priorityIndex, true);\r\n }\r\n this.items[priorityIndex].image.src = this.items[priorityIndex].src;\r\n } else {\r\n this.createLightbox(priorityIndex);\r\n }\r\n // other images\r\n for(var x=0; x < this.items.length; x++) {\r\n if( x !== priorityIndex) {\r\n if(this.items[x].width == 0 || this.items[x].height == 0) {\r\n let index = x;\r\n this.items[x].image = new Image();\r\n this.items[x].image.onload = () => {\r\n this.imageLoaded(index, false);\r\n }\r\n this.items[x].image.src = this.items[x].src;\r\n }\r\n }\r\n };\r\n }\r\n\r\n imageLoaded(i, create) {\r\n let w = this.items[i].image.width,\r\n h = this.items[i].image.height;\r\n this.items[i].width = w;\r\n this.items[i].height = h;\r\n if(create) {\r\n this.lightbox= new PhotoSwipe({\r\n dataSource: this.items,\r\n loop: this.loop,\r\n index: i\r\n });\r\n this.lightbox.init();\r\n } else {\r\n this.lightbox.options.dataSource[i].width = w;\r\n this.lightbox.options.dataSource[i].height = h;\r\n this.lightbox.refreshSlideContent(i);\r\n }\r\n }\r\n\r\n createLightbox(imageIndex) {\r\n this.lightbox = new PhotoSwipe({\r\n dataSource: this.items,\r\n loop: this.loop,\r\n index: imageIndex\r\n });\r\n this.lightbox.init();\r\n }\r\n\r\n}\r\n\r\n// export the default function to create\r\nexport function createFrom(wrappers) {\r\n wrappers.forEach((node) => {\r\n // if node is an element\r\n if (node.nodeType === 1) {\r\n new ImageGallery(node);\r\n }\r\n });\r\n}"],"names":["ImageGallery","el","this","imageSizesOkay","lightbox","items","findItems","querySelectorAll","loop","length","forEach","itemElement","itemIndex","dataWidth","dataset","pswpWidth","dataHeight","pswpHeight","figCaption","querySelector","src","getAttribute","width","parseFloat","height","alt","innerText","_this","onclick","e","stopPropagation","preventDefault","createLightbox","getImageDimensions","priorityIndex","image","Image","onload","imageLoaded","x","index","i","create","w","h","PhotoSwipe","dataSource","init","options","refreshSlideContent","imageIndex","createFrom","wrappers","node","nodeType"],"sourceRoot":""}