$(function(){
    $(".expand-row").on("click", function(){
        expandRow($(this));
    });
    $(".drop-menu").on("click", function(){
        dropMenu($(this));
    });

    function expandRow(e){
        var parent = e;
        var row = parent.siblings('.expanded-row').first();
        row.toggle();

        var toggleClass = function(i){
            i.toggleClass('fa-angle-down');
            i.toggleClass('fa-angle-up');
        };

        toggleClass(e.children('i.fa').last());
        toggleClass(e.children('.fa-stack').children('i.fa').last());
    }

    function dropMenu(btn){
        var menuId = btn.attr("data-popup");
        if(null === menuId || undefined === menuId)
            return ;

        var menu = $("#" + menuId);
        menu.toggle();
    }
});
