KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.62
System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64
User : www ( 80)
PHP Version : 8.3.8
Disable Function : NONE
Directory :  /domains/dmoisan/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /domains/dmoisan/js/dma.js
var navHeight = $('.navbar').outerHeight();
var scrollTime = 400;


// ADD NAVBAR HEIGHT TO BODY PADDING
// https://webstoked.com/smooth-scrolling-offset-bootstrap-scrollspy/
$('body').css('padding-top', navHeight + 'px');
$(window).resize(function () {
    navHeight = $('.navbar').outerHeight();
    $('body').css('padding-top', navHeight + 'px');
});

document.getElementsByTagName("body")[0].setAttribute("data-offset", $('.navbar').outerHeight() + "px");


// HANDLE REDUCE MOTION PREFERENCE
// https://justmarkup.com/articles/2019-02-19-adapting-to-user-preferences/
var motionQuery = matchMedia('(prefers-reduced-motion)');

function handleReduceMotionChanged() {
    if (motionQuery.matches) {
        scrollTime = 0;
    } else {
        /* enable animations/transitions (enabled by default) */
    }
}
motionQuery.addListener(handleReduceMotionChanged);
handleReduceMotionChanged();


// SCROLLING TO ANCHOR LINKS WITH OFFSET FROM EXTERNAL PAGES
$(window).on("load", function () {

    var urlHash = window.location.href.split("#")[1];

    if (urlHash && $('#' + urlHash).length) {
        $('html,body').animate({
            scrollTop: $('#' + urlHash).offset().top - (navHeight - 1)
        }, scrollTime);
    }
});


// SMOOTH SCROLLING PLUS OFFSET FOR FIXED NAV
//$('a[href*="#"]')
//$(document).ready(function () {
$(".navbar a").on('click', function (event) {
    // Remove links that don't actually link to anything
    //                        .not('[href="#"]')
    //                            .not('[href="#0"]')
    //                            .on('click', function (event) {

    // Make sure this.hash has a value before overriding default behavior
    if (this.hash !== "") {

        // Store hash
        var hash = this.hash;

        // Using jQuery's animate() method to add smooth page scroll
        // The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
        // - 70 is the offset/top margin
        $('html, body').animate({
            scrollTop: $(hash).offset().top - (navHeight - 1)
        }, scrollTime, function () {

            // Add hash (#) to URL when done scrolling (default click behavior), without jumping to hash
            if (history.replaceState) {
                history.replaceState(null, null, hash);
            } else {
                window.location.hash = hash;
            }
        });
        return false;
    } // End if
    //                }
});



// COLLAPSE NAV ON CLICK (<lg screens)
// https://stackoverflow.com/questions/42401606/how-to-hide-collapsible-bootstrap-4-navbar-on-click
$('.navbar-nav>li>a').on('click', function () {
    $('.navbar-collapse').collapse('hide');
});


// SCROLLSPY
$('body').scrollspy({
    target: '#dma-navbar',
    offset: navHeight
})


// LAZY-LOAD PHOTO GALLERY CAROUSEL IMAGES
// https://stackoverflow.com/questions/12697216/bootstrap-carousel-lazy-load
$(function () {
    $('.carousel.lazy-load').bind('slide.bs.carousel', function (e) {
        $(e.relatedTarget).find('img[data-src]').each(function (i) {
            $(this).attr('src', $(this).data('src'));
            $(this).removeAttr('data-src');
        });
    });
});

Anon7 - 2021