HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux wordpress 6.8.0-88-generic #89-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 01:02:46 UTC 2025 x86_64
User: www-data (33)
PHP: 8.3.28
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/plugins/wpforms-lite/assets/js/integrations/elementor/editor-context.js
/* global $e, elementor */

// noinspection ES6ConvertVarToLetConst
/**
 * WPForms script for editor context.
 *
 * @since 1.9.6
 */
var WPFormsElementorEditorContext = window.WPFormsElementorEditorContext || ( function( document, window, $ ) { // eslint-disable-line no-var
	// noinspection JSUnusedGlobalSymbols
	/**
	 * Public functions and properties.
	 *
	 * @since 1.9.6
	 *
	 * @type {Object}
	 */
	const app = {

		/**
		 * Start the engine.
		 *
		 * @since 1.9.6
		 */
		init() {
			app.events();
		},

		/**
		 * Register JS events.
		 *
		 * @since 1.9.6
		 */
		events() {
			$( window ).on( 'elementor/init', function() {
				// To add action on save event, we should use hookUI.After.
				$e.hooks.registerUIAfter( new class extends $e.modules.hookUI.After {
					// noinspection JSUnusedGlobalSymbols
					getCommand() {
						return 'document/save/save';
					}

					// noinspection JSUnusedGlobalSymbols
					getId() {
						return 'wpforms-elementor-editor-context-after-save';
					}

					// noinspection JSUnusedGlobalSymbols
					getConditions() {
						return true;
					}

					apply() {
						// Save custom themes in a preview window.
						const previewWindow = elementor.$preview[ 0 ]?.contentWindow;

						if ( previewWindow ) {
							previewWindow.WPFormsElementorThemes.saveCustomThemes();
						}
					}
				} );
			} );
		},
	};

	return app;
}( document, window, jQuery ) );

// Initialize.
WPFormsElementorEditorContext.init();