Skip to content

Commit 8a2a37f

Browse files
📝
1 parent d015460 commit 8a2a37f

File tree

1 file changed

+23
-29
lines changed

1 file changed

+23
-29
lines changed

src/module-app.js

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,22 @@
22
* ModulePattern Bootstrap
33
*
44
* Created : 21/01/2013
5-
* Modified : 27/08/2014
6-
* Version : 3.0
5+
* Modified : 13/12/2015
6+
* Version : 0.0.4
77
* UI Developer : Guilherme Pontes
88
* Notes : Copy and reproduce as much as you want.
99
---------------------------------------------------------------------------*/
1010

1111
/**
1212
* This is MyApp, it makes something awesome.
13-
* It's an self invokated function that runs automatically/immediately.
13+
* It's a self invokated function that runs automatically/immediately.
1414
*
1515
* @class MyApp
1616
* @constructor
1717
*/
1818
var MyApp = window.MyApp || (function(document, window){
1919
"use strict";
2020

21-
var app, _private;
22-
2321
/**
2422
* The _private variable encapsulate all PRIVATE functions
2523
* and properties.
@@ -28,7 +26,7 @@ var MyApp = window.MyApp || (function(document, window){
2826
* @type {Object}
2927
* @default {Object}
3028
*/
31-
_private = {
29+
var __private = {
3230
/**
3331
* The _config variable sets all properties that will be
3432
* handled by the app.
@@ -58,7 +56,7 @@ var MyApp = window.MyApp || (function(document, window){
5856
},
5957

6058
/**
61-
* Makes the body element from {MyApp.body} the color setted,
59+
* Makes the body element from `MyApp.body` the color setted,
6260
* if not setted it will be the default color
6361
* from {_private._config.background.color}
6462
*
@@ -67,45 +65,45 @@ var MyApp = window.MyApp || (function(document, window){
6765
* @return {Undefined}
6866
*/
6967
setBGColor: function(color) {
70-
app.body.style.background = color || this._config.background.color;
68+
application.body.style.background = color || this._config.background.color;
7169
},
7270

7371
/**
74-
* Makes body blue from {MyApp.init} method.
72+
* Makes body blue from `MyApp.init` method.
7573
*
7674
* @method makeBackgroundBlue
7775
* @return {Undefined}
7876
*/
7977
makeBackgroundBlue: function() {
80-
_private.setBGColor("blue");
78+
__private.setBGColor("blue");
8179
},
8280

8381
/**
84-
* Makes body red from click event at {MyApp.bind} from
82+
* Makes body red from click event at `MyApp.bind` from
8583
* {MyApp.makeBodyRed}.
8684
*
8785
* @method makeBackgroundRed
8886
* @return {Undefined}
8987
*/
9088
makeBackgroundRed: function() {
91-
_private.setBGColor("red");
89+
__private.setBGColor("red");
9290
}
9391
};
9492

9593
/**
96-
* The _app variable encapsulate all PUBLIC functions
94+
* Encapsulates all PUBLIC functions
9795
* and properties.
9896
*
9997
* @property _private
10098
* @type {Object}
10199
* @default {Object}
102100
*/
103-
app = {
101+
var application = {
104102

105103
/**
106-
* The init method, is the function that initialize the project,
107-
* by caching variables and binding objects and can initialize
108-
* other methods too.
104+
* Initialize the project by caching variables
105+
* and binding the objects. It can also initialize
106+
* other methods.
109107
*
110108
* @method init
111109
* @return {Undefined}
@@ -114,15 +112,13 @@ var MyApp = window.MyApp || (function(document, window){
114112
this._cache();
115113
this._bind();
116114

117-
//the background must be blue first..
118115
_private.makeBackgroundBlue();
119116
},
120117

121118
/**
122-
* The _cache method creates public properties that will be
123-
* handled by other methods. Caching elements to not have to be
124-
* called every single time.
125-
*
119+
* Creates public properties that will be
120+
* handled by other methods. Caching elements is a
121+
* good practice.
126122
*
127123
* @method _cache
128124
* @return {Undefined}
@@ -132,7 +128,7 @@ var MyApp = window.MyApp || (function(document, window){
132128
},
133129

134130
/**
135-
* The _bind method bind all cached dom elements from {MyApp._cache}.
131+
* Bind all cached dom elements from `MyApp._cache`.
136132
* It sets methods to events made by the DOM.
137133
*
138134
*
@@ -145,13 +141,11 @@ var MyApp = window.MyApp || (function(document, window){
145141
};
146142

147143
// make app visible by the MyApp;
148-
return app;
144+
return application;
149145

150146
})(document, window);
151-
//We also could auto-initialize the app this way, adding a `.init()`, like this:
147+
//We also can auto-initialize the app by adding a `.init()`, like this:
152148
//})(document, window).init();
153149

154-
// another self invokated function to executes the app.
155-
(function(){
156-
MyApp.init();
157-
})();
150+
// Initialize app
151+
MyApp.init();

0 commit comments

Comments
 (0)