Old school way of creating classes in JavaScript
if(!my) var my={};
if(!my.namespace) my.namespace={};
//******************************************************************************
//** ClassName
//******************************************************************************
/**
* Instances of this class are invoked using a DOM element (el) and a config.
*
* var myClass = new my.namespace.ClassName(el, {});
* myClass.doSomething();
*
******************************************************************************/
my.namespace.ClassName = function(parent, config) {
var me = this;
var defaultConfig = {
style: {}
};
//**************************************************************************
//** Constructor
//**************************************************************************
var init = function(){
var div = document.createElement('div');
parent.appendChild(div);
me.el = div;
};
//**************************************************************************
//** doSomething
//**************************************************************************
/** An example of a public method
*/
this.doSomething = function(){
//call a private method in this class
doSomething();
};
//**************************************************************************
//** doSomething
//**************************************************************************
/** An example of a private method
*/
var doSomething = function(){
//call a public method in this class
me.doSomething();
};
init();
};