-
-
Save colorful-tones/d8a1f90efef90d4e637d to your computer and use it in GitHub Desktop.
WDS Javascript Style
This file contains hidden or 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, $, 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