ServiceInnovationLab/serviceinnovationlab.github.io

View on GitHub
assets/js/waypoints.js

Summary

Maintainability
A
2 hrs
Test Coverage
$(function() {
// Get link by section or article id
function getRelatedNavigation(el) {
return $('.nav-subnav a[href*=' + $(el).attr('id') + ']');
}
 
var $navItems = $('.nav-subnav a').filter('.nz-sidenav-list > li > a');
 
var $window = $(window);
var anchors = $.map($navItems, function(item) {
return item.getAttribute('href').replace(window.location.pathname, '');
});
 
anchors = anchors.filter(function(anchor) {
return anchor[0] === '#';
});
 
var $anchors = $(anchors.join(','));
$anchors
.waypoint(
Similar blocks of code found in 2 locations. Consider refactoring.
function(direction) {
$navItems.removeClass('nz-current', direction === 'down');
if ($window.scrollTop() !== 0) {
getRelatedNavigation(this).addClass(
'nz-current',
direction === 'down',
Parsing error: Unexpected token )
);
}
},
{
offset: function() {
return $(this).height();
},
},
)
.waypoint(
Similar blocks of code found in 2 locations. Consider refactoring.
function(direction) {
$navItems.removeClass('nz-current', direction === 'up');
if ($window.scrollTop() !== 0) {
getRelatedNavigation(this).addClass(
'nz-current',
direction === 'up',
);
}
},
{
offset: function() {
return -$(this).height();
},
},
);
 
// Subnav click to top
$('.nav-accordion-button-desktop').on('click', function() {
$window.scrollTop(0, 0);
});
});