From c1dc76a3c33156964be7c880ec847046f9754aa1 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 3 Jan 2016 13:32:08 +0000 Subject: [PATCH] Linting --- static/src/js/events.js | 67 +++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/static/src/js/events.js b/static/src/js/events.js index 5468412..a3d3be6 100644 --- a/static/src/js/events.js +++ b/static/src/js/events.js @@ -1,50 +1,53 @@ /* global $ */ - var is_navbar_attached = false; -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); - }); -} -$(window).load(function(){ - $(window).trigger('scroll').trigger('resize'); +$(window).load(function() { + $(window).trigger('scroll').trigger('resize'); }); function detach_navbar() { - $('#navbar-container').removeClass('stick-top').addClass('align'); - $('.dropdown-menu').removeClass('dropdown').addClass('dropup'); + $('#navbar-container').removeClass('stick-top').addClass('align'); + $('.dropdown-menu').removeClass('dropdown').addClass('dropup'); } function attach_navbar() { - $('#navbar-container').removeClass('align').addClass('stick-top'); - $('.dropdown-menu').removeClass('dropup').addClass('dropdown'); + $('#navbar-container').removeClass('align').addClass('stick-top'); + $('.dropdown-menu').removeClass('dropup').addClass('dropdown'); } function flip_dropdowns(obj, direction) { - 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); + 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); + }); } function space_navbar() { //This really should be CSS! - 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); + 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); } $(function() { // https://css-tricks.com/snippets/jquery/smooth-scrolling/