Created
April 12, 2011 18:51
-
-
Save kayue/916127 to your computer and use it in GitHub Desktop.
Javascript bootstrapping
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
/** | |
* Namespacing | |
* All method start with "init" will be automatically called at start. | |
*/ | |
var popbee = {} | |
popbee.body = $("body"); | |
popbee.initHomepage = function() { | |
if(!popbee.body.hasClass("homepage") return; // return if not at homepage | |
alert("only pop if (and only if) this is homepage"); | |
} | |
popbee.shorthand = function() { | |
// this won't call | |
} | |
// dom ready | |
$(function(){ | |
// start initial the page | |
var namespace = popbee; | |
for(method in namespace) { | |
// skip if not start with _init | |
if(method.toString().substring(0,4) !== 'init') continue; | |
// call method | |
namespace[method.toString()](); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment