Difference between revisions of "Template:Washington"

Line 379: Line 379:
 
     });
 
     });
  
    /**
 
    * This part causes smooth scrolling using scrollto.js
 
    * We target all a tags inside the nav, and apply the scrollto.js to it.
 
    */
 
    $("nav a").click(function(evn){
 
        evn.preventDefault();
 
        $('html,body').scrollTo(this.hash, this.hash);
 
    });
 
 
    /**
 
    * This part handles the highlighting functionality.
 
    * We use the scroll functionality again, some array creation and
 
    * manipulation, class adding and class removing, and conditional testing
 
    */
 
    var aChildren = $("nav li").children(); // find the a children of the list items
 
    var aArray = []; // create the empty aArray
 
    for (var i=0; i < aChildren.length; i++) {   
 
        var aChild = aChildren[i];
 
        var ahref = $(aChild).attr('href');
 
        aArray.push(ahref);
 
    } // this for loop fills the aArray with attribute href values
 
 
 
 
        if(windowPos + windowHeight == docHeight) {
 
            if (!$("nav li:last-child a").hasClass("nav-active")) {
 
                var navActiveCurrent = $(".nav-active").attr("href");
 
                $("a[href='" + navActiveCurrent + "']").removeClass("nav-active");
 
                $("nav li:last-child a").addClass("nav-active");
 
            }
 
        }
 
    });
 
 
});
 
});
 
</script>
 
</script>

Revision as of 23:20, 13 September 2015