diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2016-08-27 12:08:53 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2016-08-27 12:08:53 +0200 |
| commit | 66725af0f80fd8fbff29d553c6f20054409ab0c0 (patch) | |
| tree | c030a32eba6bb1644891a475b58e2fc2d2d420ab /themes | |
| parent | c5beb49fd23bd9d8feb75bfda682ed60c0521abb (diff) | |
| download | pragblog-66725af0f80fd8fbff29d553c6f20054409ab0c0.tar.gz pragblog-66725af0f80fd8fbff29d553c6f20054409ab0c0.zip | |
fix js library loading
Diffstat (limited to 'themes')
| -rw-r--r-- | themes/flog/layouts/partials/footer.html | 13 | ||||
| -rw-r--r-- | themes/flog/layouts/partials/listing.html | 26 |
2 files changed, 34 insertions, 5 deletions
diff --git a/themes/flog/layouts/partials/footer.html b/themes/flog/layouts/partials/footer.html index a617ce6..937ff18 100644 --- a/themes/flog/layouts/partials/footer.html +++ b/themes/flog/layouts/partials/footer.html @@ -9,15 +9,22 @@ var coords = '50% ' + yPos + 'px'; $('body').css({ backgroundPosition: coords }); }; - function ready() { + + document.addEventListener('pageReady', function() { parallax(); $('.button-collapse').sideNav(); $('.button-collapse').sideNav('hide'); - }; + }); + + function ready() { + document.dispatchEvent(new CustomEvent('pageReady')); + } + $(document).ready(function() { + parallax(); $(window).scroll(parallax); + $('.button-collapse').sideNav(); $('#main').smoothState({ prefetch: true, onAfter: ready }); - ready(); }); </script> </body> diff --git a/themes/flog/layouts/partials/listing.html b/themes/flog/layouts/partials/listing.html index 31e5614..93fe09d 100644 --- a/themes/flog/layouts/partials/listing.html +++ b/themes/flog/layouts/partials/listing.html @@ -28,7 +28,29 @@ {{ end }} </div> </main> -<script type="text/javascript" src="/js/masonry-4.1.min.js"></script> <script type="text/javascript"> - new Masonry('.grid', { itemSelector: '.grid-item', percentPosition: true, columnWidth: '.grid-sizer' }); + var masonryReadyAttached; + + if (typeof $ === 'undefined') { + document.addEventListener('DOMContentLoaded', loadMasonry); + } + if (typeof masonryReadyAttached === 'undefined') { + masonryReadyAttached = true; + document.addEventListener('pageReady', loadMasonry); + } + + function loadMasonry() { + if (typeof Masonry === 'undefined') { + console.log('loading masonry files'); + $.getScript('/js/masonry-4.1.min.js', showMasonry); + } else { + console.log('masonry files already present'); + showMasonry(); + } + } + function showMasonry() { + if ($('.grid').length == 0) return; + console.log('using masonry to fix this grid'); + new Masonry('.grid', { itemSelector: '.grid-item', percentPosition: true, columnWidth: '.grid-sizer' }); + } </script> |
