callback.js 1.76 KB

$(document).ready(function()
{
    $('[data-toggle="popover"]').popover();

    $('body').on('click', function (e)
    {
        $('[data-toggle="popover"]').each(function ()
        {
            //the 'is' for buttons that trigger popups
            //the 'has' for icons within a button that triggers a popup
            if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
                $(this).popover('hide');
            }
        });
    });

    $('#callback .btn.read').on('click', function (e)
    {
        var $obj = $(this).closest('tr');

        callbackAction ({
            'json': {
                'jaction': 'getOne',
                'callback_id': $obj.attr('callback_id'),
            }
        }).done(function ($result)
        {
            modalBoxLoad($result.text);
        });
    });

    $(document).on('click', '#callback .status .dropdown-menu li a', function(e)
    {
        e.preventDefault();

        var $obj = $(this).closest('tr');
        var $callback_status_id = $(this).attr('value');

        callbackAction ({
            'json': {
                'jaction': 'setStatus',
                'callback_id': $obj.attr('callback_id'),
                'callback_status_id': $callback_status_id,
            }
        }).done(function ($result)
        {
            // done
            // $obj.addClass('done');
            if ($result.code == 0)
            {
                $obj.find('.manager').html($result.manager);
                $obj.find('.date_edit').html($result.date_edit);
                $obj.find('.status').html($result.button);
            }
            else if ($result.code == 1)
            {
                modalBoxLoad($result.html);
            }
        });

    });
});