
jQuery(function ($) {
    $(window).on('load', function () {
        $('.acf-flexible-content .ui-sortable .layout').each(function () {
            var $this = $(this);

            if ($this.find('.acf-field[data-name="visible"] .acf-switch').hasClass('-on')) {
                $this.removeClass('gray-out');
            } else {
                $this.addClass('gray-out');
            }

            $this.find('.acf-field[data-name="visible"] .acf-switch').on('click', function () {
                if ($(this).hasClass('-on')) {
                    $this.addClass('gray-out');
                } else {
                    $this.removeClass('gray-out');
                }
            })
        });
    });
});