Permalink
Browse files

added better reference to jquery plugin patterns

  • Loading branch information...
1 parent 6dce52d commit f4561c12a4f90f4cff141d757ea3c6c504d1e81b @shichuan committed Apr 3, 2012
@@ -5,6 +5,7 @@
<meta charset="utf-8">
</head>
<body>
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
/*!
* jQuery basic plugin boilerplate
@@ -33,7 +34,7 @@
// References
- // http://coding.smashingmagazine.com/2011/10/11/essential-jquery-plugin-patterns/
+ // Essential jQuery Plugin Patterns (by Addy Osmani) - http://goo.gl/oE0ge
</script>
</body>
</html>
@@ -15,48 +15,48 @@
;(function ( $, window, document, undefined ) {
- $.fn.pluginName = function ( options ) {
+ $.fn.pluginName = function ( options ) {
- // Here's a best practice for overriding 'defaults'
- // with specified options. Note how, rather than a
- // regular options object being passed as the second
- // parameter, we instead refer to $.fn.pluginName.defaults
- // explicitly, merging it with the options passed to the
- // plugin. This allows us to override defaults both
- // globally and on a per-call level.
+ // Here's a best practice for overriding 'defaults'
+ // with specified options. Note how, rather than a
+ // regular defaults object being passed as the second
+ // parameter, we instead refer to $.fn.pluginName.options
+ // explicitly, merging it with the options passed directly
+ // to the plugin. This allows us to override options both
+ // globally and on a per-call level.
- settings = $.extend( {}, $.fn.pluginName.defaults, options );
+ options = $.extend( {}, $.fn.pluginName.options, options );
- return this.each( function () {
+ return this.each(function () {
- var elem = $( this );
+ var elem = $(this);
- });
- };
+ });
+ };
- // Globally overriding options
- // Here are the publicly accessible defaults
- // in case the user doesn't pass-in any or all
- // possible options. The user is given a default
- // experience but can optionally override the values
- // as required.
- // eg. $fn.pluginName.key ='otherval';
+ // Globally overriding options
+ // Here are our publicly accessible default plugin options
+ // that are available in case the user doesn't pass in all
+ // of the values expected. The user is given a default
+ // experience but can also override the values as necessary.
+ // eg. $fn.pluginName.key ='otherval';
- $.fn.pluginName.defaults = {
+ $.fn.pluginName.options = {
- key: "value",
- myMethod: function ( elem, param ) {
+ key: "value",
+ myMethod: function ( elem, param ) {
- // to do: implement myMethod() here
-
- }
- };
+ }
+ };
})( jQuery, window, document );
// References
- // http://coding.smashingmagazine.com/2011/10/11/essential-jquery-plugin-patterns/
+ /*
+ jQuery Pluginization and the accompanying gist (by Ben Alman) - http://goo.gl/1VwfP http://goo.gl/bg63
+ Essential jQuery Plugin Patterns (by Addy Osmani) - http://goo.gl/oE0ge
+ */
</script>
</body>
</html>
@@ -59,7 +59,11 @@
// References
- // http://coding.smashingmagazine.com/2011/10/11/essential-jquery-plugin-patterns/
+ /*
+ Communication Between jQuery UI Widgets (by Benjamin Sternthal) - http://goo.gl/oE0ge
+ Understanding the Publish/Subscribe Pattern for Greater JavaScript Scalability (by Addy Osmani) - http://goo.gl/CU5fC
+ Essential jQuery Plugin Patterns (by Addy Osmani) - http://goo.gl/oE0ge
+ */
</script>
</body>
</html>
@@ -46,7 +46,7 @@
// References
- // http://coding.smashingmagazine.com/2011/10/11/essential-jquery-plugin-patterns/
+ // Essential jQuery Plugin Patterns (by Addy Osmani) - http://goo.gl/oE0ge
</script>
</body>
</html>
@@ -77,7 +77,10 @@
// References
- // http://coding.smashingmagazine.com/2011/10/11/essential-jquery-plugin-patterns/
+ /*
+ Creating Highly Configurable jQuery Plugins (by Mark Dalgleish) - http://goo.gl/1VwfP http://goo.gl/bg63
+ Essential jQuery Plugin Patterns (by Addy Osmani) - http://goo.gl/oE0ge
+ */
</script>
</body>
</html>
@@ -5,6 +5,7 @@
<meta charset="utf-8">
</head>
<body>
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
/*!
* jQuery lightweight plugin boilerplate
@@ -76,7 +77,14 @@
// References
- // http://coding.smashingmagazine.com/2011/10/11/essential-jquery-plugin-patterns/
+ /*
+ Plugins/Authoring (by jQuery) - http://goo.gl/98R9
+ Signs of a poorly written jQuery plugin (by Remy Sharp) - http://goo.gl/5RNI
+ How to Create Your Own jQuery Plugin (by Elijah Manor) - http://goo.gl/EoSFq
+ Style in jQuery Plugins and Why it Matters (by "Cowboy" Ben Alman) - http://goo.gl/E7pd0
+ Create Your First jQuery Plugin Part 2 (by Andrew Wirick) - http://goo.gl/IhCYO
+ Essential jQuery Plugin Patterns (by Addy Osmani) - http://goo.gl/oE0ge
+ */
</script>
</body>
</html>
@@ -63,7 +63,13 @@
// References
- // http://coding.smashingmagazine.com/2011/10/11/essential-jquery-plugin-patterns/
+ /*
+ Namespacing in JavaScript (by Angus Croll) - http://goo.gl/eul12
+ Use Your $.fn jQuery Namespace (by Ryan Florence) - http://goo.gl/QQIC6
+ JavaScript Namespacing (by Peter Michaux) - http://goo.gl/24t8N
+ Modules and namespaces in JavaScript (by Axel Rauschmayer) - http://goo.gl/6XuqO
+ Essential jQuery Plugin Patterns (by Addy Osmani) - http://goo.gl/oE0ge
+ */
</script>
</body>
</html>
@@ -5,6 +5,7 @@
<meta charset="utf-8">
</head>
<body>
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
/*!
* jQuery prototypal inheritance plugin boilerplate
@@ -76,7 +77,13 @@
// References
- // http://coding.smashingmagazine.com/2011/10/11/essential-jquery-plugin-patterns/
+ /*
+ Using Inheritance Patterns To Organize Large jQuery Applications (by Alex Sexton) - http://goo.gl/Z4lYz
+ How to Manage Large Applications With jQuery or Whatever (by Alex Sexton) - http://goo.gl/kKWhj
+ Practical Example of the Need for Prototypal Inheritance (by Neeraj Singh) - http://goo.gl/jrzb6
+ Prototypal Inheritance in JavaScript (by Douglas Crockford) - http://goo.gl/TPXqV
+ Essential jQuery Plugin Patterns (by Addy Osmani) - http://goo.gl/oE0ge
+ */
</script>
</body>
</html>
@@ -5,6 +5,7 @@
<meta charset="utf-8">
</head>
<body>
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
/*!
* jQuery UI Widget factory "bridge" plugin boilerplate
@@ -100,7 +101,10 @@
// References
- // http://coding.smashingmagazine.com/2011/10/11/essential-jquery-plugin-patterns/
+ /*
+ Using $.widget.bridge Outside of the Widget Factory (by Eric Hynds) - http://goo.gl/UfPKn
+ Essential jQuery Plugin Patterns (by Addy Osmani) - http://goo.gl/oE0ge
+ */
</script>
</body>
</html>
@@ -5,6 +5,7 @@
<meta charset="utf-8">
</head>
<body>
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
/*!
* jQuery UI Widget-factory plugin boilerplate (for 1.8/9+)
@@ -95,7 +96,13 @@
// References
- // http://coding.smashingmagazine.com/2011/10/11/essential-jquery-plugin-patterns/
+ /*
+ The jQuery UI Widget Factory (by Adam J. Sontag) - http://goo.gl/DLKEt
+ Introduction to Stateful Plugins and the Widget Factory (by Doug Neiner) - http://goo.gl/eTGhP
+ Widget Factory (by Scott González) - http://goo.gl/5qFQG
+ Understanding jQuery UI widgets: A tutorial (by Hacking at 0300) - http://goo.gl/rBhaF
+ Essential jQuery Plugin Patterns (by Addy Osmani) - http://goo.gl/oE0ge
+ */
</script>
</body>
</html>
@@ -107,7 +107,13 @@
// References
- // http://coding.smashingmagazine.com/2011/10/11/essential-jquery-plugin-patterns/
+ /*
+ Using RequireJS with jQuery (by Rebecca Murphey) - http://goo.gl/jpX31
+ Fast Modular Code With jQuery and RequireJS (by James Burke) - http://goo.gl/BMEYQ
+ jQuery’s Best Friends (by Alex Sexton) - http://jquerysbestfriends.com/
+ Managing Dependencies With RequireJS (by Ruslan Matveev) - http://goo.gl/zRRT9
+ Essential jQuery Plugin Patterns (by Addy Osmani) - http://goo.gl/oE0ge
+ */
</script>
</body>
</html>

0 comments on commit f4561c1

Please sign in to comment.