Created
July 2, 2013 16:59
-
-
Save DavidCarcamo/5911084 to your computer and use it in GitHub Desktop.
Singleton
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
/** | |
* Creates a single instance of ClassName. | |
* @author Author Name | |
* | |
* @constructor | |
* @this {ClassName} | |
* @param {object} The settings for this class. | |
* @version v.0.0.1 | |
*/ | |
// JSLint | |
/*global | |
VarName1:false, | |
varName2:false | |
*/ | |
var ClassName = function(){ | |
var constructor = function(settings){ | |
// SETUP | |
var _this = this; | |
var defaults; | |
// merge settings | |
defaults = {}; | |
settings = _.extend(settings || {}, defaults); | |
// DOM cache | |
var elms = {}; | |
// Private property | |
var template = '<div class="domClass"></div>'; | |
// METHODS | |
/** | |
* A public privilaged method. | |
* | |
* @this {ClassName} | |
*/ | |
_this.publicPrivilaged = function(){ | |
}; | |
/** | |
* A private method. | |
* | |
* @this {ClassName} | |
*/ | |
var private = function(){ | |
}; | |
// Overwrite so only one instance can ever be created | |
constructor = function(){ return _this }; | |
}; | |
return constructor; | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment