forked from chuanxshi/javascript-patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextend.html
52 lines (39 loc) · 1.21 KB
/
extend.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!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>