HEX
Server:
System: Linux aac286ea486c 5.14.0-687.15.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jun 11 08:51:45 EDT 2026 x86_64
User: root (0)
PHP: 8.2.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,disk_free_space,diskfreespace
Upload Files
File: /dom877180/wp-content/plugins/gravityformsuserregistration/js/widget_editor.js
( function( $ ) {
	
	$( document ).ready( function() {

		// Toggle editor tabs.
		$( document ).on( 'click', '.gf_login_widget_editor .tabs a', function( e ) {
		
			e.preventDefault();
			
			// Get target tab.
			var widgetForm = $( this ).parent().parent(),
				tabsNav = $( this ).parent(),
				targetTab = $( this ).attr( 'data-tab' );
				
			// Switch active tab class.
			tabsNav.find( 'a' ).removeClass( 'active' );
			$( this ).addClass( 'active' );
			
			// Switch active tab.
			widgetForm.find( '.tab-content:not( [data-tab="' + targetTab + '"] )' ).hide();
			widgetForm.find( '.tab-content[data-tab="' + targetTab + '"]' ).show();
			
			// Update active view setting.
			widgetForm.find( 'input[data-type="active_view"]' ).val( targetTab );
		
		} );

		// Add logged in link
		$( document ).on( 'click', '.gf_login_widget_add_link', function( e ) {
			
			e.preventDefault();
			
			var tableElement = $( this ).prev(),
				repeatTemplate = $( 'tr[data-repeater]', tableElement );
			
			/* Remove the new class from the current new row. */
			$( 'tr.new', tableElement ).removeClass( 'new' );
			
			/* Get the index for the new item. */
			var index = 0;
			$( 'tr:not([data-repeater])', tableElement ).each( function() {
				
				var inputName = $( 'td:first-child input', this ).attr( 'data-name' ),
					regex = /\[(\d*)\]/gmi,
					inputIndex = inputName.match( regex )[1];
				
				inputIndex = parseInt( inputIndex.replace( '[', '' ).replace( ']', '' ) );
				
				if ( inputIndex > index ) {
					index = inputIndex;
				}
				
			} );
			index++;
			
			/* Get the HTML for the new row. */
			var newRow = $( '<tr class="new">' + repeatTemplate.html() + '</tr>' );
			
			/* Add the index to each input field. */
			var linkText = $( 'input.link-text', newRow ),
				linkURL = $( 'input.link-url', newRow );
				
			linkText.attr( 'data-name', linkText.attr( 'data-name' ) + '[' + index + '][text]' );
			linkURL.attr( 'data-name', linkURL.attr( 'data-name' ) + '[' + index + '][url]' );
			
			/* Insert the new row before the repeater row. */
			newRow.insertBefore( repeatTemplate );
			
			update_widget_links( tableElement );
			
		} );

		// Delete logged in link
		$( document ).on( 'click', '.gf_login_widget_links a[data-action="delete-link"]', function( e ) {
			
			e.preventDefault();
			
			var linkRow = $( this ).closest( 'tr' ),
				tableElement = $( this ).closest( 'table' );
						
			linkRow.remove();
			
			if ( $( 'tr:not([data-repeater])', tableElement ).length === 0 ) {
				tableElement.next().click();
			}
			
			update_widget_links( tableElement );
			
		} );

		// Update logged in links when input changes
		$( document ).on( 'change', '.gf_login_widget_links input', function() { 
			
			update_widget_links( $( this ).closest( 'table' ) );
			
		} );

		// Toggle custom Registration links inputs
		$( document ).on( 'change', '.gf_login_widget_registrationpage', function() { 
						
			if ( $( this ).val() === 'custom' ) {
				$( this ).next( 'table' ).show();
			} else {
				$( this ).next( 'table' ).hide();
			}
			
		} );

		// Push logged in links to hidden input element
		function update_widget_links( table ) {
			
			var links = [],
				jsonContainer = table.prev();
			
			$( 'tr:not([data-repeater])', table ).each( function() {
				
				$( 'input', this ).each( function() {
				
					var name = $( this ).attr( 'data-name' ),
						explodedName = name.split( /[[\]]{1,2}/ );
					
					if ( links[ explodedName[3] ] === undefined ) {
						links[ explodedName[3] ] = {};
					}
					
					links[ explodedName[3] ][ explodedName[4] ] = $( this ).val();
				
				} );
				
			} );
			
			jsonContainer.val( JSON.stringify( links ) ).trigger( 'change' );
			
		}
		
	} );
	
} )( jQuery );