Created
July 19, 2010 03:40
-
-
Save jgarber623/480983 to your computer and use it in GitHub Desktop.
A sample JavaScript structure for larger web applications
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
/* | |
* Based on Paul Irish's "Markup-based unobtrusive comprehensive DOM-ready execution" | |
* http://paulirish.com/2009/markup-based-unobtrusive-comprehensive-dom-ready-execution/ | |
*/ | |
SITE_NAMESPACE = { | |
common: { | |
init: function() { | |
} | |
} | |
}; | |
UTIL = { | |
exec: function( controller, action ) { | |
var ns = SITE_NAMESPACE, action = ( action === undefined ) ? "init" : action; | |
if ( controller !== "" && ns[controller] && typeof( ns[controller][action] ) == "function" ) { | |
ns[controller][action](); | |
} | |
}, | |
init: function() { | |
UTIL.exec( "common" ); | |
UTIL.exec( document.body.getAttribute( "data-controller" ), document.body.getAttribute( "data-action" ) ); | |
} | |
}; | |
$().ready( UTIL.init ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment