Created
November 1, 2012 17:11
-
-
Save pauliusuza/3995097 to your computer and use it in GitHub Desktop.
Javascript Class
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
/*jshint browser:true, jquery:true, undef:true, devel:true, unused:false, curly:true, strict:true, | |
noarg:true, noempty:true, eqeqeq:true, bitwise:true, quotmark:true, indent:2, maxerr:50 */ | |
/*global window:true */ | |
/** | |
Global Class collection with a class(klass) object with private and public variables/methods without using this. | |
@author John Doe | |
@namespace classLib | |
*/ | |
(function (window) { | |
'use strict'; | |
var classLib = window.classLib || {}; | |
/** | |
@class klass | |
@namespace classLib | |
*/ | |
classLib.klass = function () { | |
/* Private variables */ | |
var _foo, _bar; | |
_foo = 'foo'; | |
_bar = 'bar'; | |
/*-------------------------------------------------------*/ | |
/* Private functions */ | |
var _privateFunc = function () { | |
_foo = _bar; | |
}; | |
return { | |
/* Public functions */ | |
init: function () { | |
privateFunc(); | |
}, | |
getFoo: function () { | |
return _foo; | |
}, | |
setFoo: function (value) { | |
_foo = value || _foo; | |
} | |
}; | |
}(); | |
// Expose klass to the global object | |
window.classLib = classLib; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment