HEX
Server: LiteSpeed
System: Linux pulsar191.sitesanctuary.org 5.14.0-284.30.1.el9.tuxcare.els9.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jan 10 17:34:05 UTC 2025 x86_64
User: lgooir (1604)
PHP: 8.1.32
Disabled: exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/lgooir/.trash/rising-bamboo/inc/cmb2/custom_fields/tabs/js/tabs.js
(function($) {
    // Initial check
    if( $('.cmb-tabs').length ) {
        $('.cmb-tabs').each(function() {
            // Activate first tab
            if( ! $(this).find('.cmb-tab.active').length ) {
                $(this).find('.cmb-tab').first().addClass('active');

                $($(this).find('.cmb-tab').first().data('fields')).addClass('cmb-tab-active-item');
                
                // Support for groups and repeatable fields
                $($(this).find('.cmb-tab').first().data('fields')).find('.cmb-repeat .cmb-row, .cmb-repeatable-group .cmb-row').addClass('cmb-tab-active-item');
            }
        });
    }

    $('body').on('click.cmbTabs', '.cmb-tabs .cmb-tab', function(e) {
        var tab = $(this);

        if( ! tab.hasClass('active') ) {
            var tabs = tab.closest('.cmb-tabs');
            var form = tabs.next('.cmb2-wrap');

            // Hide current active tab fields
            form.find(tabs.find('.cmb-tab.active').data('fields')).fadeOut('fast', function() {
                $(this).removeClass('cmb-tab-active-item');

                form.find(tab.data('fields')).fadeIn('fast', function() {
                    $(this).addClass('cmb-tab-active-item');

                    // Support for groups and repeatable fields
                    $(this).find('.cmb-repeat-table .cmb-row, .cmb-repeatable-group .cmb-row').addClass('cmb-tab-active-item');
                });
            });

            // Update tab active class
            tabs.find('.cmb-tab.active').removeClass('active');
            tab.addClass('active');
        }
    });
   
    // Adding a new group element needs to get the active class also
    $('body').on('click', '.cmb-add-group-row', function() {
        $(this).closest('.cmb-repeatable-group').find('.cmb-row').addClass('cmb-tab-active-item');
    });

    // Adding a new repeatable element needs to get the active class also
    $('body').on('click', '.cmb-add-row-button', function() {
        $(this).closest('.cmb-repeat').find('.cmb-row').addClass('cmb-tab-active-item');
    });

    // Initialize on widgets area
    $(document).on('widget-updated widget-added', function(e, widget) {

        if( widget.find('.cmb-tabs').length ) {

            widget.find('.cmb-tabs').each(function() {
                // Activate first tab
                if( ! $(this).find('.cmb-tab.active').length ) {
                    $(this).find('.cmb-tab').first().addClass('active');

                    $($(this).find('.cmb-tab').first().data('fields')).addClass('cmb-tab-active-item');

                    // Support for groups and repeatable fields
                    $($(this).find('.cmb-tab').first().data('fields')).find('.cmb-repeat .cmb-row, .cmb-repeatable-group .cmb-row').addClass('cmb-tab-active-item');
                }
            });

        }

    });
    
})(jQuery);