Difference between revisions of "Template:Waterloo/JS/header.js"
m |
m |
||
Line 23: | Line 23: | ||
$(".scroll-link").each(function(i, obj) { | $(".scroll-link").each(function(i, obj) { | ||
$(obj).click(function() { | $(obj).click(function() { | ||
+ | console.log(Object.keys(obj)); | ||
scrollToAnchor(obj.text); | scrollToAnchor(obj.text); | ||
}); | }); | ||
Line 33: | Line 34: | ||
// for smooth scrolling | // for smooth scrolling | ||
function scrollToAnchor(aid){ | function scrollToAnchor(aid){ | ||
− | |||
var aTag = $('#'+aid); | var aTag = $('#'+aid); | ||
if(aTag.length){ | if(aTag.length){ |
Revision as of 23:22, 26 August 2015
// scripts for header
// detects scroll for top resizing and lower nav show $(window).scroll(function() {
if ($(document).scrollTop() > 50) { $('.main-nav').addClass('shrink'); if ($('#inner-page-links').children().length > 0) { $('.navbar-lower').removeClass('hide-lower'); } } else { $('.main-nav').removeClass('shrink'); $('.navbar-lower').addClass('hide-lower'); }
});
// fills in lower nav with inner page links $(document).ready(function(){
$('.accordion-heading').addClass('link'); $('section').addClass('link'); $('.link').each(function(i, obj) {$("#inner-page-links").append('
}); $(".scroll-link").each(function(i, obj) { $(obj).click(function() { console.log(Object.keys(obj)); scrollToAnchor(obj.text); }); }); if ($('#inner-page-links').children().length < 1) { $('.navbar-lower').addClass('hide-lower'); }
});
// for smooth scrolling function scrollToAnchor(aid){
var aTag = $('#'+aid); if(aTag.length){ $('html, body').animate({scrollTop:$(aTag).position().top}, 'slow'); }
}