Skip to content

Instantly share code, notes, and snippets.

@zolitch
Created April 26, 2013 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zolitch/5466049 to your computer and use it in GitHub Desktop.
Save zolitch/5466049 to your computer and use it in GitHub Desktop.
UMD module skeleton
/*jshint laxcomma : true */
var BaseModuleConstructor
, NewClass = require('./newclass')
, _newClassInstance
, $ = $ || window.jQuery
;
BaseModuleConstructor = function BaseModuleConstructor( element, template )
{
var BaseModuleConstructor
, _element = $(element)
;
BaseModuleConstructor = function BaseModuleConstructor()
{
//Initiation in here
_newClassInstance = new NewClass();
};
BaseModuleConstructor.prototype.method = function( data )
{
var blah;
//blah method stuff in here
};
// getter setter to expose public variables that cannot be over written
Object.defineProperties(BaseModuleConstructor.prototype, {
'newClassInstance' : {
get : function() {
return _newClassInstance;
}
}
});
function privateFunction( shitPassedIn )
{
console.log('shitPassedIn: ' + shitPassedIn);
}
return new BaseModuleConstructor();
};
//Public method not on prototype
BaseModuleConstructor.attach = function( element, shitPassedIn )
{
var tmpl
, blah = element
;
privateFunction.call(this, shitPassedIn);
};
BaseModuleConstructor.Events = events = {
LOADED : 'loaded'
};
module.exports = BaseModuleConstructor;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment