Skip to content

Instantly share code, notes, and snippets.

@garciamax
Last active August 29, 2015 13:58
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save garciamax/10231455 to your computer and use it in GitHub Desktop.
Save garciamax/10231455 to your computer and use it in GitHub Desktop.
Plugin Starter
(function( $ ) {//my scope
var _obj = {},//container for plugin
_appName = 'MYDEFAULTPLUGINNAME';//will be visible in global scope, use unique name
_obj[_appName] = window[_appName] = new function(){//exposing to global scope
var _ = {//private methods
defaults:{},
settings:{},
l:function(severity, message) {
var _args = Array.prototype.slice.apply(arguments);
console[severity](_appName + ' :: ' + _args.slice(1, 2), _args.slice(2));
}
};
return {//public methods
init:function(settings){
_.settings = $.extend(_.defaults,settings||{});
_.l('log','init')
}
}
};
_obj[_appName].init();//tada
})( jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment