-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
76 changed files
with
775 additions
and
762 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const btnBackToTop = $('#btn-back-to-top'); | ||
|
||
const backtotopObserver = new IntersectionObserver(entries => { | ||
entries.forEach(entry => { | ||
if (entry.isIntersecting) { | ||
btnBackToTop.fadeOut(); | ||
} else { | ||
btnBackToTop.fadeIn(); | ||
} | ||
}); | ||
}, { | ||
rootMargin: '250px', | ||
threshold: 0, | ||
}); | ||
|
||
backtotopObserver.observe(document.querySelector('#top-of-the-morning-to-you')); | ||
|
||
btnBackToTop.on('click', () => { | ||
document.body.scrollIntoView({ | ||
behavior: 'smooth', | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// "Go to Tags" in /posts/. | ||
const gototagsButton = $('#btn-go-to-tags'); | ||
const tagsSection = document.querySelector('#tags-sidebar'); | ||
|
||
if (tagsSection) { | ||
gototagsButton.on('click', () => { | ||
tagsSection.scrollIntoView({ | ||
behavior: 'smooth', | ||
}); | ||
}); | ||
|
||
const gototagObserver = new IntersectionObserver((entries, _observer) => { | ||
entries.forEach(entry => { | ||
if (entry.isIntersecting) { | ||
gototagsButton.fadeOut(); | ||
} else { | ||
gototagsButton.fadeIn(); | ||
} | ||
}); | ||
}, { | ||
rootMargin: '0px', | ||
threshold: 0, | ||
}); | ||
|
||
gototagObserver.observe(tagsSection); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Carousel auto-label update. | ||
$('.carousel').each(function () { | ||
// Update labels on slide. | ||
const id = $(this).attr('id'); | ||
$(this).on('slide.bs.carousel', event => { | ||
$(`#${id}-tab${event.from + 1}-label`).removeClass('active-tab'); | ||
$(`#${id}-tab${event.to + 1}-label`).addClass('active-tab'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
document.addEventListener('keydown', function (event) { | ||
if ((event.ctrlKey || event.metaKey) && event.key === 'k') { | ||
event.preventDefault(); | ||
$('#search-modal').modal('show'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Load SoundCloud embeds (dynamic src). | ||
const visual = $(window).width() < 600; | ||
|
||
const options = { | ||
rootMargin: '300px', // Lazy-load when the iframe is 300px away from the viewport. | ||
threshold: 0, | ||
}; | ||
|
||
// Set up an intersection observer to detect when tracks are nearly visible. | ||
const trackObserver = new IntersectionObserver((entries, observer) => { | ||
entries.forEach(entry => { | ||
if (entry.isIntersecting) { | ||
const track = entry.target; | ||
let src = track.dataset.src; | ||
if (visual) | ||
src += '&visual=true'; // Compressed view, more suitable for small screens. | ||
track.src = src; | ||
track.classList.remove('lazy'); | ||
observer.unobserve(track); | ||
} | ||
}); | ||
}, options); | ||
|
||
// Observe tracks for lazy loading. | ||
const tracks = document.querySelectorAll('.soundcloud-track.lazy'); | ||
tracks.forEach(e => trackObserver.observe(e)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const tooltips = document.querySelectorAll('[data-bs-toggle="tooltip"]'); | ||
[...tooltips].forEach(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Mobile ToC: Add a special class for dropdown items. | ||
$('#btn-mobile-toc nav.toc a').addClass('dropdown-item'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const docElem = document.documentElement; | ||
const docBody = document.body; | ||
const progressBar = document.querySelector('#scroll-progress-bar'); | ||
|
||
document.addEventListener('scroll', () => { | ||
const scrollTop = (docBody.scrollTop || docElem.scrollTop); | ||
const height = docElem.scrollHeight - docElem.clientHeight; | ||
const progress = scrollTop / height * 100; | ||
progressBar.style.setProperty('--progress', `${Math.max(progress, 0)}%`); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.