Код взят из статьи с сайта Хабрахабр. Там же можно посмотреть и подробное описание паттернов.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
;(function ( $, window, document, undefined ) {
var pluginName = 'defaultPluginName',
defaults = {
propertyName: "value"
};
function Plugin( element, options ) {
this.element = element;
this.options = $.extend( {}, defaults, options) ;
this._defaults = defaults;
this._name = pluginName;
this.init();
}
Plugin.prototype.init = function () {
};
$.fn[pluginName] = function ( options ) {
return this.each(function () {
if (!$.data(this, 'plugin_' + pluginName)) {
$.data(this, 'plugin_' + pluginName,
new Plugin( this, options ));
}
});
}
})( jQuery, window, document );