Skip to content

Instantly share code, notes, and snippets.

@v42
Last active December 17, 2015 21:19
Show Gist options
  • Save v42/5673525 to your computer and use it in GitHub Desktop.
Save v42/5673525 to your computer and use it in GitHub Desktop.
An approach for section-based behaviours on websites.
;(function() {
window.App = (function() {
var init = function() {
var section = getSection()
coreBehaviours()
sectionBehaviours(section)
console.log("It's on! ;)")
}
function coreBehaviours() {
//do stuff that is everywhere on the site
}
function sectionBehaviours(section) {
switch(section) {
case 'home':
//do home stuff
break
default:
//things for non-specified sections
break
}
}
function getSection() {
//a method that returns section names
}
return {
init: init
}
})()
App.init()
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment