-
-
Save jazzsequence/b3c3d3c04c564459c0f774026025bbe5 to your computer and use it in GitHub Desktop.
WDS Javascript Style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Foo Script. | |
*/ | |
window.Foo_Object = {}; | |
( function( window, $, plugin ) { | |
// Private variable. | |
var fooVariable = 'foo'; | |
// Constructor. | |
plugin.init = function() { | |
plugin.cache(); | |
if ( plugin.meetsRequirements ) { | |
plugin.bindEvents(); | |
} | |
}; | |
// Cache all the things. | |
plugin.cache = function() { | |
plugin.$c = { | |
window: $(window), | |
fooSelector: $( '.foo' ), | |
}; | |
}; | |
// Combine all events. | |
plugin.bindEvents = function() { | |
plugin.$c.window.on( 'load', plugin.doFoo ); | |
}; | |
// Do we meet the requirements? | |
plugin.meetsRequirements = function() { | |
return plugin.$c.fooSelector.length; | |
}; | |
// Some function. | |
plugin.doFoo = function() { | |
// do stuff | |
}; | |
// Engage! | |
$( plugin.init ); | |
})( window, jQuery, window.Foo_Object ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment