<style>

    .text-wrap{
        white-space: nowrap;
    }

    .text-success-green{
        color: #03cb67;
    }

    .badge{
        padding: 5px;
    }

    .badge .progress{
        margin-bottom:2px;
        margin-top: 2px;
        background-color: #ffdd9c;
    }

    .footable.breakpoint > tbody > tr > td > span.footable-toggle {
        padding-right: 2px;
    }

    .panel-control .nav-tabs > li.disabled:not(.active) {
        background-color: transparent;
        opacity: .2;
    }

    .color-file-size {
        font-size: 11px;
        color: #a5a5a5;
    }

    .collapsed-panel .panel-title {
        font-size: 1.1em;
        font-weight: 500;
    }

    .required_sign {
        color: #a94442;
        margin-left: 3px;
        font-weight: bold;
    }

    .replaces-block {
        border: 1px solid #afb9c3;
        padding: 10px;
    }

    .replaces-block legend {
        font-size: 1.1em;
        display: inline-block;
        width: auto;
        border: 0;
        margin-bottom: 0;

    }

    .tag:not(.label) {
        line-height: 1.1 !important;
        display: inline-block;
    }

    td .tag:not(.label) {
        margin-bottom: 2px !important;
    }

    .replaces-block .tag {
        line-height: 20px !important;
    }

    .replaces-block .tag .btn {
        font-size: 13px;
        padding: 0 5px;
    }

    .replaces-block .tag:hover {
        background-color: #00b6cd30;
    }

</style>
<script type="text/javascript">


    jQuery(document).ready(function () {

        init_toggle_click();
        expanded_assortment();
    });
    function init_toggle_click() {

        let handler = function () {
            let tr = jQuery(this).parent().parent();
            let id = jQuery(this).data('id');
            let trs = jQuery('.parent-' + id).parent().parent();

            if (!tr.hasClass('footable-detail-show')) {


                if (!trs.length) {

                    jQuery.ajax({
                        url: '/_service/shop/catalog/category/' + id,
                        method: "GET",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json"
                    }).done(function (result) {
                        tr.after(result.html);
                        checked_ajax_init(jQuery('.parent-' + id).parent().parent().find('.sw-checked-ajax'));
                        init_toggle_click();
//                        expanded_assortment(tr);
                    }).fail(function () {
                        notify_danger('Ошибка! Не удалось получить данные таблицы');
                    });
                } else {
                    trs.show();
                }
                tr.addClass('footable-detail-show');
                var ob = jQuery.cookie('expand_assortments');
                ob = !ob ? {} : JSON.parse(ob);
                ob[id] = 1;

                jQuery.cookie('expand_assortments', JSON.stringify(ob), {expires: 1, path: '/'});
            } else {

                trs.hide();
                tr.removeClass('footable-detail-show');
                var ob = jQuery.cookie('expand_assortments');
                ob = !ob ? {} : JSON.parse(ob);
                ob[id] = 0;

                jQuery.cookie('expand_assortments', JSON.stringify(ob), {expires: 1, path: '/'});
            }

        };

        jQuery('.footable-toggle').off('click');
        jQuery('.footable-toggle').on('click', handler);
    }
    function expanded_assortment(parent) {

        var parent = !parent ? jQuery('.nifty-table') : parent;
        var ob = jQuery.cookie('expand_assortments');
        ob = !ob ? {} : JSON.parse(ob);
        for (const [key, value] of Object.entries(ob)) {
            if (value === 1) {
                parent.find('[data-id=' + key + ']').click();
            }
        }
    }



</script>