# formidable/trunk/js/plugin-search.js

Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes &amp; More, version trunk. 73 lines.

- Page: https://pluginprobe.com/plugins/formidable/trunk/code/js/plugin-search.js
- Raw: https://pluginprobe.com/plugins/formidable/trunk/raw/js/plugin-search.js
- Modified: 2026-03-11T18:49:02+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/formidable/trunk/code/js/plugin-search.js#L10-L20`.

```javascript
/**
 * Handles replacing the bottom row
 * of the card with customized content.
 */

let FormidablePSH = {};

function frmPS() {
	FormidablePSH = {
		$pluginFilter: document.getElementById( 'plugin-filter' ),

		/**
		 * Get parent search hint element.
		 *
		 * @return {Element|null} The parent search hint element.
		 */
		getCard() {
			return document.querySelector( '.plugin-card-frm-plugin-search' );
		},

		/**
		 * Replace bottom row of the card to insert logo, text and link to dismiss the card.
		 */
		replaceCardBottom() {
			const hint = FormidablePSH.getCard();
			if ( 'object' === typeof hint && null !== hint ) {
				hint.querySelector( '.plugin-card-bottom' ).outerHTML =
					`<div class="plugin-card-bottom frm-plugin-search__bottom"><p class="frm-plugin-search__text">${ frmPlugSearch.legend }</p></div>`;

				// Remove link and parent li from action links and move it to bottom row
				const dismissLink = document.querySelector( '.frm-plugin-search__dismiss' );
				dismissLink.parentNode.remove();
				document.querySelector( '.frm-plugin-search__bottom' ).append( dismissLink );
			}
		},

		/**
		 * Check if plugin card list nodes changed. If there's a Formidable PSH card, replace the title and the bottom row.
		 *
		 * @param {Array} mutationsList
		 */
		replaceOnNewResults( mutationsList ) {
			mutationsList.forEach( function( mutation ) {
				if (
					'childList' === mutation.type &&
					1 === document.querySelectorAll( '.plugin-card-frm-plugin-search' ).length
				) {
					FormidablePSH.replaceCardBottom();
				}
			} );
		},

		/**
		 * Start suggesting.
		 */
		init() {
			if ( FormidablePSH.$pluginFilter === null ) {
				return;
			}

			// Replace PSH bottom row on page load
			FormidablePSH.replaceCardBottom();

			// Listen for changes in plugin search results
			const resultsObserver = new MutationObserver( FormidablePSH.replaceOnNewResults );
			resultsObserver.observe( FormidablePSH.$pluginFilter, { childList: true } );
		},
	};

	FormidablePSH.init();
}
FormidablePS = frmPS(); //eslint-disable-line sonarjs/no-use-of-empty-return-value

```
