<script src="{{assets}}/js/masonry.min.js"></script>
<script src="{{assets}}/js/imagesloaded.min.js"></script>
<script>
  // Initialize the grid on the images gallery.
  document.addEventListener('DOMContentLoaded', function onContentLoaded() {
    var images = document.querySelector('#gallery')

    imagesLoaded(images, function onImagesLoaded() {
      new Masonry(images, {
        itemSelector: '.gallery__item'
      })
    })
  })
</script>

{{#if hamburger}}
<script src="{{assets}}/js/hamburger.js"></script>
{{/if}}

{{#if analytics}}
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', '{{analytics}}', 'auto');
  ga('send', 'pageview');
</script>
{{/if}}

<script src="{{assets}}/js/masonry.min.js"></script>
<script src="{{assets}}/js/imagesloaded.min.js"></script>
<script>
  // Add masonry layout on the galleries.
  document.addEventListener('DOMContentLoaded', function onContentLoaded() {
    var galleries = document.querySelectorAll('.gallery');

    for (var i = 0; i < galleries.length; i++) {
      (function (index) {
        var gallery = galleries[index];

        imagesLoaded(gallery, function onImagesLoaded() {
          new Masonry(gallery, {
            itemSelector: '.gallery__item'
          });
        });
      })(i);
    }
  })
</script>

{{#if hamburger}}
<script src="{{assets}}/js/hamburger.js"></script>
{{/if}}

{{#if analytics}}
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', '{{analytics}}', 'auto');
  ga('send', 'pageview');
</script>
{{/if}}

Allow masonry on multiple galleries
Allow masonry on multiple galleries
