From 5a0ee4f08edeb20c7fe0b71213c117cc047e1e5c Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 29 Oct 2019 19:34:07 +0000 Subject: [PATCH] Move more things into the ready event handler --- static/src/js/index.js | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/static/src/js/index.js b/static/src/js/index.js index bce0b70..d5e6a9c 100644 --- a/static/src/js/index.js +++ b/static/src/js/index.js @@ -3,7 +3,7 @@ var Clipboard = require('clipboard'); function waitFor(obj, property, callback) { - // Wait for a property to exist on window before runnig callback + // Wait for a property to exist on window before running callback var intervalId = setInterval(function() { if (obj.hasOwnProperty(property)) { clearInterval(intervalId); @@ -12,16 +12,6 @@ function waitFor(obj, property, callback) { }, 500); } -$('.image').each(function() { - // setup div-image hybrids - var ele = $(this); - if (ele.data('image')) { - ele.css('background-image', 'url(' + ele.data('image') + ')'); - } else { - ele.removeClass('image'); - } -}); - $(document).ready(function() { waitFor($.fn, 'lightGallery', function() { $('#light-gallery').lightGallery({ @@ -33,6 +23,12 @@ $(document).ready(function() { }); }); + new Clipboard('a').on('success', function(e) { + var ele = $(e.trigger); + ele.find('i').attr('class', 'fas fa-check'); + alert('Copied "' + ele.data('clipboard-text') + '" to clipboard!'); + }); + // HACK: ToC has blank li if no initial header $('#TableOfContents').each(function() { var ele = $(this); @@ -47,6 +43,16 @@ $(document).ready(function() { ); } }); + + $('.image').each(function() { + // setup div-image hybrids + var ele = $(this); + if (ele.data('image')) { + ele.css('background-image', 'url(' + ele.data('image') + ')'); + } else { + ele.removeClass('image'); + } + }); }); $('.navbar-brand').on('click', function(event) { @@ -65,13 +71,6 @@ $('.navbar-brand').on('click', function(event) { event.preventDefault(); }); -var clipboard = new Clipboard('a'); -clipboard.on('success', function(e) { - var ele = $(e.trigger); - ele.find('i').attr('class', 'fas fa-check'); - alert('Copied "' + ele.data('clipboard-text') + '" to clipboard!'); -}); - $('[data-clipboard-text]').on('click', function(event) { event.preventDefault(); });