Last active
December 17, 2015 21:19
-
-
Save v42/5673525 to your computer and use it in GitHub Desktop.
An approach for section-based behaviours on websites.
This file contains hidden or 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
;(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