PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.32.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.32.1
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / js / plugin-search.js

plugin-search.js in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.32.1, at js/plugin-search.js

73 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Handles replacing the bottom row
3 * of the card with customized content.
4 */
5
6 let FormidablePSH = {};
7
8 function frmPS() {
9 FormidablePSH = {
10 $pluginFilter: document.getElementById( 'plugin-filter' ),
11
12 /**
13 * Get parent search hint element.
14 *
15 * @return {Element|null} The parent search hint element.
16 */
17 getCard() {
18 return document.querySelector( '.plugin-card-frm-plugin-search' );
19 },
20
21 /**
22 * Replace bottom row of the card to insert logo, text and link to dismiss the card.
23 */
24 replaceCardBottom() {
25 const hint = FormidablePSH.getCard();
26 if ( 'object' === typeof hint && null !== hint ) {
27 hint.querySelector( '.plugin-card-bottom' ).outerHTML =
28 `<div class="plugin-card-bottom frm-plugin-search__bottom"><p class="frm-plugin-search__text">${ frmPlugSearch.legend }</p></div>`;
29
30 // Remove link and parent li from action links and move it to bottom row
31 const dismissLink = document.querySelector( '.frm-plugin-search__dismiss' );
32 dismissLink.parentNode.remove();
33 document.querySelector( '.frm-plugin-search__bottom' ).append( dismissLink );
34 }
35 },
36
37 /**
38 * Check if plugin card list nodes changed. If there's a Formidable PSH card, replace the title and the bottom row.
39 *
40 * @param {Array} mutationsList
41 */
42 replaceOnNewResults( mutationsList ) {
43 mutationsList.forEach( function( mutation ) {
44 if (
45 'childList' === mutation.type &&
46 1 === document.querySelectorAll( '.plugin-card-frm-plugin-search' ).length
47 ) {
48 FormidablePSH.replaceCardBottom();
49 }
50 } );
51 },
52
53 /**
54 * Start suggesting.
55 */
56 init() {
57 if ( FormidablePSH.$pluginFilter === null ) {
58 return;
59 }
60
61 // Replace PSH bottom row on page load
62 FormidablePSH.replaceCardBottom();
63
64 // Listen for changes in plugin search results
65 const resultsObserver = new MutationObserver( FormidablePSH.replaceOnNewResults );
66 resultsObserver.observe( FormidablePSH.$pluginFilter, { childList: true } );
67 },
68 };
69
70 FormidablePSH.init();
71 }
72 FormidablePS = frmPS(); //eslint-disable-line sonarjs/no-use-of-empty-return-value
73