Difference between revisions of "Team:UC San Diego/main.js"

(Created page with "// scroll function function scrollToID(id, speed){ var offSet = 0; var targetOffset = $(id).offset().top - offSet; var mainNav = $('#main-nav'); $('html,body').animate({scrol...")
 
 
Line 2: Line 2:
 
function scrollToID(id, speed){
 
function scrollToID(id, speed){
 
var offSet = 0;
 
var offSet = 0;
var targetOffset = $(id).offset().top - offSet;
+
var targetOffset = jQuery(id).offset().top - offSet;
var mainNav = $('#main-nav');
+
var mainNav = jQuery('#main-nav');
$('html,body').animate({scrollTop:targetOffset}, speed);
+
jQuery('html,body').animate({scrollTop:targetOffset}, speed);
 
if (mainNav.hasClass("open")) {
 
if (mainNav.hasClass("open")) {
 
mainNav.css("height", "1px").removeClass("in").addClass("collapse");
 
mainNav.css("height", "1px").removeClass("in").addClass("collapse");
Line 18: Line 18:
 
$(document).ready(function() {
 
$(document).ready(function() {
 
// navigation click actions
 
// navigation click actions
$('.scroll-link').on('click', function(event){
+
jQuery('.scroll-link').on('click', function(event){
 
event.preventDefault();
 
event.preventDefault();
var sectionID = $(this).attr("data-id");
+
var sectionID = jQuery(this).attr("data-id");
 
scrollToID('#' + sectionID, 750);
 
scrollToID('#' + sectionID, 750);
 
});
 
});
 
// scroll to top action
 
// scroll to top action
$('.scroll-top').on('click', function(event) {
+
jQuery('.scroll-top').on('click', function(event) {
 
event.preventDefault();
 
event.preventDefault();
$('html, body').animate({scrollTop:0}, 'slow');
+
jQuery('html, body').animate({scrollTop:0}, 'slow');
 
});
 
});
 
// mobile nav toggle
 
// mobile nav toggle
$('#nav-toggle').on('click', function (event) {
+
jQuery('#nav-toggle').on('click', function (event) {
 
event.preventDefault();
 
event.preventDefault();
$('#main-nav').toggleClass("open");
+
jQuery('#main-nav').toggleClass("open");
 
});
 
});
 
});
 
});

Latest revision as of 03:06, 1 September 2015

// scroll function function scrollToID(id, speed){ var offSet = 0; var targetOffset = jQuery(id).offset().top - offSet; var mainNav = jQuery('#main-nav'); jQuery('html,body').animate({scrollTop:targetOffset}, speed); if (mainNav.hasClass("open")) { mainNav.css("height", "1px").removeClass("in").addClass("collapse"); mainNav.removeClass("open"); } } if (typeof console === "undefined") {

   console = {
       log: function() { }
   };

}

$(document).ready(function() { // navigation click actions jQuery('.scroll-link').on('click', function(event){ event.preventDefault(); var sectionID = jQuery(this).attr("data-id"); scrollToID('#' + sectionID, 750); }); // scroll to top action jQuery('.scroll-top').on('click', function(event) { event.preventDefault(); jQuery('html, body').animate({scrollTop:0}, 'slow'); }); // mobile nav toggle jQuery('#nav-toggle').on('click', function (event) { event.preventDefault(); jQuery('#main-nav').toggleClass("open"); }); });