in src/assets/js/main.js [10:223]
jQuery(document).ready(function ($) {
// SETTINGS
// ------------------
// Velocty Easing
// ------
$.Velocity.defaults.easing = 'easeInOutQuart';
// Device
// ------
if (is_touch_device) {
$('body').addClass('touch-device');
}
$('body').on('mousedown', function () {
$('body').addClass('using-mouse');
});
$('body').on('keydown', function () {
$('body').removeClass('using-mouse');
});
// PLUGINS
// ------------------
// 1. Site Nav
if ($('.full-width .site-header, .sidebar .site-header').length) {
$('.site-header').switchNav();
}
$('.has-children').each(function () {
if ($(this).find('.is-active').length) {
$(this).addClass('has-active-children');
}
});
if ($('.sidenav').length) {
$('.sidenav').sideNav();
}
if ($('#sidenav-status-pagename').length) {
$('#sidenav-status-pagename').sideNavStatus();
}
if ($('.sidenav-top .primary > .has-subfolder.has-active-children').length) {
$(
'.sidenav-top .primary > .has-subfolder.has-active-children'
).sideNavTop();
}
// Secondary Dropdown should not be tabbed through since it repeats functionality above:
if ($('.sidenav-top a').length) {
$('.sidenav-top a').each(function () {
$(this).attr('tabindex', '-1');
});
}
if ($('.sidenav-detail').length) {
$('.sidenav-detail').sideNavDetail();
}
// 2. Anchor Link Scroll
// ------
$('a[href^="#"]').scrollto({ offset_lg: 38, offset_sm: 38 });
// 3. Show in View
// ------
if ($('.showOnView').length) {
$('.showOnView').showOnView();
}
// 4. Banner Image Parallax
// ------
// ****** ******
// ** the plugin code is found in parallax.js **
// ***** ******
if (!is_touch_device) {
console.debug('Parallax effects enabled');
if ($('.parallax').length) {
$('.parallax').parallax({ offsetIntertia: -0.15 });
}
if ($('.parallaxFG').length) {
$('.parallaxFG').parallaxFG({ offsetIntertia: 0.15 });
}
if ($('.parallaxFG-right').length) {
$('.parallaxFG-right').parallaxFG({ offsetIntertia: 0.075, axis: 'x' });
}
if ($('.parallaxFG-left').length) {
$('.parallaxFG-left').parallaxFG({ offsetIntertia: -0.075, axis: 'x' });
}
}
// 5. Video Popup
// ------
// ****** ******
// ** the plugin code is found in youtubeplayer.js **
// ***** ******
// 6. Slick slider
// ------
// ****** ******
// ** external plugin **
// ***** ******
if ($('.mobile-slider .grid-container').length) {
$('.mobile-slider .grid-container').slick({
mobileFirst: true,
dots: true,
arrows: false,
centerMode: true,
centerPadding: '16px',
slidesToShow: 1,
responsive: [
{
breakpoint: 640,
settings: 'unslick',
},
],
});
}
// 7. RSS Feed
// ------
if ($('#rss-feed').length) {
$('#rss-feed').rss_feed();
}
// 8. Anatomy of an extension
// ------
if ($('#anatomy-of-an-extension-graphic').length) {
$('#anatomy-of-an-extension-graphic').extenstionAnatomy();
}
// 9. Popups
// ------
if ($('.popup-action').length) {
$('.popup-action').popups();
}
// 10. Site (Content Guidelines) Nav
// ------
if ($('.content-guidelines .site-nav-container').length) {
$('.content-guidelines .site-nav-container').switchContentGuidelinesNav();
}
// 11. Site Search Header
// ------
if ($('.search-input').length) {
$('.search-input').searchHeader();
}
// 12. Site Search Results
// ------
if ($('#result-list').length) {
$('#result-list').searchResults();
}
if ($('#tag-list').length) {
$('#tag-list').searchResults({
input: null,
default: '.popular-searches',
search_fields: [
{
title: 'tags',
},
],
});
}
// 13. Sidebar Nav Page Section Highlighting
// ------
if ($('.is-active > .section').length) {
$('.is-active > .section').highlightPageSection();
}
// 14. Expandable List
// ------
if ($('.expandable-list').length) {
$('.expandable-list').expandableList();
}
// 15. Up Next: hide if empty
// ------
if ($('.up-next').length && !$('.up-next a').length) {
$('.up-next').hide(0);
}
// 16. Scroll sidebar to active page position
// ------
if ($('.sidenav-detail .is-active').length) {
$('.sidenav').sidenavScrollToActive();
}
// Init Breakpoint Listeners
// ------------------
$(this).breakpoints();
});