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AGkE,cACrCD,GACAA,EAAOE,aAAaH,EAAOA,EAAOhE,OAAS,GAAIgE,EAAO,G,EAoClDO,CAAUb,GACVY,EAAsBZ,EAAU,GAClC,GACJ,EAYAY,EAAyBZ,I,MAC3B,MAAMc,EAVmBd,KACzB,MAAMM,EAASP,EAAiBC,GAChC,GAAIM,EAAOhE,QAAU,EAEjB,OADoBgE,EAAO,GACRS,aAAa,OAEpC,MAAO,EAAE,EAIWC,CAAoBhB,IAAc,GAChDiB,EAA6C,QAA5BC,EAAAlB,EAAUmB,0BAAkB,IAAAD,OAAA,EAAAA,EAAEhE,iBAEjD+D,GACAG,EAAoBH,EAAgB,EAAGH,E,EAIzCM,EAAsBA,CAACH,EAAyBI,EAAeP,KACjE,GAAIA,EAAYxE,OAAS,IAAM+E,GAEpBJ,aAA0BK,YAAa,CAEO,MAD5BR,EAAYS,OAAOF,EAAQ,IAIhDJ,EAAeO,UAAYV,EAAYW,UAAU,EAAGJ,EAAQ,GAC5DvB,EAA0B4B,OAAOC,YAAW,IAAMP,EAAoBH,EAAgBI,EAAQ,EAAGP,IAAc,MAE/GG,EAAeO,UAAYV,EAAYW,UAAU,EAAGJ,GACpDvB,EAA0B4B,OAAOC,YAAW,IAAMP,EAAoBH,EAAgBI,EAAQ,EAAGP,IAAc,I,GAMrHT,EAAqBA,KACvBR,GAAoB,EACpB6B,OAAOC,YAAW,KACd9B,GAAoB,CAAK,GAC1B,IAAI,GAIXxD,EAAAA,EAAAA,KAAI,aAAaU,SAAQ6E,IACrB1B,EAAmB0B,GAxEnB7B,EAyEmB6B,GAzES7E,SAAQC,GAAKA,EAAEC,iBAAiB,SAASI,IAC7DA,aAAaE,mBACb7B,EAAAA,EAAAA,aAAY2B,E,KAuEC,GAE5B,EAzGD,E","sources":["webpack://bm3giraffe/./WebRoot/js/fs-img.ts","webpack://bm3giraffe/./WebRoot/js/util.ts","webpack://bm3giraffe/webpack/bootstrap","webpack://bm3giraffe/webpack/runtime/define property getters","webpack://bm3giraffe/webpack/runtime/hasOwnProperty shorthand","webpack://bm3giraffe/webpack/runtime/make namespace object","webpack://bm3giraffe/./WebRoot/js/photobox.ts"],"sourcesContent":["import { all } from './util';\n\n// include this, then mark images with class \"fs\"\n\n\nconst canShowFullscreen = true;\n\n// click event that triggers the fullscreen image display for the given HTMLImageElement\nconst showFsImage = (img: HTMLImageElement) => {\n if (canShowFullscreen) {\n const url =\n img.srcset\n ? img.srcset.split(',').map(s => s.replace(\" 1x\", \"\").replace(\" 2x\", \"\").replace(\" 3x\", \"\").replace(\" 4x\", \"\")).pop() || img.src\n : img.src\n\n const fsImageContainers = all('.fs-img');\n\n if (fsImageContainers.length) {\n const newImg = document.createElement('img');\n newImg.src = url;\n newImg.className = \"fs-img__image\";\n\n const fsImageContainer = fsImageContainers[0];\n fsImageContainer.appendChild(newImg);\n fsImageContainer.classList.add('fs-img__active');\n }\n }\n}\n\n// prepares the fullscreen image container\n\nall('.fs-img').forEach(i => {\n i.addEventListener('click', () => {\n while (i.lastElementChild) {\n i.removeChild(i.lastElementChild); // deletes all content\n }\n i.classList.remove('fs-img__active'); // then makes it disappear\n })\n});\n\n\n// prepares the fullscreen-enabled images\nall('.fs').forEach(i => {\n i.addEventListener('click', e => {\n if (e.target instanceof HTMLImageElement) {\n showFsImage(e.target);\n }\n })\n});\n\nexport {\n showFsImage\n}","function first(selector: string, root?: Element) : T {\r\n const foundElement = (root || document).querySelector(selector);\r\n if (!foundElement) {\r\n throw new Error(`element '${selector}' was not found.`);\r\n } else {\r\n return foundElement as T;\r\n }\r\n}\r\n\r\nfunction tryFirst(selector: string, root?: Element): T | null {\r\n const foundElement = (root || document).querySelector(selector);\r\n if (!foundElement) {\r\n console.warn(`element '${selector}' was not found.`);\r\n }\r\n return foundElement;\r\n}\r\n\r\nfunction all(selector: string, root?: Element): Array {\r\n return Array.from((root || document).querySelectorAll(selector));\r\n}\r\n\r\n\r\nexport {\r\n first,\r\n tryFirst,\r\n all\r\n}","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { showFsImage } from '../js/fs-img';\nimport { all } from './util';\r\n\n(() => {\n let canShowFullscreen = true;\n let imageDescriptionTimeout = 0;\n\n // gets all image elements inside a container\n const getImageElements = (container: Element) => {\n console.log(all('img', container));\n return all('img', container);\n }\n\n // take the last one and place it on the left\n const moveRight = (container: Element) => {\n const images = getImageElements(container);\n const parent = images[images.length - 1].parentElement;\n if (parent) {\n parent.insertBefore(images[images.length - 1], images[0]);\n }\n }\n\n // take the first one and place it on the right\n const moveLeft = (container: Element) => {\n const images = getImageElements(container);\n const parent = images[0].parentElement;\n if (parent) {\n parent.insertBefore(images[0], images[images.length - 1].nextSibling);\n }\n }\n\n // add 'fullscreen image' display on click\n const initPhotoboxImages = (container: Element) => {\n getImageElements(container).forEach(i => i.addEventListener('click', e => {\n if (e instanceof HTMLImageElement) {\n showFsImage(e);\n }\n }))\n }\n\n // init left/right arrows\n const initPhotoboxArrows = (container: Element) => {\n all('.left').forEach(l => {\n l.addEventListener('click', () => {\n clearTimeout(imageDescriptionTimeout);\n tempDisableFsImage();\n moveLeft(container);\n printImageDescription(container);\n });\n });\n all('.right').forEach(r => {\n r.addEventListener('click', () => {\n clearTimeout(imageDescriptionTimeout);\n tempDisableFsImage();\n moveRight(container);\n printImageDescription(container);\n });\n });\n }\n\n const getImageDescription = (container: Element) => {\n const images = getImageElements(container);\n if (images.length >= 2) {\n const activeImage = images[1];\n return activeImage.getAttribute('alt');\n }\n return '';\n }\n\n const printImageDescription = (container: Element) => {\n const description = getImageDescription(container) || '';\n const descriptionBox = container.nextElementSibling?.lastElementChild;\n\n if (descriptionBox) {\n recPrintDescription(descriptionBox, 0, description);\n }\n }\n\n const recPrintDescription = (descriptionBox: Element, index: number, description: string) => {\n if (description.length + 1 === index) {\n return;\n } else if (descriptionBox instanceof HTMLElement) {\n const characterToPrint = description.charAt(index - 1);\n const characterToPrintIsSpace = characterToPrint === ' ';\n\n if (characterToPrintIsSpace) {\n descriptionBox.innerText = description.substring(0, index + 1);\n imageDescriptionTimeout = window.setTimeout(() => recPrintDescription(descriptionBox, index + 2, description), 30)\n } else {\n descriptionBox.innerText = description.substring(0, index);\n imageDescriptionTimeout = window.setTimeout(() => recPrintDescription(descriptionBox, index + 1, description), 30);\n }\n }\n }\n\n // disables triggering of 'fullscreen image' while the image is moving\n const tempDisableFsImage = () => {\n canShowFullscreen = false;\n window.setTimeout(() => {\n canShowFullscreen = false;\n }, 600);\n }\n\n // initializes all photoboxes on the page\n all('.photobox').forEach(p => {\n initPhotoboxArrows(p);\n initPhotoboxImages(p);\n });\n})()"],"names":["showFsImage","img","url","srcset","split","map","s","replace","pop","src","fsImageContainers","all","length","newImg","document","createElement","className","fsImageContainer","appendChild","classList","add","forEach","i","addEventListener","lastElementChild","removeChild","remove","e","target","HTMLImageElement","first","selector","root","foundElement","querySelector","Error","tryFirst","console","warn","Array","from","querySelectorAll","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","exports","module","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","canShowFullscreen","imageDescriptionTimeout","getImageElements","container","log","initPhotoboxArrows","l","clearTimeout","tempDisableFsImage","images","parent","parentElement","insertBefore","nextSibling","moveLeft","printImageDescription","moveRight","description","getAttribute","getImageDescription","descriptionBox","_a","nextElementSibling","recPrintDescription","index","HTMLElement","charAt","innerText","substring","window","setTimeout","p"],"sourceRoot":""}