-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple-js-namespace.js
35 lines (27 loc) · 993 Bytes
/
simple-js-namespace.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//my simple javascript namespace i use as a template.
//Do a search-resplace on "SIMPLE" and replace it with your sugested namespace name.
//Roger Krona, [email protected]
(function (window, document, SIMPLE, $, undefined) {
//variables, put variables here
var myVar = 'SIMPLE namespace logged from init function';
//private functions, put functions here
var privateFunction = function(){
//this function is private inside the SIMPLE namespace
}
var publicFunction = function(){
//this function is public outside the SIMPLE namespace. call it by SIMPLE.publicFunction();
}
// initialize
// call this function by SIMPLE.init();
var init = function () {
console.log(myVar);
};
// public interface, declare all varibales and functions here you want to expose outside this namespace.
var oPublic =
{
publicFunction: publicFunction,
init: init
};
return oPublic;
}();
}(this, this.document, window.SIMPLE = window.SIMPLE || {}, jQuery));