HEX
Server: Apache/2
System: Linux server-27-254-144-72.da.direct 5.10.0-33-amd64 #1 SMP Debian 5.10.226-1 (2024-10-03) x86_64
User: pokaorgani (1114)
PHP: 8.1.33
Disabled: exec,system,passthru,shell_exec,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/pokaorgani/public_html/wp-content/plugins/so-widgets-bundle/base/inc/fields/js/tabs-field.js
/* global jQuery, soWidgets */

( function( $ ) {

	const setupTabsField = function( e ) {
		const $field = $( this );

		if ( $field.data( 'initialized' ) ) {
			return;
		}

		const $items = $field.find( '.siteorigin-widget-tabs > li' );
		if ( $items.length == 1 ) {
			// There's only one tab. Show the linked section as a standard tab.
			$( '.siteorigin-widget-field-' + $items.data( 'id' ) ).find( '> .siteorigin-widget-field-label ' ).removeClass( 'siteorigin-widget-section-tab' );
		} else {
			$items.on( 'click', function( e ) {
				const $$ = $( this );
				e.preventDefault();
				if ( ! $$.hasClass( 'sow-active-tab' ) ) {
					$( '.sow-active-tab' ).removeClass( 'sow-active-tab' );
					$( '.siteorigin-widget-field-' + $$.data( 'id' ) ).find( '> .siteorigin-widget-section' ).addClass( 'sow-active-tab' );
					$$.addClass( 'sow-active-tab' );
				}
			} );
			$items.first().trigger( 'click' );

		}


		$field.data( 'initialized', true );
	};

	 // If the current page isn't the site editor, set up the Tabs field now.
	 if (
		 window.top === window.self &&
		 (
			 typeof pagenow === 'string' &&
			 pagenow !== 'site-editor'
		 )
	 ) {
		 $( document ).on( 'sowsetupformfield', '.siteorigin-widget-field-type-tabs', setupTabsField );
	 }

		// Add support for the Site Editor.
	window.addEventListener( 'message', function( e ) {
		if ( e.data && e.data.action === 'sowbBlockFormInit' ) {
			$( '.siteorigin-widget-field-type-tabs' ).each( function() {
				setupTabsField.call( this );
			} );
		}
	} );

} )( jQuery );