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