Skip to content

Instantly share code, notes, and snippets.

@colorful-tones
Forked from gregrickaby/wdsjQuery.js
Created February 10, 2016 18:07
Show Gist options
  • Save colorful-tones/d8a1f90efef90d4e637d to your computer and use it in GitHub Desktop.
Save colorful-tones/d8a1f90efef90d4e637d to your computer and use it in GitHub Desktop.
WDS Javascript Style
/**
* Foo Script.
*/
window.Foo_Object = {};
( function( window, $, that ) {
// Private variable.
var fooVariable = 'foo';
// Constructor.
that.init = function() {
that.cache();
if ( that.meetsRequirements ) {
that.bindEvents();
}
};
// Cache all the things.
that.cache = function() {
that.$c = {
window: $(window),
fooSelector: $( '.foo' ),
};
};
// Combine all events.
that.bindEvents = function() {
that.$c.window.on( 'load', that.doFoo );
};
// Do we meet the requirements?
that.meetsRequirements = function() {
return that.$c.fooSelector.length;
};
// Some function.
that.doFoo = function() {
// do stuff
};
// Engage!
$( that.init );
})( window, jQuery, window.Foo_Object );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment