Created
January 11, 2010 19:03
-
-
Save mattfarina/274482 to your computer and use it in GitHub Desktop.
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
(function($) { | |
// | |
// Automatically calls all functions in APP.init | |
// | |
jQuery(document).ready(function() { | |
APP.go(); | |
}); | |
// | |
// Module pattern: | |
// http://yuiblog.com/blog/2007/06/12/module-pattern/ | |
// | |
var APP = function() { | |
// For use only inside APP. | |
var private_var_1 = 'foo'; | |
var private_var_2 = 'bar'; | |
// Expose contents of APP. | |
go: function() { | |
for (var i in APP.init) { | |
APP.init[i](); | |
} | |
}, | |
init: { | |
call_automatically_one: function() { | |
// Called on page-load. | |
// Can still be called individually, via: | |
// APP.init.call_automatically_one(); | |
}, | |
call_automatically_two: function() { | |
// Called on page-load. | |
// Can still be called individually, via: | |
// APP.init.call_automatically_two(); | |
} | |
}, | |
misc: { | |
call_specifically_one: function() { | |
// Must be called individually, via:. | |
// APP.misc.call_specifically_one(); | |
}, | |
call_specifically_two: function() { | |
// Must be called individually, via:. | |
// APP.misc.call_specifically_two(); | |
} | |
} | |
}; | |
// Pass in jQuery ref. | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment