HEX
Server: nginx/1.18.0
System: Linux vcwordpress 5.15.0-174-generic #184-Ubuntu SMP Fri Mar 13 18:41:50 UTC 2026 x86_64
User: root (0)
PHP: 7.4.33
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,pcntl_unshare,
Upload Files
File: /var/www/vcstore.viitorcloud.co/wp-content/plugins/woocommerce-subscriptions/assets/js/modal.js
jQuery( function( $ ) {
	const modals = $( '.wcs-modal' );

	// Resize all open modals on window resize.
	$( window ).on( 'resize', resizeModals );

	// Initialize modals
	$( modals ).each( function() {
		trigger = $( this ).data( 'modal-trigger' );
		$( trigger ).click( { modal: this }, show_modal );
	});

	/**
	 * Displays the modal linked to a click event.
	 *
	 * Attaches all close callbacks and resizes to fit.
	 *
	 * @param {JQuery event} event
	 */
	function show_modal( event ) {
		const modal = $( event.data.modal );

		if ( ! should_show_modal( modal ) ) {
			return;
		}

		// Prevent the trigger element event being triggered.
		event.preventDefault();

		const contentWrapper = modal.find( '.content-wrapper' );
		const close          = modal.find( '.close' );

		modal.focus();
		modal.addClass( 'open' );

		resizeModal( modal );

		$( document.body ).toggleClass( 'wcs-modal-open', true );

		// Attach callbacks to handle closing the modal.
		close.on( 'click', () => close_modal( modal ) );
		modal.on( 'click', () => close_modal( modal ) );
		contentWrapper.on( 'click', ( e ) => e.stopPropagation() );

		// Close the modal if the escape key is pressed.
		modal.on( 'keyup', function( e ) {
			if ( 27 === e.keyCode ) {
				close_modal( modal )
			}
		} );
	}

	/**
	 * Closes a modal and resets any forced height styles.
	 *
	 * @param {JQuery Object} modal
	 */
	function close_modal( modal ) {
		modal.removeClass( 'open' );
		$( modal ).find( '.content-wrapper' ).css( 'height', '' );

		if ( 0 === modals.filter( '.open' ).length ) {
			$( document.body ).removeClass( 'wcs-modal-open' );
		}
	}

	/**
	 * Determines if a modal should be displayed.
	 *
	 * A custom trigger is called to allow third-parties to filter whether the modal should be displayed or not.
	 *
	 * @param {JQuery Object} modal
	 */
	function should_show_modal( modal ) {
		// Allow third-parties to filter whether the modal should be displayed.
		var event   = jQuery.Event( 'wcs_show_modal' );
		event.modal = modal;

		$( document ).trigger( event );

		// Fallback to true (show modal) if the result is undefined.
		return undefined === event.result ? true : event.result;
	}

	/**
	 * Resize all open modals to fit the display.
	 */
	function resizeModals() {
		$( modals ).each( function() {
			if ( ! $( this ).hasClass( 'open' ) ) {
				return;
			}

			resizeModal( this );
		});
	}

	/**
	 * Resize a modal to fit the display.
	 *
	 * @param {JQuery Object} modal
	 */
	function resizeModal( modal ) {
		var modal_container = $( modal ).find( '.content-wrapper' );

		// On smaller displays the height is already forced to be 100% in CSS. We just clear any height we might set previously.
		if ( $( window ).width() <= 414 ) {
			modal_container.css( 'height', '' );
		} else if ( modal_container.height() > $( window ).height() ) {
			// Force the container height to trigger scroll etc if it doesn't fit on the screen.
			modal_container.css( 'height', '90%' );
		}
	}
});