Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Whitespace changes to better conform to jQuery coding standards, remo…

…ved the mix of spaces and tabs, adjusted line spacing in these two files for consistency of conceptual segmentation, and made changes to pass jsHint

The JQuery Core Style Guidelines can be found here: http://docs.jquery.com/JQuery_Core_Style_Guidelines

Adjusted the in-code white-spacing for consistency -- prior to these changes there was no evident standard, or a standard had yet to be enforced.  Chose to adhere to jQuery Core Style Guidelines because students studying jQuery will come across many examples authored by core team members who, on balance, tend towards this standard.

Fixed one minor jsHint-discovered error, an unnecessary semicolon at the end of a function definition.

Stripped-away all trailing spaces on code and blank lines.

By the way, I like your use of the leading semicolon to guard against prior concatenated code.

Signed-off-by: Steven Black <steveb@stevenblack.com>
  • Loading branch information...
commit d34a29720dbac9fd5dd2dfe4cb7e4396b5e77079 1 parent e53a5be
@StevenBlack StevenBlack authored
View
32 jquery-plugin-patterns/extend.html
@@ -17,32 +17,32 @@
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.
+ 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 ) {
+ // 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.defaultOptions = {};
+ this.defaultOptions = {};
- var settings = $.extend({}, this.defaultOptions, options);
+ var settings = $.extend( {}, this.defaultOptions, options );
- return this.each(function() {
+ return this.each( function() {
- var $this = $(this);
+ var $this = $( this );
- });
+ });
- }
-
- });
+ }
- })(jQuery);
+ });
+
+ })( jQuery );
// References
View
92 jquery-plugin-patterns/namespaced-starter.html
@@ -14,52 +14,52 @@
*/
;(function ( $ ) {
- if (!$.myNamespace) {
- $.myNamespace = {};
- };
-
- $.myNamespace.myPluginName = function ( el, myFunctionParam, options ) {
- // To avoid scope issues, use 'base' instead of 'this'
- // to reference this class from internal events and functions.
- var base = this;
-
- // Access to jQuery and DOM versions of element
- base.$el = $(el);
- base.el = el;
-
- // Add a reverse reference to the DOM object
- base.$el.data( "myNamespace.myPluginName" , base );
-
- base.init = function () {
- base.myFunctionParam = myFunctionParam;
-
- base.options = $.extend({},
- $.myNamespace.myPluginName.defaultOptions, options);
-
- // Put your initialization code here
- };
-
- // Sample Function, Uncomment to use
- // base.functionName = function( paramaters ){
- //
- // };
- // Run initializer
- base.init();
- };
-
- $.myNamespace.myPluginName.defaultOptions = {
- myDefaultValue: ""
- };
-
- $.fn.mynamespace_myPluginName = function
- ( myFunctionParam, options ) {
- return this.each(function () {
- (new $.myNamespace.myPluginName(this,
- myFunctionParam, options));
- });
- };
-
- })( jQuery );
+ if ( ! $.myNamespace ) {
+ $.myNamespace = {};
+ }
+
+ $.myNamespace.myPluginName = function ( el, myFunctionParam, options ) {
+
+ // To avoid scope issues, use 'base' instead of 'this'
+ // to reference this class from internal events and functions.
+ var base = this;
+
+ // Access to jQuery and DOM versions of element
+ base.$el = $( el );
+ base.el = el;
+
+ // Add a reverse reference to the DOM object
+ base.$el.data( "myNamespace.myPluginName" , base );
+
+ base.init = function () {
+ base.myFunctionParam = myFunctionParam;
+
+ base.options = $.extend( {}, $.myNamespace.myPluginName.defaultOptions, options );
+
+ // Put your initialization code here
+
+ };
+
+ // Sample Function, Uncomment to use
+ // base.functionName = function( paramaters ){
+ //
+ // };
+
+ // Run initializer
+ base.init();
+ };
+
+ $.myNamespace.myPluginName.defaultOptions = {
+ myDefaultValue: ""
+ };
+
+ $.fn.mynamespace_myPluginName = function( myFunctionParam, options ) {
+ return this.each( function () {
+ ( new $.myNamespace.myPluginName( this, myFunctionParam, options ) );
+ });
+ };
+
+ } )( jQuery );
// References
Please sign in to comment.
Something went wrong with that request. Please try again.