Skip to content

Instantly share code, notes, and snippets.

@vergissberlin
Last active August 29, 2015 14: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 vergissberlin/c26076d39469ca4829a6 to your computer and use it in GitHub Desktop.
Save vergissberlin/c26076d39469ca4829a6 to your computer and use it in GitHub Desktop.
JavaScript: Scaffold for jQuery plugin programming.
/**
* jQuery Plugin
*
* @category JavaScript
* @package PROJECT
* @author Excellent Developer <excellent.developer@netresearch.de>
* @license https://netresearch.de/license
* @version 0.0.1
* requires jquery 2.1.1
*/
(function ($, window, document) {
$.fn.myPlugin = function(options) {
var helper, handler, def, conf;
// Configuration with defaults
conf = {
// Switches
showSomething: false,
// Templates
};
conf = $.extend(settings, options );
// Default configuration
def = {
$self: $(this),
$window: $(window),
$document: $(document)
};
helper = {
calculateSomething: function(value) {
return value + value;
}
}
handler = {
/**
* Constructor
*/
init: function() {
// return self for chaining
return this;
}
}
// Call constructor
handler.init();
};
}( jQuery, window, document ));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment