Object-oriented JavaScript template

This template make use of OOP techniques to encapsulate functionalities, producing reusable components.

define([ 'jquery' ], function ( $ ) {
    'use strict';

    var example = function ( $el, options ) {
        this.$el = $el;
        this.defaults = {
            selectors: {
            },
            classes: {
                hidden: 'hidden',
                active: 'active'
            }
        };

        this.settings = $.extend( {}, this.defaults, options );
    };

    Example.prototype = {
        init: function () {

            // Only apply if initialisation has been done outside
            // of the each loop in main.js
            if ( !this.$el.length ) {
                return false;
            }

            this.bindEvents();

            return this;
        },

        bindEvents: function () {
            this.$el.on( 'click', this.handleActive );
            this.$el.on( 'keydown', this.handleKeydown );
        },

        handleActive: function () {
        },

        handleKeydown: function () {
        }
    };

    return example;
});