Skip to content

Instantly share code, notes, and snippets.

@stormwild
Last active January 7, 2016 10:01
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 stormwild/4518404 to your computer and use it in GitHub Desktop.
Save stormwild/4518404 to your computer and use it in GitHub Desktop.
/**
 *@namesomeFunction
 *@authorkfb
 *
 *Basicusage:
 * var someFunction = new SomeFunction();
 * someFunction.init();
 *
 * additionally you can use methods like someFunction.methodName();
 *
 * Advancedusage:
   var someFunction = new SomeFunction({
     "additionalOption":"thatCanOvervriteDefaults"
   });
*/
function SomeFunction(opts){
  var_cfg;
  var_root;

  //defining defaults and extending/overwriting it with inputted parameters
  this.config = $.extend({
    "someOption":"somevalue"
  }, opts);

  /*
  INITIALIZE
  */
  this.init = function(){
    //assign_rootandconfigvariables
    _root = this;
    _cfg = this.config;

    //somecode
  }
  
/*
SomePrivateMethod(no"this")
*/
_somePrivateMethod = function(){
  //somecode
}

/*
SomeMethod
*/
this.someMethod = function(){
  //somecode
  }
  
}

//declaration and auto initialization of someFunction
var someFunction = new SomeFunction();
someFunction.init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment