{"size": 843, "ext": "js", "max_stars_repo_path": "src/main.js", "max_stars_repo_name": "elr-utilities/drm-dropdown-buttons", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/main.js", "max_issues_repo_name": "elr-utilities/drm-dropdown-buttons", "max_issues_repo_issues_event_min_datetime": "2019-02-13T20:54:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-02-21T10:27:37.000Z", "max_forks_repo_path": "src/main.js", "max_forks_repo_name": "Beth3346/elr-dropdown-buttons", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 29.0689655172, "max_line_length": 93, "alphanum_fraction": 0.5421115065}
const $ = require('jquery');

const elrDropdownButton = function({
    buttonClass = 'elr-dropdown-button',
    activeClass = 'clicked',
    activeListClass = 'active-list'
} = {}) {
    const $button = $(`.${buttonClass}`);

    if ($button.length) {
        $button.on('click', function(e) {
            e.preventDefault();

            const $openButtons = $(`ul.elr-dropdown-list.${activeListClass}`).prev('button');
            const $button = $(this);
            const $menu = $button.next('ul');

            if (!$button.hasClass(activeClass)) {
                $button.addClass(activeClass);
                $menu.addClass(activeListClass);
            } else {
                $button.removeClass(activeClass);
                $menu.removeClass(activeListClass);
            }
        });
    }
};

export default elrDropdownButton;