got the nav working on web and looking real sharp.

This commit is contained in:
Dave Gamache
2014-12-01 22:44:25 -08:00
parent a4ab5f6f4e
commit 7e293bdc43
4 changed files with 119 additions and 34 deletions

View File

@ -5,7 +5,9 @@ $(document).ready(function() {
$nav = $('.navbar'),
$body = $('body'),
$window = $(window),
$popoverLink = $('[data-popover]'),
navOffsetTop = $nav.offset().top,
$document = $(document),
entityMap = {
"&": "&",
"<": "&lt;",
@ -18,9 +20,45 @@ $(document).ready(function() {
function init() {
$window.on('scroll', onScroll)
$window.on('resize', resize)
$popoverLink.on('click', openPopover)
$document.on('click', closePopover)
$('a[href^="#"]').on('click', smoothScroll)
buildSnippets();
}
function smoothScroll(e) {
e.preventDefault();
$(document).off("scroll");
var target = this.hash,
menu = target;
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top-40
}, 500, 'swing', function () {
window.location.hash = target;
$(document).on("scroll", onScroll);
});
}
function openPopover(e) {
e.preventDefault()
var popover = $($(this).data('popover'));
popover.toggleClass('open')
e.stopImmediatePropagation();
}
function closePopover(e) {
if($('.popover.open').length > 0) {
$('.popover').removeClass('open')
}
}
$("#button").click(function() {
$('html, body').animate({
scrollTop: $("#elementtoScrollToID").offset().top
}, 2000);
});
function resize() {
navOffsetTop = $nav.offset().top
}