Chaining JS modules #1

by toubia95

CSS

/* source : 
http://stackoverflow.com/questions/881515/how-do-i-declare-a-namespace-in-javascript
*/

JavaScript

(function( module, undefined ) {
    //Private Property
    var _toto = 'HelloWorld';
    
    //Public Property
    module.toto = 'HelloWorld2';

    //Public Method
    module.HelloWorld = function() {
        alert(_toto+" "+module.toto);
        Test('Private Method');
    };
    
    //Private Method
   function Test(x) {
        alert(x);
    }
}( window.module = window.module || {}));

(function( module, undefined ) {
    //Private Property
    var _titi = 'titi';
    
    //Public Method
    module.GoodByeWorld = function() {
        alert(_titi+" "+module.toto);
        Test('Private Method2');
    };
}( window.module = window.module || {}));

module.HelloWorld();
module.GoodByeWorld(); // /!\ second private method is not called