upgrade to bootstrap 4, complete rewrite of template (#629)

This commit is contained in:
Dean Attali 2020-05-02 02:10:20 -04:00 committed by GitHub
parent 67bd8058c7
commit 54ca402373
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 642 additions and 10358 deletions

2306
assets/js/bootstrap.js vendored

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
// Dean Attali / Beautiful Jekyll 2016
// Dean Attali / Beautiful Jekyll 2020
var main = {
var BeautifulJekyllJS = {
bigImgEl : null,
numImgs : null,
@ -10,10 +10,8 @@ var main = {
$(window).scroll(function() {
if ($(".navbar").offset().top > 50) {
$(".navbar").addClass("top-nav-short");
$(".navbar-custom .avatar-container").fadeOut(500);
} else {
$(".navbar").removeClass("top-nav-short");
$(".navbar-custom .avatar-container").fadeIn(500);
}
});
@ -25,116 +23,77 @@ var main = {
$(".navbar").removeClass("top-nav-expanded");
});
// On mobile, when clicking on a multi-level navbar menu, show the child links
$('#main-navbar').on("click", ".navlinks-parent", function(e) {
var target = e.target;
$.each($(".navlinks-parent"), function(key, value) {
if (value == target) {
$(value).parent().toggleClass("show-children");
} else {
$(value).parent().removeClass("show-children");
}
});
});
// Ensure nested navbar menus are not longer than the menu header
var menus = $(".navlinks-container");
if (menus.length > 0) {
var navbar = $("#main-navbar ul");
var fakeMenuHtml = "<li class='fake-menu' style='display:none;'><a></a></li>";
navbar.append(fakeMenuHtml);
var fakeMenu = $(".fake-menu");
$.each(menus, function(i) {
var parent = $(menus[i]).find(".navlinks-parent");
var children = $(menus[i]).find(".navlinks-children a");
var words = [];
$.each(children, function(idx, el) { words = words.concat($(el).text().trim().split(/\s+/)); });
var maxwidth = 0;
$.each(words, function(id, word) {
fakeMenu.html("<a>" + word + "</a>");
var width = fakeMenu.width();
if (width > maxwidth) {
maxwidth = width;
}
});
$(menus[i]).css('min-width', maxwidth + 'px')
});
fakeMenu.remove();
}
// show the big header image
main.initImgs();
BeautifulJekyllJS.initImgs();
},
initImgs : function() {
// If the page was large images to randomly select from, choose an image
if ($("#header-big-imgs").length > 0) {
main.bigImgEl = $("#header-big-imgs");
main.numImgs = main.bigImgEl.attr("data-num-img");
BeautifulJekyllJS.bigImgEl = $("#header-big-imgs");
BeautifulJekyllJS.numImgs = BeautifulJekyllJS.bigImgEl.attr("data-num-img");
// 2fc73a3a967e97599c9763d05e564189
// set an initial image
var imgInfo = main.getImgInfo();
var src = imgInfo.src;
var desc = imgInfo.desc;
main.setImg(src, desc);
// 2fc73a3a967e97599c9763d05e564189
// set an initial image
var imgInfo = BeautifulJekyllJS.getImgInfo();
var src = imgInfo.src;
var desc = imgInfo.desc;
BeautifulJekyllJS.setImg(src, desc);
// For better UX, prefetch the next image so that it will already be loaded when we want to show it
var getNextImg = function() {
var imgInfo = main.getImgInfo();
var src = imgInfo.src;
var desc = imgInfo.desc;
// For better UX, prefetch the next image so that it will already be loaded when we want to show it
var getNextImg = function() {
var imgInfo = BeautifulJekyllJS.getImgInfo();
var src = imgInfo.src;
var desc = imgInfo.desc;
var prefetchImg = new Image();
prefetchImg.src = src;
// if I want to do something once the image is ready: `prefetchImg.onload = function(){}`
var prefetchImg = new Image();
prefetchImg.src = src;
// if I want to do something once the image is ready: `prefetchImg.onload = function(){}`
setTimeout(function(){
var img = $("<div></div>").addClass("big-img-transition").css("background-image", 'url(' + src + ')');
$(".intro-header.big-img").prepend(img);
setTimeout(function(){ img.css("opacity", "1"); }, 50);
setTimeout(function(){
var img = $("<div></div>").addClass("big-img-transition").css("background-image", 'url(' + src + ')');
$(".intro-header.big-img").prepend(img);
setTimeout(function(){ img.css("opacity", "1"); }, 50);
// after the animation of fading in the new image is done, prefetch the next one
//img.one("transitioned webkitTransitionEnd oTransitionEnd MSTransitionEnd", function(){
setTimeout(function() {
main.setImg(src, desc);
img.remove();
getNextImg();
}, 1000);
//});
}, 6000);
};
// after the animation of fading in the new image is done, prefetch the next one
//img.one("transitioned webkitTransitionEnd oTransitionEnd MSTransitionEnd", function(){
setTimeout(function() {
BeautifulJekyllJS.setImg(src, desc);
img.remove();
getNextImg();
}, 1000);
//});
}, 6000);
};
// If there are multiple images, cycle through them
if (main.numImgs > 1) {
getNextImg();
}
// If there are multiple images, cycle through them
if (BeautifulJekyllJS.numImgs > 1) {
getNextImg();
}
}
},
getImgInfo : function() {
var randNum = Math.floor((Math.random() * main.numImgs) + 1);
var src = main.bigImgEl.attr("data-img-src-" + randNum);
var desc = main.bigImgEl.attr("data-img-desc-" + randNum);
var randNum = Math.floor((Math.random() * BeautifulJekyllJS.numImgs) + 1);
var src = BeautifulJekyllJS.bigImgEl.attr("data-img-src-" + randNum);
var desc = BeautifulJekyllJS.bigImgEl.attr("data-img-desc-" + randNum);
return {
src : src,
desc : desc
}
return {
src : src,
desc : desc
}
},
setImg : function(src, desc) {
$(".intro-header.big-img").css("background-image", 'url(' + src + ')');
if (typeof desc !== typeof undefined && desc !== false) {
$(".img-desc").text(desc).show();
} else {
$(".img-desc").hide();
}
$(".intro-header.big-img").css("background-image", 'url(' + src + ')');
if (typeof desc !== typeof undefined && desc !== false) {
$(".img-desc").text(desc).show();
} else {
$(".img-desc").hide();
}
}
};
// 2fc73a3a967e97599c9763d05e564189
document.addEventListener('DOMContentLoaded', main.init);
document.addEventListener('DOMContentLoaded', BeautifulJekyllJS.init);