Skip to content

Instantly share code, notes, and snippets.

@menslow
Created June 27, 2014 18:24
Show Gist options
  • Save menslow/75155e5e9add4bbe7d66 to your computer and use it in GitHub Desktop.
Save menslow/75155e5e9add4bbe7d66 to your computer and use it in GitHub Desktop.
JavaScript Namespace Pattern
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