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,EAAMnE,QAAQsE,aAAe,yBAC7BH,EAAMW,QAAQ,IAIlBpH,IAAAA,aAA8BmH,IAG9B,IAIIE,EAJiBxH,EAAqBC,EAAM2G,GAKhD1F,OAAOuG,iBAAiB,UAAU,WAC9BC,KAAKC,aAAaH,GAClBA,EAAiBE,KAAKE,YAAW,KAC7BhB,EAAMW,SACNvH,EAAqBC,EAAM2G,EAAM,GAClC,IACP,IAGAlG,EAAsB,cAC1B,CACJ,G","sources":["webpack://app/./app/javascript/packs/photography.js"],"sourcesContent":["import 'photoswipe/dist/photoswipe.css'\nimport 'photoswipe/dist/default-skin/default-skin.css'\nimport PhotoSwipe from 'photoswipe';\nimport PhotoSwipeUI_Default from 'photoswipe/dist/photoswipe-ui-default';\nimport InfiniteScroll from 'infinite-scroll';\nimport Masonry from 'masonry-layout';\nimport imagesLoaded from 'imagesloaded';\nimport './photography.sass';\n\n// build and return a new Masonry object\nconst createMasonry = (elem) => {\n return new Masonry( elem, {\n // use outer width of grid-sizer for columnWidth\n // do not use .grid-sizer in layout!\n columnWidth: '.grid-sizer',\n itemSelector: '.grid-item',\n\n // responsive\n percentPosition: true,\n\n // nicer reveal transition\n visibleStyle: { transform: 'translateY(0)', opacity: 1 },\n hiddenStyle: { transform: 'translateY(100px)', opacity: 0 },\n });\n}\n\n// build and return a new InfiniteScroll object\nconst createInfiniteScroll = (elem, masonry) => {\n return new InfiniteScroll( elem, {\n // options\n checkLastPage: 'figure.image.grid-item',\n path: 'photography?page={{#}}',\n append: 'figure.image.grid-item',\n history: false,\n outlayer: masonry,\n status: '.page-load-status',\n });\n}\n\n// build the Photoswipe gallery from the provided CSS selector\nconst initPhotoSwipeFromDOM = function(gallerySelector) {\n\n // parse slide data (url, title, size ...) from DOM elements\n // (children of gallerySelector)\n var parseThumbnailElements = function(el) {\n var thumbElements = el.childNodes,\n numNodes = thumbElements.length,\n items = [],\n figureEl,\n linkEl,\n size,\n item;\n\n for(var i = 1; i < numNodes; i++) {\n\n figureEl = thumbElements[i]; //
element\n\n // include only element nodes\n if(figureEl.nodeType !== 1) {\n continue;\n }\n\n linkEl = figureEl.children[0]; // element\n size = linkEl.getAttribute('data-size').split('x');\n\n // create slide object\n item = {\n src: linkEl.getAttribute('href'),\n w: parseInt(size[0], 10),\n h: parseInt(size[1], 10)\n };\n\n\n\n if(figureEl.children.length > 1) {\n //
content\n item.title = figureEl.children[1].innerHTML;\n }\n\n if(linkEl.children.length > 0) {\n // thumbnail element, retrieving thumbnail url\n item.msrc = linkEl.children[0].getAttribute('src');\n }\n\n item.el = figureEl; // save link to element for getThumbBoundsFn\n items.push(item);\n }\n\n return items;\n };\n\n // find nearest parent element\n var closest = function closest(el, fn) {\n return el && ( fn(el) ? el : closest(el.parentNode, fn) );\n };\n\n // triggers when user clicks on thumbnail\n var onThumbnailsClick = function(e) {\n e = e || window.event;\n e.preventDefault ? e.preventDefault() : e.returnValue = false;\n\n var eTarget = e.target || e.srcElement;\n\n // find root element of slide\n var clickedListItem = closest(eTarget, function(el) {\n return (el.tagName && el.tagName.toUpperCase() === 'FIGURE');\n });\n\n if(!clickedListItem) {\n return;\n }\n\n // find index of clicked item by looping through all child nodes\n // alternatively, you may define index via data- attribute\n var clickedGallery = clickedListItem.parentNode,\n childNodes = clickedListItem.parentNode.childNodes,\n numChildNodes = childNodes.length,\n nodeIndex = 0,\n index;\n\n for (var i = 1; i < numChildNodes; i++) {\n if(childNodes[i].nodeType !== 1) {\n continue;\n }\n\n if(childNodes[i] === clickedListItem) {\n index = nodeIndex;\n break;\n }\n nodeIndex++;\n }\n\n\n\n if(index >= 0) {\n // open PhotoSwipe if valid index found\n openPhotoSwipe( index, clickedGallery );\n }\n return false;\n };\n\n // parse picture index and gallery index from URL (#&pid=1&gid=2)\n var photoswipeParseHash = function() {\n var hash = window.location.hash.substring(1),\n params = {};\n\n if(hash.length < 5) {\n return params;\n }\n\n var vars = hash.split('&');\n for (var i = 0; i < vars.length; i++) {\n if(!vars[i]) {\n continue;\n }\n var pair = vars[i].split('=');\n if(pair.length < 2) {\n continue;\n }\n params[pair[0]] = pair[1];\n }\n\n if(params.gid) {\n params.gid = parseInt(params.gid, 10);\n }\n\n return params;\n };\n\n var openPhotoSwipe = function(index, galleryElement, disableAnimation, fromURL) {\n var pswpElement = document.querySelectorAll('.pswp')[0],\n gallery,\n options,\n items;\n\n items = parseThumbnailElements(galleryElement);\n\n // define options (if needed)\n options = {\n\n // define gallery index (for URL)\n galleryUID: galleryElement.getAttribute('data-pswp-uid'),\n\n getThumbBoundsFn: function(index) {\n // See Options -> getThumbBoundsFn section of documentation for more info\n var thumbnail = items[index].el.getElementsByTagName('img')[0], // find thumbnail\n pageYScroll = window.pageYOffset || document.documentElement.scrollTop,\n rect = thumbnail.getBoundingClientRect();\n\n return {x:rect.left, y:rect.top + pageYScroll, w:rect.width};\n }\n\n };\n\n // PhotoSwipe opened from URL\n if(fromURL) {\n if(options.galleryPIDs) {\n // parse real index when custom PIDs are used\n // http://photoswipe.com/documentation/faq.html#custom-pid-in-url\n for(var j = 0; j < items.length; j++) {\n if(items[j].pid == index) {\n options.index = j;\n break;\n }\n }\n } else {\n // in URL indexes start from 1\n options.index = parseInt(index, 10) - 1;\n }\n } else {\n options.index = parseInt(index, 10);\n }\n\n // exit if index not found\n if( isNaN(options.index) ) {\n return;\n }\n\n if(disableAnimation) {\n options.showAnimationDuration = 0;\n }\n\n // backing out of the photoswipe full screen causes page reload (turbolinks)\n // disable back button support until this is fixed:\n // https://github.com/dimsemenov/PhotoSwipe/issues/700\n options.history = false;\n\n // Pass data to PhotoSwipe and initialize it\n gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);\n gallery.init();\n\n // event handlers to animate the navigation div on open/close of photoswipe gallery\n gallery.listen('initialZoomIn', function() {\n let navElement = document.querySelector(\".desktop-nav\");\n navElement.classList.add(\"animate-hideTop\")\n navElement.classList.remove(\"animate-showTop\")\n });\n gallery.listen('close', function() {\n let navElement = document.querySelector(\".desktop-nav\");\n navElement.classList.remove(\"animate-hideTop\")\n navElement.classList.add(\"animate-showTop\")\n });\n };\n\n // loop through all gallery elements and bind events\n var galleryElements = document.querySelectorAll( gallerySelector );\n\n for(var i = 0, l = galleryElements.length; i < l; i++) {\n galleryElements[i].setAttribute('data-pswp-uid', i+1);\n galleryElements[i].onclick = onThumbnailsClick;\n }\n\n // Parse URL and open gallery if it contains #&pid=3&gid=1\n var hashData = photoswipeParseHash();\n if(hashData.pid && hashData.gid) {\n openPhotoSwipe( hashData.pid , galleryElements[ hashData.gid - 1 ], true, true );\n }\n};\n\n// logic to fire on (turbolinks) page load\n$(document).on('turbo:load', function() {\n const elem = document.querySelector('.my-gallery.grid');\n if (elem) {\n let msnry = createMasonry(elem)\n\n // Unloaded images can throw off Masonry layouts and cause item elements to overlap.\n // imagesLoaded resolves this issue.\n // note: this seems to work and only is important for first page load\n imagesLoaded( elem, () => {\n elem.classList.remove('are-images-unloaded');\n msnry.options.itemSelector = 'figure.image.grid-item';\n msnry.layout()\n });\n\n // make imagesLoaded available for InfiniteScroll\n InfiniteScroll.imagesLoaded = imagesLoaded;\n\n // instantiate infinite scroll with the gallery and masonry\n let infiniteScroll = createInfiniteScroll(elem, msnry);\n\n // 250ms after a resize finishes, re-run masonry.layout(),\n // and rebuild a new infinite scroll with the new masonry layout\n let resizeComplete;\n window.addEventListener('resize', function () {\n this.clearTimeout(resizeComplete);\n resizeComplete = this.setTimeout(() => {\n msnry.layout();\n createInfiniteScroll(elem, msnry);\n }, 250);\n });\n\n // start up Photoswipe\n initPhotoSwipeFromDOM('.my-gallery');\n }\n});\n"],"names":["createInfiniteScroll","elem","masonry","InfiniteScroll","checkLastPage","path","append","history","outlayer","status","initPhotoSwipeFromDOM","gallerySelector","closest","el","fn","parentNode","onThumbnailsClick","e","window","event","preventDefault","returnValue","eTarget","target","srcElement","clickedListItem","tagName","toUpperCase","index","clickedGallery","childNodes","numChildNodes","length","nodeIndex","i","nodeType","openPhotoSwipe","galleryElement","disableAnimation","fromURL","gallery","options","items","pswpElement","document","querySelectorAll","figureEl","linkEl","size","item","thumbElements","numNodes","children","getAttribute","split","src","w","parseInt","h","title","innerHTML","msrc","push","parseThumbnailElements","galleryUID","getThumbBoundsFn","thumbnail","getElementsByTagName","pageYScroll","pageYOffset","documentElement","scrollTop","rect","getBoundingClientRect","x","left","y","top","width","galleryPIDs","j","pid","isNaN","showAnimationDuration","PhotoSwipe","PhotoSwipeUI_Default","init","listen","navElement","querySelector","classList","add","remove","galleryElements","l","setAttribute","onclick","hashData","hash","location","substring","params","vars","pair","gid","photoswipeParseHash","$","on","msnry","Masonry","columnWidth","itemSelector","percentPosition","visibleStyle","transform","opacity","hiddenStyle","createMasonry","imagesLoaded","layout","resizeComplete","addEventListener","this","clearTimeout","setTimeout"],"sourceRoot":""}