2015-12-01 08:33:23 +00:00
|
|
|
/* global $ */
|
2016-01-02 23:29:02 +00:00
|
|
|
var is_navbar_attached = false;
|
|
|
|
|
2016-01-03 13:32:08 +00:00
|
|
|
$(window).load(function() {
|
|
|
|
$(window).trigger('scroll').trigger('resize');
|
2016-01-02 23:29:02 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
function detach_navbar() {
|
2016-01-03 13:32:08 +00:00
|
|
|
$('#navbar-container').removeClass('stick-top').addClass('align');
|
|
|
|
$('.dropdown-menu').removeClass('dropdown').addClass('dropup');
|
2016-01-02 23:29:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function attach_navbar() {
|
2016-01-03 13:32:08 +00:00
|
|
|
$('#navbar-container').removeClass('align').addClass('stick-top');
|
|
|
|
$('.dropdown-menu').removeClass('dropup').addClass('dropdown');
|
2016-01-02 23:29:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function flip_dropdowns(obj, direction) {
|
2016-01-03 13:32:08 +00:00
|
|
|
if (obj.hasClass('drop' + direction)) { return; }
|
|
|
|
var reverse = ((direction === 'up') ? 'down' : 'up');
|
|
|
|
obj.removeClass('drop' + reverse).addClass('drop' + direction);
|
|
|
|
obj.prev().children().removeClass('ion-ios-arrow-' + reverse).addClass('ion-ios-arrow-' + direction);
|
|
|
|
}
|
|
|
|
|
|
|
|
function position_navbar() {
|
|
|
|
if ($(window).width() < 862) { // @screen-sm
|
|
|
|
$('.navbar-icon').removeClass('ion-ios-arrow-up').addClass('ion-ios-arrow-down');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ($(window).scrollTop() > $('#navbar-anchor').offset().top) {
|
|
|
|
if (!is_navbar_attached) {
|
|
|
|
attach_navbar();
|
|
|
|
is_navbar_attached = true;
|
|
|
|
}
|
|
|
|
} else if (is_navbar_attached) {
|
|
|
|
detach_navbar();
|
|
|
|
is_navbar_attached = false;
|
|
|
|
}
|
|
|
|
$('.dropdown-menu').each(function() {
|
|
|
|
var direction = ($(this).height() + 10 < $('nav').offset().top - $(window).scrollTop()) ? 'up' : 'down';
|
|
|
|
flip_dropdowns($(this), direction);
|
|
|
|
});
|
2016-01-02 23:29:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function space_navbar() { //This really should be CSS!
|
2016-01-03 13:32:08 +00:00
|
|
|
if ($(window).width() < 862) { return; } // @screen-sm
|
|
|
|
var nav_width = $('#navigation').outerWidth(true);
|
|
|
|
var full_width = $('nav > .container-fluid').outerWidth(true) - $('.home-button').outerWidth(true);
|
|
|
|
var margin = (full_width - nav_width) / 2;
|
|
|
|
$('#navigation').css('margin-left', margin);
|
2016-01-02 23:29:02 +00:00
|
|
|
}
|
|
|
|
|
2015-12-01 08:33:23 +00:00
|
|
|
$(function() { // https://css-tricks.com/snippets/jquery/smooth-scrolling/
|
|
|
|
$('a[href*=#]:not([href=#])').click(function() {
|
|
|
|
if (location.pathname.replace(/^\//, '') === this.pathname.replace(/^\//, '')
|
|
|
|
&& location.hostname === this.hostname) {
|
|
|
|
var target = $(this.hash);
|
|
|
|
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
|
|
|
|
if (target.length) {
|
|
|
|
$('html,body').animate({
|
|
|
|
scrollTop: target.offset().top
|
|
|
|
}, 1000);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2015-12-28 18:12:39 +00:00
|
|
|
|
|
|
|
$('a[href="soon"]').click(function (e) {
|
|
|
|
e.preventDefault();
|
2015-12-28 18:17:49 +00:00
|
|
|
alert('Content coming soon, stand by!');
|
2015-12-28 18:12:39 +00:00
|
|
|
});
|
2016-01-02 23:29:02 +00:00
|
|
|
|
2016-01-03 13:21:48 +00:00
|
|
|
$(window).scroll(position_navbar);
|
2016-01-02 23:29:02 +00:00
|
|
|
|
2016-01-03 13:21:48 +00:00
|
|
|
$(window).resize(space_navbar);
|