Skip to content

Instantly share code, notes, and snippets.

@jtwalters
Last active April 11, 2016 22:35
Show Gist options
  • Save jtwalters/64abc2c71a0eb421250a to your computer and use it in GitHub Desktop.
Save jtwalters/64abc2c71a0eb421250a to your computer and use it in GitHub Desktop.
/**
* New Tabia/Components JS-pattern.
*/
// Loose augmentation pattern. Creates top-level namespace variable if it
// doesn't already exist.
var Tabia = Tabia || {};
// Create a base for this module's data and functions.
Tabia.myBehavior = {};
// Closure to extend behavior, provide privacy and state.
(function (behavior, $) {
/**
* Private variables
*/
var foo,
bar;
/**
* Public variables
*/
behavior.options = {
foo: 'bar'
};
/**
* DOM-ready callback.
* - DOM element context: this.context
* - Drupal settings object: this.settings
*/
behavior.ready = function ($) {
// Initialize behavior here.
};
})(Tabia.myBehavior, jQuery);
// Initialize Drupal behavior.
Drupal.behave('myBehavior').ready(Tabia.myBehavior.ready);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment