From 80799be7d37a248b5c359cc6e8d313ce5a15004a Mon Sep 17 00:00:00 2001 From: Daniel Austin <121881138+IMDANIELAUSTIN@users.noreply.github.com> Date: Tue, 23 Jul 2024 08:33:09 -0700 Subject: [PATCH] Update main.js --- assets/js/main.js | 273 +++++++++++++++++++++------------------------- 1 file changed, 122 insertions(+), 151 deletions(-) diff --git a/assets/js/main.js b/assets/js/main.js index 176ab9b..b4ba91e 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,189 +1,160 @@ -/* - Phantom by HTML5 UP - html5up.net | @ajlkn - Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) -*/ - (function($) { var $window = $(window), $body = $('body'); // Breakpoints. - breakpoints({ - xlarge: [ '1281px', '1680px' ], - large: [ '981px', '1280px' ], - medium: [ '737px', '980px' ], - small: [ '481px', '736px' ], - xsmall: [ '361px', '480px' ], - xxsmall: [ null, '360px' ] - }); + breakpoints({ + xlarge: [ '1281px', '1680px' ], + large: [ '981px', '1280px' ], + medium: [ '737px', '980px' ], + small: [ '481px', '736px' ], + xsmall: [ '361px', '480px' ], + xxsmall: [ null, '360px' ] + }); // Play initial animations on page load. - $window.on('load', function() { - window.setTimeout(function() { - $body.removeClass('is-preload'); - }, 100); - }); + $window.on('load', function() { + window.setTimeout(function() { + $body.removeClass('is-preload'); + }, 100); + }); // Touch? - if (browser.mobile) - $body.addClass('is-touch'); + if (browser.mobile) + $body.addClass('is-touch'); // Forms. - var $form = $('form'); - - // Auto-resizing textareas. - $form.find('textarea').each(function() { - - var $this = $(this), - $wrapper = $('
'), - $submits = $this.find('input[type="submit"]'); + var $form = $('form'); - $this - .wrap($wrapper) - .attr('rows', 1) - .css('overflow', 'hidden') - .css('resize', 'none') - .on('keydown', function(event) { + // Auto-resizing textareas. + $form.find('textarea').each(function() { - if (event.keyCode == 13 - && event.ctrlKey) { + var $this = $(this), + $wrapper = $('
'), + $submits = $this.find('input[type="submit"]'); - event.preventDefault(); - event.stopPropagation(); + $this + .wrap($wrapper) + .attr('rows', 1) + .css('overflow', 'hidden') + .css('resize', 'none') + .on('keydown', function(event) { + if (event.keyCode == 13 && event.ctrlKey) { + event.preventDefault(); + event.stopPropagation(); + $(this).blur(); + } + }) + .on('blur focus', function() { + $this.val($.trim($this.val())); + }) + .on('input blur focus --init', function() { + $wrapper.css('height', $this.height()); + $this.css('height', 'auto').css('height', $this.prop('scrollHeight') + 'px'); + }) + .on('keyup', function(event) { + if (event.keyCode == 9) + $this.select(); + }) + .triggerHandler('--init'); - $(this).blur(); + // Fix. + if (browser.name == 'ie' || browser.mobile) + $this.css('max-height', '10em').css('overflow-y', 'auto'); + }); - } + // Menu. + var $menu = $('#menu'); - }) - .on('blur focus', function() { - $this.val($.trim($this.val())); - }) - .on('input blur focus --init', function() { + $menu.wrapInner('
'); - $wrapper - .css('height', $this.height()); + $menu._locked = false; - $this - .css('height', 'auto') - .css('height', $this.prop('scrollHeight') + 'px'); + $menu._lock = function() { + if ($menu._locked) + return false; - }) - .on('keyup', function(event) { + $menu._locked = true; - if (event.keyCode == 9) - $this - .select(); + window.setTimeout(function() { + $menu._locked = false; + }, 350); - }) - .triggerHandler('--init'); + return true; + }; - // Fix. - if (browser.name == 'ie' - || browser.mobile) - $this - .css('max-height', '10em') - .css('overflow-y', 'auto'); + $menu._show = function() { + if ($menu._lock()) + $body.addClass('is-menu-visible'); + }; - }); + $menu._hide = function() { + if ($menu._lock()) + $body.removeClass('is-menu-visible'); + }; - // Menu. - var $menu = $('#menu'); + $menu._toggle = function() { + if ($menu._lock()) + $body.toggleClass('is-menu-visible'); + }; - $menu.wrapInner('
'); + $menu + .appendTo($body) + .on('click', function(event) { + event.stopPropagation(); + }) + .on('click', 'a', function(event) { - $menu._locked = false; + var href = $(this).attr('href'); - $menu._lock = function() { + event.preventDefault(); + event.stopPropagation(); - if ($menu._locked) - return false; + // Hide. + $menu._hide(); - $menu._locked = true; + // Redirect. + if (href == '#menu') + return; window.setTimeout(function() { - $menu._locked = false; + window.location.href = href; }, 350); - return true; - - }; - - $menu._show = function() { - - if ($menu._lock()) - $body.addClass('is-menu-visible'); - - }; - - $menu._hide = function() { - - if ($menu._lock()) - $body.removeClass('is-menu-visible'); - - }; - - $menu._toggle = function() { - - if ($menu._lock()) - $body.toggleClass('is-menu-visible'); - - }; - - $menu - .appendTo($body) - .on('click', function(event) { - event.stopPropagation(); - }) - .on('click', 'a', function(event) { - - var href = $(this).attr('href'); - - event.preventDefault(); - event.stopPropagation(); - - // Hide. - $menu._hide(); - - // Redirect. - if (href == '#menu') - return; - - window.setTimeout(function() { - window.location.href = href; - }, 350); - - }) - .append('Close'); - - $body - .on('click', 'a[href="#menu"]', function(event) { - - event.stopPropagation(); - event.preventDefault(); - - // Toggle. - $menu._toggle(); - - }) - .on('click', function(event) { - - // Hide. - $menu._hide(); - - }) - .on('keydown', function(event) { - - // Hide on escape. - if (event.keyCode == 27) - $menu._hide(); - - }); - + }) + .append('Close'); + + $body + .on('click', 'a[href="#menu"]', function(event) { + event.stopPropagation(); + event.preventDefault(); + $menu._toggle(); + }) + .on('click', function(event) { + $menu._hide(); + }) + .on('keydown', function(event) { + if (event.keyCode == 27) + $menu._hide(); + }); -const navIcon = document.querySelector(".nav-icon");const nav = document.querySelector("nav"); -navIcon.onclick = function () { nav.classList.toggle('show');} + // Back to Top button + var backToTopButton = document.getElementById("myBtn"); + + // Show the button when scrolling down 20px + window.onscroll = function() { + if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { + backToTopButton.style.display = "block"; + } else { + backToTopButton.style.display = "none"; + } + }; + + // Scroll to the top when the button is clicked + backToTopButton.onclick = function() { + document.body.scrollTop = 0; // For Safari + document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera + }; })(jQuery);