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