var notificationTimer;

function showCartNotification(message)
{
    clearTimeout(notificationTimer);
    
    $('.cart-box-notification').html(message).fadeIn(400);
    
    /*notificationTimer = setTimeout(function(){
       hideCartNotification();
    }, 5000);*/
}

function hideCartNotification()
{
    $('.cart-box-notification').fadeOut(400, function(){
        $(this).html('');
    });
}

/* Обработчик кнопки "Продолжить покупки" */
$('body').on('click', '.explore-catalog', function(){
    hideCartNotification();
});

$('body').on('click', '.cart-box-notification__close', function(){
    hideCartNotification();
});

/* Обработчик кнопки "Удалить" */
$('body').on('click', '.cart-box-notification__item-remove', function(){
    link = $(this);
    order_id = $(this).data('id');

    if (link.hasClass('-inactive')) {
        return;
    }

    link.addClass('-inactive');

    $.ajax({
        url: '/cart/cart/removeOrderFromCart',
        type: 'GET',
        data: {
            'order_id': order_id,
        },
        dataType: 'json',
        success: function(response) {
            update_cart(response);

            hideCartNotification();
        },
        complete: function() {
            link.removeClass('-inactive');
        }
    });
});