Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WDS Javascript Style
/**
* file: wdsjQuery.js
*
* Handle Foo things for the foo theme.
*/
window.wdsFoo = {};
( function( window, $, app ) {
// Private variable.
var fooVariable = 'foo';
// Constructor.
app.init = function() {
app.cache();
if ( app.meetsRequirements() ) {
app.bindEvents();
}
};
// Cache all the things.
app.cache = function() {
app.$c = {
window: $( window ),
fooSelector: $( '.foo' )
};
};
// Combine all events.
app.bindEvents = function() {
app.$c.window.on( 'load', app.doFoo );
};
// Do we meet the requirements?
app.meetsRequirements = function() {
return app.$c.fooSelector.length;
};
// Some function.
app.doFoo = function() {
// do stuff.
};
// Engage!
$( app.init );
})( window, jQuery, window.wdsFoo );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.