$(document).ready(function()
{
    //var setHeight = '35';
    var setHeight = 29;
    $('.user-list').each(function()
    {
        var height = $(this).children(':first').height();
        $(this).children(':first').css('height', setHeight + 'px');
        var thisHeight = $(this).height(); 
        $(this).children(':first').css('height', '');
        if(height > thisHeight + 1)
        {
            $(this).children(':first').css('height', thisHeight + 'px');
            $(this).children('a:first').show();
        }
    })
    $('.more-list').click(function()
    {
        $(this).parent().children(':first').css('height', '')
        $(this).hide();
        $(this).prev().children('a:first').show();
    })
    $('.hide-list').click(function()
    {
        var thisHeight = $(this).parent().next().css('margin-top');
        thisHeight = parseInt(thisHeight) + 29;
        $(this).parent().css('height', thisHeight + 'px');
        $(this).hide();
        $(this).parent().next().show();
    })

    $('#groupList').on('sort.sortable', function(e, data)
    {
        const orderStart = v.pageID > 1 ? (v.recPerPage * (v.pageID - 1)) + 1 : 1;
        Object.keys(data.orders).forEach(function(key){
            data.orders[key] += orderStart;
        });
        $.post(createLink('group', 'sort'), {groups: data.orders}, function(response)
        {
            if(response.result == 'success')
            {
                return location.reload();
            }
            else
            {
                bootbox.alert(response.message);
            }
        }, 'json');
    });
})
