Skip to content

Instantly share code, notes, and snippets.

@jazzsequence
Forked from gregrickaby/wdsjQuery.js
Last active August 29, 2016 18:42
Show Gist options
  • Save jazzsequence/b3c3d3c04c564459c0f774026025bbe5 to your computer and use it in GitHub Desktop.
Save jazzsequence/b3c3d3c04c564459c0f774026025bbe5 to your computer and use it in GitHub Desktop.
WDS Javascript Style
/**
* 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