1
Fork 0

Move more things into the ready event handler

This commit is contained in:
Jake Howard 2019-10-29 19:34:07 +00:00
parent 92810bc12b
commit 5a0ee4f08e
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -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();
});