mirror of
https://git.adityakumar.xyz/hugo-theme-introduction.git
synced 2024-12-22 14:42:54 +00:00
Bundle nav script in index.js
This commit is contained in:
parent
9125225a21
commit
e375687f26
11 changed files with 29 additions and 36 deletions
|
@ -1,3 +1,23 @@
|
|||
// Nav burger animation
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
// Get all "navbar-burger" elements
|
||||
var $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
|
||||
// Check if there are any navbar burgers
|
||||
if ($navbarBurgers.length > 0) {
|
||||
// Add a click event on each of them
|
||||
$navbarBurgers.forEach(function ($el) {
|
||||
$el.addEventListener('click', function () {
|
||||
// Get the target from the "data-target" attribute
|
||||
var target = $el.dataset.target;
|
||||
var $target = document.getElementById(target);
|
||||
// Toggle the class on both the "navbar-burger" and the "navbar-menu"
|
||||
$el.classList.toggle('is-active');
|
||||
$target.classList.toggle('is-active');
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Bitty scrolling links script
|
||||
$('a[href^="#"]').click(function(e) {
|
||||
e.preventDefault();
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
{"Target":"js/bundle.41083b6c6cc8f18bf6349ab84f46b25dd6373822f5450e0064959d72e42b36f5.js","MediaType":"application/javascript","Data":{"Integrity":"sha256-QQg7bGzI8Yv2NJq4T0ayXdY3OCL1RQ4AZJWdcuQrNvU="}}
|
||||
{"Target":"js/bundle.43be10f5b3a3e814bf07ce3fad76148fdd7184ea7b2e3f1d6b427828d24a56f2.js","MediaType":"application/javascript","Data":{"Integrity":"sha256-Q74Q9bOj6BS/B84/rXYUj91xhOp7Lj8da0J4KNJKVvI="}}
|
|
@ -1,2 +1,2 @@
|
|||
$('a[href^="#"]').click(function(e){e.preventDefault();$('html, body').animate({scrollTop:$(this.hash).offset().top},500);$("#nav-menu").removeClass("is-active");return true;})
|
||||
document.addEventListener('DOMContentLoaded',function(){var $navbarBurgers=Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'),0);if($navbarBurgers.length>0){$navbarBurgers.forEach(function($el){$el.addEventListener('click',function(){var target=$el.dataset.target;var $target=document.getElementById(target);$el.classList.toggle('is-active');$target.classList.toggle('is-active');});});}});$('a[href^="#"]').click(function(e){e.preventDefault();$('html, body').animate({scrollTop:$(this.hash).offset().top},500);$("#nav-menu").removeClass("is-active");return true;})
|
||||
$('.card').click(function(){$($(this).attr('data-target')).addClass('is-active');$("html").addClass("modal-open");});$('.modal-close').click(function(){$($(this).attr('data-target')).removeClass('is-active');$("html").removeClass("modal-open");});$(document).keypress(function(e){if(e.which==0){$('.modal.is-active').removeClass('is-active');$("html").removeClass("modal-open");}});
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
{"Target":"js/bundle.41083b6c6cc8f18bf6349ab84f46b25dd6373822f5450e0064959d72e42b36f5.js","MediaType":"application/javascript","Data":{"Integrity":"sha256-QQg7bGzI8Yv2NJq4T0ayXdY3OCL1RQ4AZJWdcuQrNvU="}}
|
||||
{"Target":"js/bundle.43be10f5b3a3e814bf07ce3fad76148fdd7184ea7b2e3f1d6b427828d24a56f2.js","MediaType":"application/javascript","Data":{"Integrity":"sha256-Q74Q9bOj6BS/B84/rXYUj91xhOp7Lj8da0J4KNJKVvI="}}
|
|
@ -1,2 +1,2 @@
|
|||
$('a[href^="#"]').click(function(e){e.preventDefault();$('html, body').animate({scrollTop:$(this.hash).offset().top},500);$("#nav-menu").removeClass("is-active");return true;})
|
||||
document.addEventListener('DOMContentLoaded',function(){var $navbarBurgers=Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'),0);if($navbarBurgers.length>0){$navbarBurgers.forEach(function($el){$el.addEventListener('click',function(){var target=$el.dataset.target;var $target=document.getElementById(target);$el.classList.toggle('is-active');$target.classList.toggle('is-active');});});}});$('a[href^="#"]').click(function(e){e.preventDefault();$('html, body').animate({scrollTop:$(this.hash).offset().top},500);$("#nav-menu").removeClass("is-active");return true;})
|
||||
$('.card').click(function(){$($(this).attr('data-target')).addClass('is-active');$("html").addClass("modal-open");});$('.modal-close').click(function(){$($(this).attr('data-target')).removeClass('is-active');$("html").removeClass("modal-open");});$(document).keypress(function(e){if(e.which==0){$('.modal.is-active').removeClass('is-active');$("html").removeClass("modal-open");}});
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
{"Target":"js/bundle.41083b6c6cc8f18bf6349ab84f46b25dd6373822f5450e0064959d72e42b36f5.js","MediaType":"application/javascript","Data":{"Integrity":"sha256-QQg7bGzI8Yv2NJq4T0ayXdY3OCL1RQ4AZJWdcuQrNvU="}}
|
||||
{"Target":"js/bundle.43be10f5b3a3e814bf07ce3fad76148fdd7184ea7b2e3f1d6b427828d24a56f2.js","MediaType":"application/javascript","Data":{"Integrity":"sha256-Q74Q9bOj6BS/B84/rXYUj91xhOp7Lj8da0J4KNJKVvI="}}
|
|
@ -1,2 +1,2 @@
|
|||
$('a[href^="#"]').click(function(e){e.preventDefault();$('html, body').animate({scrollTop:$(this.hash).offset().top},500);$("#nav-menu").removeClass("is-active");return true;})
|
||||
document.addEventListener('DOMContentLoaded',function(){var $navbarBurgers=Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'),0);if($navbarBurgers.length>0){$navbarBurgers.forEach(function($el){$el.addEventListener('click',function(){var target=$el.dataset.target;var $target=document.getElementById(target);$el.classList.toggle('is-active');$target.classList.toggle('is-active');});});}});$('a[href^="#"]').click(function(e){e.preventDefault();$('html, body').animate({scrollTop:$(this.hash).offset().top},500);$("#nav-menu").removeClass("is-active");return true;})
|
||||
$('.card').click(function(){$($(this).attr('data-target')).addClass('is-active');$("html").addClass("modal-open");});$('.modal-close').click(function(){$($(this).attr('data-target')).removeClass('is-active');$("html").removeClass("modal-open");});$(document).keypress(function(e){if(e.which==0){$('.modal.is-active').removeClass('is-active');$("html").removeClass("modal-open");}});
|
|
@ -102,31 +102,4 @@
|
|||
</nav>
|
||||
<hr>
|
||||
</div>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
// Get all "navbar-burger" elements
|
||||
var $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
|
||||
|
||||
// Check if there are any navbar burgers
|
||||
if ($navbarBurgers.length > 0) {
|
||||
|
||||
// Add a click event on each of them
|
||||
$navbarBurgers.forEach(function ($el) {
|
||||
$el.addEventListener('click', function () {
|
||||
|
||||
// Get the target from the "data-target" attribute
|
||||
var target = $el.dataset.target;
|
||||
var $target = document.getElementById(target);
|
||||
|
||||
// Toggle the class on both the "navbar-burger" and the "navbar-menu"
|
||||
$el.classList.toggle('is-active');
|
||||
$target.classList.toggle('is-active');
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
<!-- End Nav bar -->
|
||||
|
|
Loading…
Reference in a new issue