I'm developing a jQuery application for a website and by what I have read, the module pattern seems to be the best setup.
I've begun to adapt the module/sub module pattern and before I write the application, I'm wondering if the development is correct. Here is a basic sample:
var module = (function($, window, document, undefined) {
return {
loader : (function() {
var fade = 250; // public property
var $loader = $('#loader'); // private property
// return public properties and methods
return {
fade : fade,
show : function() {
$loader.fadeIn(module.loader.fade);
},
hide : function() {
$loader.fadeOut(module.loader.fade);
}
}
})()
}
})(jQuery, window, document);
module.loader.fade = 500;
module.loader.show();
Again, "loader" would be a sub module. I want to keep all my sub modules wrapped in the main module.
I'm wondering if I'm handling the public property correctly, or if there is a better way?
Thanks