scopesessions.org/js/custom.js

82 lines
1.4 KiB
JavaScript
Raw Normal View History

2015-02-03 04:36:49 +01:00
var scrolling = false;
2015-02-13 18:09:23 +01:00
var navigatorOpen = false;
var topButtonVisible = true;
2015-02-13 18:11:24 +01:00
$(document).ready(function() {
2015-02-13 18:11:24 +01:00
$(function() {
2015-02-03 04:36:49 +01:00
$.scrollIt();
});
2015-02-03 04:36:49 +01:00
$(".navigator-toggle").click(function() {
2015-02-13 18:11:24 +01:00
if (navigatorOpen) {
2015-02-13 18:09:23 +01:00
closeTopMenu();
2015-02-13 18:11:24 +01:00
} else {
2015-02-13 18:09:23 +01:00
openTopMenu();
}
navigatorOpen = !navigatorOpen;
});
$(".topic").click(function() {
closeTopMenu();
});
2015-02-13 18:11:24 +01:00
function openTopMenu() {
if (!scrolling && !navigatorOpen) {
2015-02-03 04:36:49 +01:00
scrolling = true;
2015-02-13 18:11:24 +01:00
$(".navigator").slideDown("slow", function() {
2015-02-03 04:36:49 +01:00
scrolling = false;
2015-02-13 18:09:23 +01:00
navigatorOpen = true;
2015-02-03 04:36:49 +01:00
});
}
2015-02-13 18:09:23 +01:00
}
2015-02-13 18:11:24 +01:00
function closeTopMenu() {
if (!scrolling && navigatorOpen) {
2015-02-03 04:36:49 +01:00
scrolling = true;
2015-02-13 18:11:24 +01:00
$('.navigator').slideUp("slow", function() {
2015-02-03 04:36:49 +01:00
scrolling = false;
2015-02-13 18:09:23 +01:00
navigatorOpen = false;
2015-02-03 04:36:49 +01:00
});
}
2015-02-13 18:09:23 +01:00
}
2015-02-13 18:11:24 +01:00
function showTopButton() {
2015-02-13 18:09:23 +01:00
console.log('showTopButton');
2015-02-13 18:11:24 +01:00
if (!topButtonVisible) {
$('.top-button').show("slow", function() {
2015-02-13 18:09:23 +01:00
topButtonVisible = true;
});
}
}
2015-02-13 18:11:24 +01:00
function hideTopButton() {
2015-02-13 18:09:23 +01:00
console.log('hideTopButton');
2015-02-13 18:11:24 +01:00
if (topButtonVisible) {
$('.top-button').hide("slow", function() {
2015-02-13 18:09:23 +01:00
topButtonVisible = false;
});
}
}
var timeout = null;
var navbarHeight = $('.navbar').height();
2015-02-13 18:11:24 +01:00
$(window).scroll(function() {
2015-02-13 18:09:23 +01:00
if (!timeout) {
2015-02-13 18:11:24 +01:00
timeout = setTimeout(function() {
clearTimeout(timeout);
timeout = null;
if ($(window).scrollTop() >= navbarHeight) {
closeTopMenu();
showTopButton();
} else {
hideTopButton();
}
}, 250);
2015-02-13 18:09:23 +01:00
}
2015-02-03 04:36:49 +01:00
});
});