| @@ -2,8 +2,10 @@ | ||
| 2 | 2 | * Handles replacing the bottom row |
| 3 | 3 | * of the card with customized content. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | +/* global frmPlugSearch */ | |
| 7 | + | |
| 6 | 8 | let FormidablePSH = {}; |
| 7 | 9 | |
| 8 | 10 | function frmPS() { |
| 9 | 11 | FormidablePSH = { |
| @@ -10,12 +12,11 @@ | ||
| 10 | 12 | $pluginFilter: document.getElementById( 'plugin-filter' ), |
| 11 | 13 | |
| 12 | 14 | /** |
| 13 | 15 | * Get parent search hint element. |
| 14 | - * | |
| 15 | 16 | * @return {Element|null} The parent search hint element. |
| 16 | 17 | */ |
| 17 | - getCard() { | |
| 18 | + getCard: function() { | |
| 18 | 19 | return document.querySelector( '.plugin-card-frm-plugin-search' ); |
| 19 | 20 | }, |
| 20 | 21 | |
| 21 | 22 | /** |
| @@ -20,27 +21,30 @@ | ||
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * Replace bottom row of the card to insert logo, text and link to dismiss the card. |
| 23 | 24 | */ |
| 24 | - replaceCardBottom() { | |
| 25 | + replaceCardBottom: function() { | |
| 25 | 26 | const hint = FormidablePSH.getCard(); |
| 26 | 27 | if ( 'object' === typeof hint && null !== hint ) { |
| 27 | 28 | 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 | + '<div class="plugin-card-bottom frm-plugin-search__bottom">' + | |
| 30 | + '<p class="frm-plugin-search__text">' + | |
| 31 | + frmPlugSearch.legend + | |
| 32 | + '</p>' + | |
| 33 | + '</div>'; | |
| 29 | 34 | |
| 30 | 35 | // Remove link and parent li from action links and move it to bottom row |
| 31 | 36 | const dismissLink = document.querySelector( '.frm-plugin-search__dismiss' ); |
| 32 | - dismissLink.parentNode.remove(); | |
| 33 | - document.querySelector( '.frm-plugin-search__bottom' ).append( dismissLink ); | |
| 37 | + dismissLink.parentNode.parentNode.removeChild( dismissLink.parentNode ); | |
| 38 | + document.querySelector( '.frm-plugin-search__bottom' ).appendChild( dismissLink ); | |
| 34 | 39 | } |
| 35 | 40 | }, |
| 36 | 41 | |
| 37 | 42 | /** |
| 38 | 43 | * Check if plugin card list nodes changed. If there's a Formidable PSH card, replace the title and the bottom row. |
| 39 | - * | |
| 40 | 44 | * @param {Array} mutationsList |
| 41 | 45 | */ |
| 42 | - replaceOnNewResults( mutationsList ) { | |
| 46 | + replaceOnNewResults: function( mutationsList ) { | |
| 43 | 47 | mutationsList.forEach( function( mutation ) { |
| 44 | 48 | if ( |
| 45 | 49 | 'childList' === mutation.type && |
| 46 | 50 | 1 === document.querySelectorAll( '.plugin-card-frm-plugin-search' ).length |
| @@ -52,9 +56,9 @@ | ||
| 52 | 56 | |
| 53 | 57 | /** |
| 54 | 58 | * Start suggesting. |
| 55 | 59 | */ |
| 56 | - init() { | |
| 60 | + init: function() { | |
| 57 | 61 | if ( FormidablePSH.$pluginFilter === null ) { |
| 58 | 62 | return; |
| 59 | 63 | } |
| 60 | 64 | |