Formatting

This commit is contained in:
Ryan Prather 2024-05-15 22:40:13 -04:00
parent 090fd864b4
commit 98cb84acba

View File

@ -1,262 +1,262 @@
/* /*
Editorial by HTML5 UP Editorial by HTML5 UP
html5up.net | @ajlkn html5up.net | @ajlkn
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
*/ */
(function($) { (function ($) {
var $window = $(window), var $window = $(window),
$head = $('head'), $head = $('head'),
$body = $('body'); $body = $('body');
// Breakpoints. // Breakpoints.
breakpoints({ breakpoints({
xlarge: [ '1281px', '1680px' ], xlarge: ['1281px', '1680px'],
large: [ '981px', '1280px' ], large: ['981px', '1280px'],
medium: [ '737px', '980px' ], medium: ['737px', '980px'],
small: [ '481px', '736px' ], small: ['481px', '736px'],
xsmall: [ '361px', '480px' ], xsmall: ['361px', '480px'],
xxsmall: [ null, '360px' ], xxsmall: [null, '360px'],
'xlarge-to-max': '(min-width: 1681px)', 'xlarge-to-max': '(min-width: 1681px)',
'small-to-xlarge': '(min-width: 481px) and (max-width: 1680px)' 'small-to-xlarge': '(min-width: 481px) and (max-width: 1680px)'
}); });
// Stops animations/transitions until the page has ... // Stops animations/transitions until the page has ...
// ... loaded. // ... loaded.
$window.on('load', function() { $window.on('load', function () {
window.setTimeout(function() { window.setTimeout(function () {
$body.removeClass('is-preload'); $body.removeClass('is-preload');
}, 100); }, 100);
}); });
// ... stopped resizing. // ... stopped resizing.
var resizeTimeout; var resizeTimeout;
$window.on('resize', function() { $window.on('resize', function () {
// Mark as resizing. // Mark as resizing.
$body.addClass('is-resizing'); $body.addClass('is-resizing');
// Unmark after delay. // Unmark after delay.
clearTimeout(resizeTimeout); clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() { resizeTimeout = setTimeout(function () {
$body.removeClass('is-resizing'); $body.removeClass('is-resizing');
}, 100); }, 100);
}); });
// Fixes. // Fixes.
// Object fit images. // Object fit images.
if (!browser.canUse('object-fit') if (!browser.canUse('object-fit')
|| browser.name == 'safari') || browser.name == 'safari')
$('.image.object').each(function() { $('.image.object').each(function () {
var $this = $(this), var $this = $(this),
$img = $this.children('img'); $img = $this.children('img');
// Hide original image. // Hide original image.
$img.css('opacity', '0'); $img.css('opacity', '0');
// Set background. // Set background.
$this $this
.css('background-image', 'url("' + $img.attr('src') + '")') .css('background-image', 'url("' + $img.attr('src') + '")')
.css('background-size', $img.css('object-fit') ? $img.css('object-fit') : 'cover') .css('background-size', $img.css('object-fit') ? $img.css('object-fit') : 'cover')
.css('background-position', $img.css('object-position') ? $img.css('object-position') : 'center'); .css('background-position', $img.css('object-position') ? $img.css('object-position') : 'center');
}); });
// Sidebar. // Sidebar.
var $sidebar = $('#sidebar'), var $sidebar = $('#sidebar'),
$sidebar_inner = $sidebar.children('.inner'); $sidebar_inner = $sidebar.children('.inner');
// Inactive by default on <= large. // Inactive by default on <= large.
breakpoints.on('<=large', function() { breakpoints.on('<=large', function () {
$sidebar.addClass('inactive'); $sidebar.addClass('inactive');
}); });
breakpoints.on('>large', function() { breakpoints.on('>large', function () {
$sidebar.removeClass('inactive'); $sidebar.removeClass('inactive');
}); });
// Hack: Workaround for Chrome/Android scrollbar position bug. // Hack: Workaround for Chrome/Android scrollbar position bug.
if (browser.os == 'android' if (browser.os == 'android'
&& browser.name == 'chrome') && browser.name == 'chrome')
$('<style>#sidebar .inner::-webkit-scrollbar { display: none; }</style>') $('<style>#sidebar .inner::-webkit-scrollbar { display: none; }</style>')
.appendTo($head); .appendTo($head);
// Toggle. // Toggle.
$('<a href="#sidebar" class="toggle">Toggle</a>') $('<a href="#sidebar" class="toggle">Toggle</a>')
.appendTo($sidebar) .appendTo($sidebar)
.on('click', function(event) { .on('click', function (event) {
// Prevent default. // Prevent default.
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
// Toggle. // Toggle.
$sidebar.toggleClass('inactive'); $sidebar.toggleClass('inactive');
}); });
// Events. // Events.
// Link clicks. // Link clicks.
$sidebar.on('click', 'a', function(event) { $sidebar.on('click', 'a', function (event) {
// >large? Bail. // >large? Bail.
if (breakpoints.active('>large')) if (breakpoints.active('>large'))
return; return;
// Vars. // Vars.
var $a = $(this), var $a = $(this),
href = $a.attr('href'), href = $a.attr('href'),
target = $a.attr('target'); target = $a.attr('target');
// Prevent default. // Prevent default.
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
// Check URL. // Check URL.
if (!href || href == '#' || href == '') if (!href || href == '#' || href == '')
return; return;
// Hide sidebar. // Hide sidebar.
$sidebar.addClass('inactive'); $sidebar.addClass('inactive');
// Redirect to href. // Redirect to href.
setTimeout(function() { setTimeout(function () {
if (target == '_blank') if (target == '_blank')
window.open(href); window.open(href);
else else
window.location.href = href; window.location.href = href;
}, 500); }, 500);
}); });
// Prevent certain events inside the panel from bubbling. // Prevent certain events inside the panel from bubbling.
$sidebar.on('click touchend touchstart touchmove', function(event) { $sidebar.on('click touchend touchstart touchmove', function (event) {
// >large? Bail. // >large? Bail.
if (breakpoints.active('>large')) if (breakpoints.active('>large'))
return; return;
// Prevent propagation. // Prevent propagation.
event.stopPropagation(); event.stopPropagation();
}); });
// Hide panel on body click/tap. // Hide panel on body click/tap.
$body.on('click touchend', function(event) { $body.on('click touchend', function (event) {
// >large? Bail. // >large? Bail.
if (breakpoints.active('>large')) if (breakpoints.active('>large'))
return; return;
// Deactivate. // Deactivate.
$sidebar.addClass('inactive'); $sidebar.addClass('inactive');
}); });
// Scroll lock. // Scroll lock.
// Note: If you do anything to change the height of the sidebar's content, be sure to // Note: If you do anything to change the height of the sidebar's content, be sure to
// trigger 'resize.sidebar-lock' on $window so stuff doesn't get out of sync. // trigger 'resize.sidebar-lock' on $window so stuff doesn't get out of sync.
$window.on('load.sidebar-lock', function() { $window.on('load.sidebar-lock', function () {
var sh, wh, st; var sh, wh, st;
// Reset scroll position to 0 if it's 1. // Reset scroll position to 0 if it's 1.
if ($window.scrollTop() == 1) if ($window.scrollTop() == 1)
$window.scrollTop(0); $window.scrollTop(0);
$window $window
.on('scroll.sidebar-lock', function() { .on('scroll.sidebar-lock', function () {
var x, y; var x, y;
// <=large? Bail. // <=large? Bail.
if (breakpoints.active('<=large')) { if (breakpoints.active('<=large')) {
$sidebar_inner $sidebar_inner
.data('locked', 0) .data('locked', 0)
.css('position', '') .css('position', '')
.css('top', ''); .css('top', '');
return; return;
} }
// Calculate positions. // Calculate positions.
x = Math.max(sh - wh, 0); x = Math.max(sh - wh, 0);
y = Math.max(0, $window.scrollTop() - x); y = Math.max(0, $window.scrollTop() - x);
// Lock/unlock. // Lock/unlock.
if ($sidebar_inner.data('locked') == 1) { if ($sidebar_inner.data('locked') == 1) {
if (y <= 0) if (y <= 0)
$sidebar_inner $sidebar_inner
.data('locked', 0) .data('locked', 0)
.css('position', '') .css('position', '')
.css('top', ''); .css('top', '');
else else
$sidebar_inner $sidebar_inner
.css('top', -1 * x); .css('top', -1 * x);
} }
else { else {
if (y > 0) if (y > 0)
$sidebar_inner $sidebar_inner
.data('locked', 1) .data('locked', 1)
.css('position', 'fixed') .css('position', 'fixed')
.css('top', -1 * x); .css('top', -1 * x);
} }
}) })
.on('resize.sidebar-lock', function() { .on('resize.sidebar-lock', function () {
// Calculate heights. // Calculate heights.
wh = $window.height(); wh = $window.height();
sh = $sidebar_inner.outerHeight() + 30; sh = $sidebar_inner.outerHeight() + 30;
// Trigger scroll. // Trigger scroll.
$window.trigger('scroll.sidebar-lock'); $window.trigger('scroll.sidebar-lock');
}) })
.trigger('resize.sidebar-lock'); .trigger('resize.sidebar-lock');
}); });
// Menu. // Menu.
var $menu = $('#menu'), var $menu = $('#menu'),
$menu_openers = $menu.children('ul').find('.opener'); $menu_openers = $menu.children('ul').find('.opener');
// Openers. // Openers.
$menu_openers.each(function() { $menu_openers.each(function () {
var $this = $(this); var $this = $(this);
$this.on('click', function(event) { $this.on('click', function (event) {
// Prevent default. // Prevent default.
event.preventDefault(); event.preventDefault();
// Toggle. // Toggle.
$menu_openers.not($this).removeClass('active'); $menu_openers.not($this).removeClass('active');
$this.toggleClass('active'); $this.toggleClass('active');
// Trigger resize (sidebar lock). // Trigger resize (sidebar lock).
$window.triggerHandler('resize.sidebar-lock'); $window.triggerHandler('resize.sidebar-lock');
}); });
}); });
})(jQuery); })(jQuery);