summaryrefslogtreecommitdiffstats
path: root/theme/javascript/utils/dropdown.js
blob: fe4e1f4365bdbc1a850f80ada5631f4cd5ab5d21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
define([
    "jQuery"
], function($) {

    var toggleDropdown = function(e) {
        var $dropdown = $(e.currentTarget).parent().find(".dropdown-menu");

        $dropdown.toggleClass("open");
        e.stopPropagation();
        e.preventDefault();
    };

    var closeDropdown = function(e) {
        $(".dropdown-menu").removeClass("open");
    };

    // Bind all dropdown
    var init = function() {
        $(document).on('click', ".toggle-dropdown", toggleDropdown);
        $(document).on('click', ".dropdown-menu", function(e){ e.stopPropagation(); });
        $(document).on("click", closeDropdown);
    };

    return {
        init: init
    };
});