| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e53a5be commit d34a297
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,32 +17,32 @@ | |||
| 17 | 17 | As you'll notice below, we're making use of $.fn.extend to create our plugin rather | |
| 18 | 18 | than opting for $.fn.pluginname. This type of structure may be useful if you need | |
| 19 | 19 | to add a relatively large number of methods to your plugin. There are however alternatives | |
| 20 | - to this that may be better suited, including Alex Sexton's prototypal inheritence pattern | ||
| 21 | - which is also included in this repo. | ||
| 20 | + to this that may be better suited, including Alex Sexton's prototypal inheritence pattern | ||
| 21 | + which is also included in this repo. | ||
| 22 | 22 | */ | |
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | - //the semi colon before function invocation is a safety net against concatenated | ||
| 26 | - //scripts and/or other plugins which may not be closed properly. | ||
| 27 | - ;(function($){ | ||
| 28 | - $.fn.extend({ | ||
| 29 | - pluginname: function( options ) { | ||
| 25 | + // the semi colon before function invocation is a safety net against concatenated | ||
| 26 | + // scripts and/or other plugins which may not be closed properly. | ||
| 27 | + ;( function( $ ){ | ||
| 28 | + $.fn.extend( { | ||
| 29 | + pluginname: function( options ) { | ||
| 30 | 30 | ||
| 31 | - this.defaultOptions = {}; | ||
| 31 | + this.defaultOptions = {}; | ||
| 32 | 32 | ||
| 33 | - var settings = $.extend({}, this.defaultOptions, options); | ||
| 33 | + var settings = $.extend( {}, this.defaultOptions, options ); | ||
| 34 | 34 | ||
| 35 | - return this.each(function() { | ||
| 35 | + return this.each( function() { | ||
| 36 | 36 | ||
| 37 | - var $this = $(this); | ||
| 37 | + var $this = $( this ); | ||
| 38 | 38 | ||
| 39 | - }); | ||
| 39 | + }); | ||
| 40 | 40 | ||
| 41 | - } | ||
| 42 | - | ||
| 43 | - }); | ||
| 41 | + } | ||
| 44 | 42 | ||
| 45 | - })(jQuery); | ||
| 43 | + }); | ||
| 44 | + | ||
| 45 | + })( jQuery ); | ||
| 46 | 46 | ||
| 47 | 47 | ||
| 48 | 48 | // References | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,52 +14,52 @@ | |||
| 14 | 14 | */ | |
| 15 | 15 | ||
| 16 | 16 | ;(function ( $ ) { | |
| 17 | - if (!$.myNamespace) { | ||
| 18 | - $.myNamespace = {}; | ||
| 19 | - }; | ||
| 20 | - | ||
| 21 | - $.myNamespace.myPluginName = function ( el, myFunctionParam, options ) { | ||
| 22 | - // To avoid scope issues, use 'base' instead of 'this' | ||
| 23 | - // to reference this class from internal events and functions. | ||
| 24 | - var base = this; | ||
| 25 | - | ||
| 26 | - // Access to jQuery and DOM versions of element | ||
| 27 | - base.$el = $(el); | ||
| 28 | - base.el = el; | ||
| 29 | - | ||
| 30 | - // Add a reverse reference to the DOM object | ||
| 31 | - base.$el.data( "myNamespace.myPluginName" , base ); | ||
| 32 | - | ||
| 33 | - base.init = function () { | ||
| 34 | - base.myFunctionParam = myFunctionParam; | ||
| 35 | - | ||
| 36 | - base.options = $.extend({}, | ||
| 37 | - $.myNamespace.myPluginName.defaultOptions, options); | ||
| 38 | - | ||
| 39 | - // Put your initialization code here | ||
| 40 | - }; | ||
| 41 | - | ||
| 42 | - // Sample Function, Uncomment to use | ||
| 43 | - // base.functionName = function( paramaters ){ | ||
| 44 | - // | ||
| 45 | - // }; | ||
| 46 | - // Run initializer | ||
| 47 | - base.init(); | ||
| 48 | - }; | ||
| 49 | - | ||
| 50 | - $.myNamespace.myPluginName.defaultOptions = { | ||
| 51 | - myDefaultValue: "" | ||
| 52 | - }; | ||
| 53 | - | ||
| 54 | - $.fn.mynamespace_myPluginName = function | ||
| 55 | - ( myFunctionParam, options ) { | ||
| 56 | - return this.each(function () { | ||
| 57 | - (new $.myNamespace.myPluginName(this, | ||
| 58 | - myFunctionParam, options)); | ||
| 59 | - }); | ||
| 60 | - }; | ||
| 61 | - | ||
| 62 | - })( jQuery ); | ||
| 17 | + if ( ! $.myNamespace ) { | ||
| 18 | + $.myNamespace = {}; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + $.myNamespace.myPluginName = function ( el, myFunctionParam, options ) { | ||
| 22 | + | ||
| 23 | + // To avoid scope issues, use 'base' instead of 'this' | ||
| 24 | + // to reference this class from internal events and functions. | ||
| 25 | + var base = this; | ||
| 26 | + | ||
| 27 | + // Access to jQuery and DOM versions of element | ||
| 28 | + base.$el = $( el ); | ||
| 29 | + base.el = el; | ||
| 30 | + | ||
| 31 | + // Add a reverse reference to the DOM object | ||
| 32 | + base.$el.data( "myNamespace.myPluginName" , base ); | ||
| 33 | + | ||
| 34 | + base.init = function () { | ||
| 35 | + base.myFunctionParam = myFunctionParam; | ||
| 36 | + | ||
| 37 | + base.options = $.extend( {}, $.myNamespace.myPluginName.defaultOptions, options ); | ||
| 38 | + | ||
| 39 | + // Put your initialization code here | ||
| 40 | + | ||
| 41 | + }; | ||
| 42 | + | ||
| 43 | + // Sample Function, Uncomment to use | ||
| 44 | + // base.functionName = function( paramaters ){ | ||
| 45 | + // | ||
| 46 | + // }; | ||
| 47 | + | ||
| 48 | + // Run initializer | ||
| 49 | + base.init(); | ||
| 50 | + }; | ||
| 51 | + | ||
| 52 | + $.myNamespace.myPluginName.defaultOptions = { | ||
| 53 | + myDefaultValue: "" | ||
| 54 | + }; | ||
| 55 | + | ||
| 56 | + $.fn.mynamespace_myPluginName = function( myFunctionParam, options ) { | ||
| 57 | + return this.each( function () { | ||
| 58 | + ( new $.myNamespace.myPluginName( this, myFunctionParam, options ) ); | ||
| 59 | + }); | ||
| 60 | + }; | ||
| 61 | + | ||
| 62 | + } )( jQuery ); | ||
| 63 | 63 | ||
| 64 | 64 | ||
| 65 | 65 | // References | |
| Back | FazBrowse Home | New Git URL |
0 commit comments