$(function()
{
    /* Make cards clickable. */
    /*$('#mainContent').on('click', '.project-card', function(e)
    {
        if($(e.target).closest('.project-actions,[data-toggle],.btn,a').length) return;
        window.location.href = $(this).data('url');
    });
    */

    $('.switchButton').click(function()
    {
        var datasourceType = $(this).attr('data-type');
        $.cookie('datasourceType', datasourceType, {expires:config.cookieLife, path:config.webRoot});
        window.location.reload();
    });

    $('.user-info').children('.avatar').addClass('avatar-shadow avatar-margin');

    var zdex = 99;
    datasourceList.forEach(function(datasource,index) {
        var id = datasource.id;
        $('#datasource' + id).children('.avatar').each(function() {
            $(this).css("z-index", zdex);
            zdex --;
        });

        $('#datasource' + id).children('.avatar').first().addClass("avatar-border");
        $('#datasource' + id).children('.avatar').first().find('span').addClass("avatar-span");
        $('#datasource' + id).children('.avatar').first().removeClass('avatar-shadow');
    });
});

/**
 * Close menu.
 *
 * @param  obj $obj
 * @access public
 * @return void
 */
function closeMenu(obj)
{
    $(obj).find('.project-actions .dropdown').removeClass('open');
}
