77 lines
2.4 KiB
JavaScript
Executable File
77 lines
2.4 KiB
JavaScript
Executable File
/****************************************************************************
|
|
* WonderDome.net
|
|
*
|
|
* Copyright 2018 Eric Woodward
|
|
* https://git.itsericwoodward.com/eric/wonderdome-site/
|
|
*
|
|
* Source released under CC0 Public Domain License v1.0
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
****************************************************************************/
|
|
;
|
|
|
|
(function(){
|
|
'use strict';
|
|
|
|
if (document.documentElement.className && document.documentElement.className.indexOf('lt-ie8') == -1) {
|
|
var
|
|
protocol = window.location.protocol;
|
|
|
|
// Indicate JS is loaded
|
|
document.documentElement.className = document.documentElement.className.replace('no-js', 'js');
|
|
|
|
// Enable cached fonts ASAP
|
|
if (typeof Cookies !== 'undefined' && Cookies.get('fonts_loaded') === 'false' ? false : !!Cookies.get('fonts_loaded')) {
|
|
document.documentElement.className += " js-hasFontsLoaded";
|
|
}
|
|
|
|
docReady(function() {
|
|
setTimeout(function() {
|
|
// Handle Fonts
|
|
if (typeof Cookies !== 'undefined') {
|
|
if (typeof FontFaceObserver !== 'undefined') {
|
|
var
|
|
font = new FontFaceObserver('raleway');
|
|
font
|
|
.load()
|
|
.then(function () {
|
|
if (document.documentElement.className.indexOf("js-hasFontsLoaded") == -1) {
|
|
document.documentElement.className += " js-hasFontsLoaded";
|
|
}
|
|
Cookies.set('fonts_loaded', true);
|
|
});
|
|
}
|
|
}
|
|
|
|
// Lazy-Load Media
|
|
if (typeof loadMedia === 'function') {
|
|
loadMedia('.js-lazyLoader', null, true);
|
|
}
|
|
if (
|
|
document.documentElement.className.indexOf('is404') > -1 &&
|
|
document.getElementById("searchQuery")
|
|
) {
|
|
document
|
|
.getElementById("searchQuery")
|
|
.value =
|
|
window
|
|
.location
|
|
.pathname
|
|
.replace(/\\.html?$/, "")
|
|
.replace(/\//g, " ");
|
|
}
|
|
if (document.getElementById("searchForm")) {
|
|
document
|
|
.getElementById("searchForm")
|
|
.addEventListener ("submit",
|
|
function(e) {
|
|
document
|
|
.getElementById("searchQuery")
|
|
.value += " site:" + window.location.hostname;
|
|
}
|
|
);
|
|
}
|
|
}, 1);
|
|
});
|
|
}
|
|
})();
|