Created
June 27, 2014 18:24
-
-
Save menslow/75155e5e9add4bbe7d66 to your computer and use it in GitHub Desktop.
JavaScript Namespace Pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var CS = (function() { | |
var $ = jQuery; | |
return { | |
init: function() { | |
this.setFoundation(); | |
this.setJS(); | |
this.setMenuEvents(); | |
this.setPageScroll(); | |
}, | |
setFoundation: function() { | |
$(document).foundation(); | |
}, | |
setJS: function() { | |
$('body').addClass('js'); | |
}, | |
setMenuEvents: function() { | |
}, | |
setPageScroll: function() { | |
// Add click event with animated scroll | |
$('ul.scroll a').on('click', function(e){ | |
e.preventDefault(); | |
var speed = 400, | |
anchor = $(this).attr('href'); | |
loc = $(anchor).offset().top; | |
$('body').animate( { scrollTop: loc }, speed ); | |
}); | |
} | |
}; | |
} () ); | |
jQuery(document).ready(function() { | |
CS.init(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment