Permalink
Find file
f4561c1 Apr 3, 2012
@StevenBlack @shichuan
52 lines (39 sloc) 1.21 KB
<!doctype html>
<html lang="en">
<head>
<title>JavaScript Patterns</title>
<meta charset="utf-8">
</head>
<body>
<script>
/*!
* jQuery extend-based plugin boilerplate
* Author: @oscargodson
* Further changes: @timmywil
* Licensed under the MIT license
*/
/*
As you'll notice below, we're making use of $.fn.extend to create our plugin rather
than opting for $.fn.pluginname. This type of structure may be useful if you need
to add a relatively large number of methods to your plugin. There are however alternatives
to this that may be better suited, including Alex Sexton's prototypal inheritence pattern
which is also included in this repo.
*/
// the semi colon before function invocation is a safety net against concatenated
// scripts and/or other plugins which may not be closed properly.
;( function( $ ){
$.fn.extend( {
pluginname: function( options ) {
this.defaults = {};
var settings = $.extend( {}, this.defaults, options );
return this.each( function() {
var $this = $( this );
});
}
});
})( jQuery );
// References
// Essential jQuery Plugin Patterns (by Addy Osmani) - http://goo.gl/oE0ge
</script>
</body>
</html>