<div class="efl-search-mechanic hidden" data-behavior="efl-search-mechanic" id="efl-search-mechanic">
    <div class="efl-search-mechanic__inputgroup" data-min-text="5">
        <input type="text" class="efl-search-mechanic__input" placeholder="Search England Football" autocomplete="off">
        <a class="clear-input" aria-label="Clear input"></a>
        <span class="line"></span>
    </div>
    <div class="efl-search-mechanic__result hidden">
        <div class="efl-search-mechanic__result--loading hidden">
            <div class="loading">
                <div class="loader"></div>
                <div class="efl-logo"></div>
            </div>
        </div>
        <div class="efl-search-mechanic__result--suggestion hidden">
            <h3>Suggestions</h3>
            <div class="suggesion-list-group">
                <div class="suggesion-list">
                    <!-- clone suggetion html object -->
                </div>
                <div class="see-all">
                    <a class="see-all-cta">SEE ALL RESULTS</a>
                </div>
            </div>
        </div>
        <div class="efl-search-mechanic__result--noresult hidden">
            <h3>No Results</h3>
            <div class="suggesion-list-group">
                <div class="suggesion-list">
                    We&#x27;re sorry. We were not able to find a match for your search. Please check for typos and spelling errors or try a more general / different search
                </div>
            </div>
        </div>
        <div class="efl-search-mechanic__result--allresults hidden">
            <div class="allresults-tabs" role="tablist" aria-label="Panel Tablist">
                <a role="tab" aria-selected="true" aria-controls="panel-tab-all" id="tab-all" data-search-filter="">All</a>
                <a role="tab" aria-selected="false" aria-controls="panel-tab-courses" id="tab-courses" data-search-filter="c139e0de1b1a4e62a05ce4a90fc37ab7">Courses</a>
                <a role="tab" aria-selected="false" aria-controls="panel-tab-sessions" id="tab-sessions" data-search-filter="5b8c1f84b7364f42aee54bae6a8cef06">Sessions</a>
                <a role="tab" aria-selected="false" aria-controls="panel-tab-article" id="tab-article" data-search-filter="affa021ca9a24b60b08058bc80351cda">Articles</a>
                <a role="tab" aria-selected="false" aria-controls="panel-tab-cpd" id="tab-cpd" data-search-filter="44983d32599d4a0aa3ea497cf00530bd">CPD</a>
            </div>
            <div role="tabpanel" id="panel-tab-all">
                <h3>0 Results</h3>
                <div class="result-scroll">
                    <div class="result-lists">
                    </div>
                    <div class="more-result-lists">
                    </div>
                    <div class="result-lists-norsult hidden">
                        We&#x27;re sorry. We were not able to find a match for your search
                    </div>
                    <div class="loading">
                        <div class="loader"></div>
                        <div class="efl-logo"></div>
                    </div>
                </div>
            </div>
            <div role="tabpanel" id="panel-tab-courses" hidden="true">
                <h3>0 Results</h3>
                <div class="result-scroll">
                    <div class="result-lists">
                    </div>
                    <div class="more-result-lists">
                    </div>
                    <div class="result-lists-norsult hidden">
                        We&#x27;re sorry. We were not able to find a match for your search
                    </div>
                    <div class="loading">
                        <div class="loader"></div>
                        <div class="efl-logo"></div>
                    </div>
                </div>
            </div>
            <div role="tabpanel" id="panel-tab-sessions" hidden="true">
                <h3>0 Results</h3>
                <div class="result-scroll">
                    <div class="result-lists">
                    </div>
                    <div class="more-result-lists">
                    </div>
                    <div class="result-lists-norsult hidden">
                        We&#x27;re sorry. We were not able to find a match for your search
                    </div>
                    <div class="loading">
                        <div class="loader"></div>
                        <div class="efl-logo"></div>
                    </div>
                </div>
            </div>
            <div role="tabpanel" id="panel-tab-article" hidden="true">
                <h3>0 Results</h3>
                <div class="result-scroll">
                    <div class="result-lists">
                    </div>
                    <div class="more-result-lists">
                    </div>
                    <div class="result-lists-norsult hidden">
                        We&#x27;re sorry. We were not able to find a match for your search
                    </div>
                    <div class="loading">
                        <div class="loader"></div>
                        <div class="efl-logo"></div>
                    </div>
                </div>
            </div>
            <div role="tabpanel" id="panel-tab-cpd" hidden="true">
                <h3>0 Results</h3>
                <div class="result-scroll">
                    <div class="result-lists">
                    </div>
                    <div class="more-result-lists">
                    </div>
                    <div class="result-lists-norsult hidden">
                        We&#x27;re sorry. We were not able to find a match for your search
                    </div>
                    <div class="loading">
                        <div class="loader"></div>
                        <div class="efl-logo"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

No notes defined.

{
  "suggestion": "Suggestions",
  "see-all-cta": "SEE ALL RESULTS",
  "no-result": "No Results",
  "no-result-info": "We're sorry. We were not able to find a match for your search. Please check for typos and spelling errors or try a more general / different search",
  "tablist": [
    {
      "selected": "true",
      "id": "all",
      "label": "All",
      "filter": "",
      "hidden": false,
      "no-resulttab-info": "We're sorry. We were not able to find a match for your search"
    },
    {
      "selected": "false",
      "id": "courses",
      "label": "Courses",
      "filter": "c139e0de1b1a4e62a05ce4a90fc37ab7",
      "hidden": true,
      "no-resulttab-info": "We're sorry. We were not able to find a match for your search"
    },
    {
      "selected": "false",
      "id": "sessions",
      "label": "Sessions",
      "filter": "5b8c1f84b7364f42aee54bae6a8cef06",
      "hidden": true,
      "no-resulttab-info": "We're sorry. We were not able to find a match for your search"
    },
    {
      "selected": "false",
      "id": "article",
      "label": "Articles",
      "filter": "affa021ca9a24b60b08058bc80351cda",
      "hidden": true,
      "no-resulttab-info": "We're sorry. We were not able to find a match for your search"
    },
    {
      "selected": "false",
      "id": "cpd",
      "label": "CPD",
      "filter": "44983d32599d4a0aa3ea497cf00530bd",
      "hidden": true,
      "no-resulttab-info": "We're sorry. We were not able to find a match for your search"
    }
  ]
}
  • Content:
    // import autocomplete from 'autocompleter';
    import { Dialog } from '../../components/lightbox-overlay/lightbox-overlay';
    import videoLightBox from '../../components/dynamic-video-dialog/generate-lightbox';
    import vimeoVideoLightBox from '../../components/dynamic-video-dialog/generate-vimeo-lightbox';
    
    const DIALOG_ID = 'efl-search-mechanic-dialog';
    
    export default parentElement => {
      const searchIcon = document.querySelector(
        '.global-fixed-header .site-search'
      );
      const inputBlock = parentElement.querySelector(
        '.efl-search-mechanic__inputgroup'
      );
      const { minText } = inputBlock.dataset;
      let isAjaxRuning = false;
    
      if (!searchIcon) {
        return;
      }
    
      async function globalSearchCallback(activePanel, searchText, pageSize, skip) {
        let filter = '';
        let tab = '';
        const modal = document.querySelector(`#${DIALOG_ID}`);
    
        if (activePanel) {
          const tabid = activePanel.id.replace('panel-tab-', '');
    
          tab = modal
            .querySelector(`#tab-${tabid}`)
            .getAttribute('data-search-filter');
        }
    
        if (tab && tab !== 'all') {
          filter = `&filters=${tab}`;
        }
    
        const url = `/GlobalSearch/SearchResults?site=EF&q=${searchText}&PageIndex=${skip}&PageSize=${pageSize}${filter}`;
        // eslint-disable-next-line compat/compat
        const response = await fetch(url, {
          headers: {
            'Content-Type': 'application/json',
          },
        });
    
        return response.json();
      }
    
      const initiateLightbox = () => {
        const videoLightBoxElements = document.querySelectorAll(
          '[data-behavior=video-lightbox]'
        );
    
        if (videoLightBoxElements) {
          videoLightBoxElements.forEach(videoLightBoxElement =>
            videoLightBox(videoLightBoxElement)
          );
        }
      };
      const initiateVimeoLightbox = () => {
        const vimeoLightBoxElements = document.querySelectorAll(
          '[data-behavior=vimeo-video-lightbox]'
        );
    
        if (vimeoLightBoxElements) {
          vimeoLightBoxElements.forEach(vimeoLightBoxElement =>
            vimeoVideoLightBox(vimeoLightBoxElement)
          );
        }
      };
    
      const hideSuggestion = () => {
        const modal = document.querySelector(`#${DIALOG_ID}`);
        const resultDiv = modal.querySelector('.efl-search-mechanic__result');
        const suggestionDiv = resultDiv.querySelector(
          '.efl-search-mechanic__result--suggestion'
        );
        const noResultDiv = resultDiv.querySelector(
          '.efl-search-mechanic__result--noresult'
        );
    
        resultDiv.classList.add('hidden');
        suggestionDiv.classList.add('hidden');
        noResultDiv.classList.add('hidden');
      };
    
      const suggesionHtml = suggestion => {
        const {
          articleHeadline,
          articleLink,
          categoryTagName,
          videoType,
          videoId,
          articleImage,
        } = suggestion;
        let category = 'Others';
    
        if (categoryTagName) {
          category = categoryTagName;
        }
        const modal = document.querySelector(`#${DIALOG_ID}`);
        const inputBox = modal.querySelector('.efl-search-mechanic__input');
    
        let videoHtml = '';
    
        if (videoType && videoType === 'youtube') {
          videoHtml = `data-behavior="video-lightbox"
          data-video-id="${videoId}" data-poster-image="${articleImage}"`;
        } else if (videoType && videoType === 'vimeo') {
          videoHtml = `data-behavior="vimeo-video-lightbox"
          data-video-id="${videoId}" data-poster-image="${articleImage}"`;
        }
    
        return `
          <a href="${articleLink}?q=${inputBox.value}" ${videoHtml}>
            <div class="list-info">
                <h4>${category}</h4>
                <p>${articleHeadline}</p>
            </div>
          </a>`;
      };
      const renderSuggestion = (response, pageSize) => {
        const modal = document.querySelector(`#${DIALOG_ID}`);
        const resultDiv = modal.querySelector('.efl-search-mechanic__result');
        const suggestionDiv = resultDiv.querySelector(
          '.efl-search-mechanic__result--suggestion'
        );
        const allresultDiv = resultDiv.querySelector(
          '.efl-search-mechanic__result--allresults'
        );
        const noresultDiv = resultDiv.querySelector(
          '.efl-search-mechanic__result--noresult'
        );
        const suggestionList = suggestionDiv.querySelector('.suggesion-list');
    
        suggestionList.innerHTML = '';
    
        response.forEach((list, index) => {
          if (index < pageSize) {
            const listClone = suggesionHtml(list);
    
            suggestionList.insertAdjacentHTML('beforeend', listClone);
          }
        });
    
        initiateLightbox();
        initiateVimeoLightbox();
    
        resultDiv.classList.remove('hidden');
        suggestionDiv.classList.remove('hidden');
        allresultDiv.classList.add('hidden');
        noresultDiv.classList.add('hidden');
      };
    
      const dateFormater = dateStr => {
        const dateObj = dateStr.split('T');
        const stDate = new Date(dateObj[0]);
        const month = [
          'Jan',
          'Feb',
          'Mar',
          'Apr',
          'May',
          'Jun',
          'Jul',
          'Aug',
          'Sep',
          'Oct',
          'Nov',
          'Dec',
        ];
        let stDt = '';
    
        if (stDate.getDate() >= 10) {
          stDt = stDate.getDate();
        } else {
          stDt = `0${stDate.getDate()}`;
        }
    
        const stMonth = month[stDate.getMonth()];
    
        return `${stDt} ${stMonth} ${stDate.getFullYear()}`;
      };
    
      const renderResultCard = cardDetails => {
        const {
          articleHeadline,
          articleDescription,
          articleImage,
          articleLink,
          publishedDate,
          readTime,
          categoryTagName,
          videoType,
          videoId,
        } = cardDetails;
    
        const date = dateFormater(publishedDate);
        let imgTag = '';
        let playIcon = '';
        let read = '';
    
        if (articleImage) {
          imgTag = `<img src="${articleImage}" alt="" loading="lazy" />`;
        }
    
        let category = 'Others';
    
        if (categoryTagName) {
          category = categoryTagName;
        }
    
        if (category === 'Video') {
          playIcon = `<div class="efl-search-play_icon" alt="play icon" loading="lazy" ></div>`;
        }
    
        if (readTime) {
          read = `<span class="time">${readTime}</span> &nbsp;&nbsp;&#8211;&nbsp;&nbsp;<span class="date">${date}</span>`;
        } else {
          read = `<span class="date">${date}</span>`;
        }
    
        const tempDiv = document.createElement('div');
    
        tempDiv.innerHTML = articleDescription;
    
        const desc = tempDiv.innerText;
        const modal = document.querySelector(`#${DIALOG_ID}`);
        const inputBox = modal.querySelector('.efl-search-mechanic__input');
        let videoHtml = '';
    
        if (videoType && videoType === 'youtube') {
          videoHtml = `data-behavior="video-lightbox"
          data-video-id="${videoId}" data-poster-image="${articleImage}"`;
        } else if (videoType && videoType === 'vimeo') {
          videoHtml = `data-behavior="vimeo-video-lightbox"
          data-video-id="${videoId}" data-poster-image="${articleImage}"`;
        }
    
        return `
          <a href="${articleLink}?q=${inputBox.value}" ${videoHtml}>
            <div class="efl-search-card">
              <div class="efl-search-card__image">
                  ${imgTag}
                  <span>
                  ${playIcon}
                  </span>
              </div>
              
              <div class="efl-search-card__content">
                  <p class="efl-search-card__category">${category}</p>
                  <h5 class="efl-heading-5 efl-search-card__title">${articleHeadline}</h5>
                  <p class="efl-p-1 efl-search-card__description">${desc}</p>
                  <p class="efl-search-card__date-wrap">
                      ${read}
                  </p>
              </div>
            </div>
          </a>`;
      };
    
      const renderAllResult = (activePanel, response, pageSize) => {
        let allCardHtml = '';
        const appendObj = activePanel.querySelector('.result-lists');
        const totalCount = activePanel.querySelector('h3');
        // eslint-disable-next-line radix
        let current = parseInt(activePanel.getAttribute('data-current'));
        // eslint-disable-next-line radix
        let skip = parseInt(activePanel.getAttribute('data-skip'));
    
        response.results.forEach((cardDetails, index) => {
          if (index < pageSize) {
            allCardHtml += renderResultCard(cardDetails);
          }
        });
    
        if (response.results.length > pageSize) {
          // eslint-disable-next-line radix
          current += parseInt(pageSize);
        } else {
          // eslint-disable-next-line radix
          current += parseInt(response.results.length);
        }
        // eslint-disable-next-line no-plusplus
        skip++;
    
        appendObj.insertAdjacentHTML('beforeend', allCardHtml);
        totalCount.innerText = `${response.numFound} Results`;
        activePanel.setAttribute('data-totalresult', response.numFound);
        activePanel.setAttribute('data-current', current);
        activePanel.setAttribute('data-skip', skip);
        if (response.numFound > 9) {
          activePanel.setAttribute('data-loadmore', 'true');
        }
    
        initiateLightbox();
        initiateVimeoLightbox();
      };
    
      const renderMoreResult = (activePanel, response, pageSize) => {
        let allCardHtml = '';
        const appendObj = activePanel.querySelector('.more-result-lists');
        // eslint-disable-next-line radix
        let current = parseInt(activePanel.getAttribute('data-current'));
        // eslint-disable-next-line radix
        const total = parseInt(activePanel.getAttribute('data-totalresult'));
        // eslint-disable-next-line radix
        let skip = parseInt(activePanel.getAttribute('data-skip'));
    
        response.results.forEach((cardDetails, index) => {
          if (index < pageSize && current + index < total) {
            allCardHtml += renderResultCard(cardDetails);
          }
        });
    
        if (total - current > pageSize) {
          // eslint-disable-next-line radix
          current += parseInt(pageSize);
        } else {
          // eslint-disable-next-line radix
          current += parseInt(total - current);
        }
        // eslint-disable-next-line no-plusplus
        skip++;
    
        appendObj.insertAdjacentHTML('beforeend', allCardHtml);
        activePanel.setAttribute('data-current', current);
        activePanel.setAttribute('data-skip', skip);
        if (response.numFound > current) {
          activePanel.setAttribute('data-loadmore', 'true');
        } else {
          activePanel.setAttribute('data-loadmore', 'false');
        }
    
        initiateLightbox();
        initiateVimeoLightbox();
      };
    
      const renderNoResult = () => {
        const modal = document.querySelector(`#${DIALOG_ID}`);
        const resultDiv = modal.querySelector('.efl-search-mechanic__result');
        const suggestionDiv = resultDiv.querySelector(
          '.efl-search-mechanic__result--suggestion'
        );
        const allresultDiv = resultDiv.querySelector(
          '.efl-search-mechanic__result--allresults'
        );
        const noresultDiv = resultDiv.querySelector(
          '.efl-search-mechanic__result--noresult'
        );
    
        resultDiv.classList.remove('hidden');
        suggestionDiv.classList.add('hidden');
        allresultDiv.classList.add('hidden');
        noresultDiv.classList.remove('hidden');
      };
    
      const renderTabNoResult = activePanel => {
        const resultlist = activePanel.querySelector('.result-lists');
        const moreresult = activePanel.querySelector('.more-result-lists');
        const noresult = activePanel.querySelector('.result-lists-norsult');
    
        resultlist.classList.add('hidden');
        moreresult.classList.add('hidden');
        noresult.classList.remove('hidden');
        // eslint-disable-next-line no-param-reassign
        activePanel.querySelector('h3').innerText = 'No Results';
      };
    
      const removeLoading = (loaderDiv, type) => {
        const loading = loaderDiv.querySelector('.loading');
    
        if (type === 'search') {
          loaderDiv.classList.add('hidden');
        }
    
        if (loading) {
          loading.classList.remove('show');
        }
      };
    
      const showLoading = (loaderDiv, type) => {
        const loading = loaderDiv.querySelector('.loading');
    
        if (type === 'search') {
          loaderDiv.classList.remove('hidden');
        }
    
        if (loading) {
          loading.classList.add('show');
        }
      };
    
      function globalSearch(activePanel, type, searchText, pageSize, skip) {
        try {
          if (activePanel) {
            showLoading(activePanel, type);
          } else if (type === 'search') {
            const modal = document.querySelector(`#${DIALOG_ID}`);
            const loaderDiv = modal.querySelector(
              '.efl-search-mechanic__result--loading'
            );
            const resultDiv = modal.querySelector('.efl-search-mechanic__result');
            const suggestionDiv = resultDiv.querySelector(
              '.efl-search-mechanic__result--suggestion'
            );
            const resultAllDiv = resultDiv.querySelector(
              '.efl-search-mechanic__result--allresults'
            );
    
            showLoading(loaderDiv, type);
            resultDiv.classList.remove('hidden');
            suggestionDiv.classList.add('hidden');
            resultAllDiv.classList.add('hidden');
          }
          isAjaxRuning = true;
          globalSearchCallback(activePanel, searchText, pageSize, skip).then(
            response => {
              if (activePanel) {
                removeLoading(activePanel, type);
              } else {
                const modal = document.querySelector(`#${DIALOG_ID}`);
                const loaderDiv = modal.querySelector(
                  '.efl-search-mechanic__result--loading'
                );
                const resultDiv = modal.querySelector(
                  '.efl-search-mechanic__result'
                );
    
                removeLoading(loaderDiv, type);
                resultDiv.classList.add('hidden');
              }
              isAjaxRuning = false;
              if (response && response !== 'null' && response.numFound) {
                if (type === 'search') {
                  renderSuggestion(response.results, pageSize);
                } else if (type === 'allresult') {
                  renderAllResult(activePanel, response, pageSize);
                } else {
                  renderMoreResult(activePanel, response, pageSize);
                }
              } else if (type === 'allresult') {
                renderTabNoResult(activePanel);
              } else {
                renderNoResult();
              }
            }
          );
        } catch (e) {
          throw new Error('Uable to retrive the sessions ::', e);
        }
      }
    
      const generateLightBox = ({ labelId }) => {
        const html = parentElement.innerHTML;
    
        return `
          <div role="dialog" id="${DIALOG_ID}" aria-labelledby="${labelId}" aria-modal="true" class="lightbox-overlay">
            <div class="efl-search-mechanic">
              <button class="lightbox-overlay__close" id="close">
                <span class="visually-hidden">Close dialog</span>
              </button>      
              <div class="efl-search-mechanic__content">
                ${html}
              </div>
            </div>
          </div>`;
      };
    
      const removeLightBox = () => {
        document.getElementById(DIALOG_ID).remove();
      };
    
      searchIcon.addEventListener('click', event => {
        event.preventDefault();
    
        // Create the lightbox
        const lightboxContainer = document.createElement('div');
    
        lightboxContainer.innerHTML = generateLightBox({
          labelId: parentElement.id,
        });
        document.body.appendChild(lightboxContainer);
    
        // eslint-disable-next-line no-new
        new Dialog({
          dialogId: DIALOG_ID,
          focusAfterClosed: searchIcon,
          focusFirst: 'close',
          closeCallBack: () => removeLightBox(),
        });
    
        const inputBox = lightboxContainer.querySelector(
          '.efl-search-mechanic__input'
        );
    
        // added default focus to the inputbox
        inputBox.focus();
    
        const clearText = lightboxContainer.querySelector('.clear-input');
        const resultAllCta = lightboxContainer.querySelector('.see-all-cta');
        const suggestionDiv = lightboxContainer.querySelector(
          '.efl-search-mechanic__result--suggestion'
        );
        const resultAllDiv = lightboxContainer.querySelector(
          '.efl-search-mechanic__result--allresults'
        );
        const allTabs = resultAllDiv.querySelectorAll('.allresults-tabs > a');
        const firstTab = resultAllDiv.querySelector(
          '.allresults-tabs > a:first-child'
        );
        const allTabPanel = resultAllDiv.querySelectorAll('div[role="tabpanel"]');
    
        const tabActive = activeTab => {
          allTabs.forEach(t => t.setAttribute('aria-selected', 'false'));
          allTabPanel.forEach(t => t.setAttribute('hidden', 'true'));
          activeTab.setAttribute('aria-selected', 'true');
          const activePanel = activeTab.getAttribute('aria-controls');
    
          resultAllDiv.querySelector(`#${activePanel}`).removeAttribute('hidden');
        };
    
        const resetTab = () => {
          allTabs.forEach(tab => {
            tab.setAttribute('aria-selected', 'false');
          });
          allTabPanel.forEach(panel => {
            panel.setAttribute('hidden', 'true');
            panel.setAttribute('data-skip', '1');
            panel.setAttribute('data-totalresult', '0');
            panel.setAttribute('data-current', '0');
            panel.setAttribute('data-loadmore', 'false');
            panel.querySelector('.result-lists').classList.remove('hidden');
            panel.querySelector('.more-result-lists').classList.remove('hidden');
            panel.querySelector('.result-lists-norsult').classList.add('hidden');
            // eslint-disable-next-line no-param-reassign
            panel.querySelector('.result-lists').innerHTML = '';
            // eslint-disable-next-line no-param-reassign
            panel.querySelector('.more-result-lists').innerHTML = '';
            // eslint-disable-next-line no-param-reassign
            panel.querySelector('h3').innerText = '0 Results';
          });
          allTabs[0].setAttribute('aria-selected', 'true');
          const activePanel = allTabs[0].getAttribute('aria-controls');
    
          resultAllDiv.querySelector(`#${activePanel}`).removeAttribute('hidden');
        };
    
        inputBox.addEventListener('input', e => {
          if (e.target.value) {
            inputBox.classList.add('noempty');
          } else {
            inputBox.classList.remove('noempty');
          }
        });
    
        /* const keyUpDelay = (callback, ms) => {
          var timer = 0;
          return function() {
            var context = this, args = arguments;
            clearTimeout(timer);
            timer = setTimeout(function () {
              callback.apply(context, args);
            }, ms || 0);
          };
        }; */
    
        inputBox.addEventListener('keyup', e => {
          const contentDiv = lightboxContainer.querySelector(
            '.efl-search-mechanic__content'
          );
    
          if (e.target.value.trim().length >= minText) {
            // console.log(e.target.value);
            contentDiv.classList.add('search-margin');
            // keyUpDelay(() => {
            globalSearch('', 'search', e.target.value, 5, 1);
            // }, 300);
          } else {
            contentDiv.classList.remove('search-margin');
            hideSuggestion();
          }
        });
    
        clearText.addEventListener('click', () => {
          inputBox.value = '';
          inputBox.classList.remove('noempty');
          const contentDiv = lightboxContainer.querySelector(
            '.efl-search-mechanic__content'
          );
    
          contentDiv.classList.remove('search-margin');
          hideSuggestion();
        });
    
        resultAllCta.addEventListener('click', e => {
          e.preventDefault();
          suggestionDiv.classList.add('hidden');
          resultAllDiv.classList.remove('hidden');
    
          resetTab();
          tabActive(firstTab);
    
          const modal = document.querySelector(`#${DIALOG_ID}`);
          const resultDiv = modal.querySelector('.efl-search-mechanic__result');
          const allresultDiv = resultDiv.querySelector(
            '.efl-search-mechanic__result--allresults'
          );
          const activePanel = allresultDiv.querySelector(
            'div[role="tabpanel"]:not([hidden])'
          );
    
          globalSearch(activePanel, 'allresult', inputBox.value, 9, 1);
        });
    
        allTabs.forEach(tab => {
          tab.addEventListener('click', e => {
            tabActive(e.target);
    
            const activeTab = e.target.getAttribute('aria-controls');
            const activePanel = lightboxContainer.querySelector(`#${activeTab}`);
            const skip = activePanel.getAttribute('data-skip');
            const current = activePanel.getAttribute('data-current');
    
            if (current === '0') {
              globalSearch(activePanel, 'allresult', inputBox.value, 9, skip);
            }
          });
        });
    
        // load more content
        allTabPanel.forEach(panel => {
          const currentPannel = panel.querySelector('.result-scroll');
    
          panel.querySelector('.result-scroll').addEventListener('scroll', () => {
            const { scrollTop, scrollHeight, clientHeight } = currentPannel;
    
            if (
              clientHeight + scrollTop >= scrollHeight - 10 &&
              panel.getAttribute('data-loadmore') === 'true' &&
              !isAjaxRuning
            ) {
              // eslint-disable-next-line radix
              const skip = parseInt(panel.getAttribute('data-skip'));
    
              globalSearch(panel, 'moreresult', inputBox.value, 9, skip);
            }
          });
        });
      });
    };
    
  • URL: /components/raw/efl-search-mechanic/efl-search-mechanic.js
  • Filesystem Path: src/library/modules/efl-search-mechanic/efl-search-mechanic.js
  • Size: 20.6 KB
  • Content:
    .efl-search-mechanic {
      height: 100vh;
      width: 100vw;
      background-color: $white;
      position: relative;
      &__content {
        padding-top: 11.6rem;
        padding-left: 3.2rem;
        padding-right: 3.2rem;
        margin: 0 auto;
        transition: padding-top 0.3s ease-in-out;
      }
      &__inputgroup {
        position: relative;
        .clear-input {
          background: url('./assets/images/efl-seach-mechanic-delete.svg') no-repeat
            center right;
          width: 2.2rem;
          height: 2.2rem;
          display: none;
          position: absolute;
          left: 0.8rem;
          top: calc(50% - 1.1rem);
          cursor: pointer;
        }
      }
      &__input {
        font-family: $text-font;
        font-size: 1.6rem;
        line-height: 2.4rem;
        color: $blue;
        box-sizing: border-box;
        border: none;
        width: 100%;
        font-weight: 500;
        background: url('./assets/images/efl-seach-mechanic-search.svg') no-repeat
          98% center;
        background-color: $white;
        transition: padding-left 0.3s ease-in-out;
        outline-color: $blue-accent;
        padding-top: 1.2rem;
        padding-bottom: 1.2rem;
        padding-left: 1.6rem;
        padding-right: 1.6rem;
        &:focus-visible {
          outline-style: solid;
        }
        & + a + span {
          border-bottom: 1px solid $color-interface-light;
          display: inline-block;
          position: absolute;
          width: 100%;
          height: 2px;
          left: 0;
          bottom: 0;
          &::after {
            content: '';
            border-bottom: 2px solid $blue-accent;
            width: 0%;
            height: 1px;
            display: inline-block;
            position: absolute;
            z-index: 1;
            transition: width 0.3s ease-in-out;
          }
        }
        &:focus + a + span {
          &::after {
            width: 100%;
          }
        }
        &.noempty {
          padding-left: 3.8rem;
          padding-right: 3.8rem;
        }
        &.noempty + .clear-input {
          display: inline-block;
        }
      }
      .lightbox-overlay__close {
        height: 3.2rem;
        width: 3.2rem;
        top: 5.4rem;
        right: 3.2rem;
        &::before {
          background: url('./assets/images/search-mechanic-modal-close.svg');
          height: 3.2rem;
          width: 3.2rem;
          background-size: contain;
        }
      }
      &__result {
        h3 {
          font-family: $ef-font;
          font-size: 1.2rem;
          line-height: 1.2rem;
          letter-spacing: 0.08em;
          text-transform: uppercase;
          color: $color-interface-light;
          padding-bottom: 0.8rem;
          padding-top: 2.4rem;
          position: relative;
          &::before {
            content: '';
            position: absolute;
            border-bottom: 1px solid $blue;
            width: 7rem;
            height: 1px;
            bottom: 0;
            z-index: 1;
          }
          &::after {
            content: '';
            position: absolute;
            border-bottom: 1px solid $light-blue;
            width: 100%;
            height: 1px;
            bottom: 0;
            left: 0;
          }
        }
        .loading {
          display: none;
          position: relative;
          margin: 4rem auto;
          width: 8em;
          height: 8em;
          &.show {
            display: block;
          }
          .efl-logo {
            background-image: url('./assets/images/ef-logo.svg');
            background-repeat: no-repeat;
            background-position: center;
            position: absolute;
            z-index: 2;
            top: 0;
            left: 0;
            background-size: 3.28rem 3.9rem;
            width: 100%;
            height: 100%;
          }
          .loader {
            font-size: 10px;
            text-indent: -9999em;
            width: 100%;
            height: 100%;
            border-radius: 100%;
            overflow: hidden;
            background: rgb(236, 238, 243);
            position: relative;
            -webkit-animation: load3 1.4s infinite linear;
            animation: load3 1.4s infinite linear;
            -webkit-transform: translateZ(0);
            -ms-transform: translateZ(0);
            transform: translateZ(0);
          }
          .loader::before {
            width: 100%;
            height: 50%;
            background: -linear-gradient(0deg, #004aa3 0%, #eceef3 50%);
            background: -moz-linear-gradient(0deg, #004aa3 0%, #eceef3 50%);
            background: -o-linear-gradient(0deg, #004aa3 0%, #eceef3 50%);
            background: -ms-linear-gradient(0deg, #004aa3 0%, #eceef3 50%);
            background: -webkit-linear-gradient(0deg, #004aa3 0%, #eceef3 50%);
            transform-origin: bottom right;
            position: absolute;
            top: 0;
            left: 0;
            content: '';
          }
          .loader::after {
            background: #fff;
            width: 85%;
            height: 85%;
            border-radius: 50%;
            content: '';
            margin: auto;
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
          }
    
          @-webkit-keyframes load3 {
            0% {
              -webkit-transform: rotate(0deg);
              transform: rotate(0deg);
            }
            100% {
              -webkit-transform: rotate(360deg);
              transform: rotate(360deg);
            }
          }
    
          @keyframes load3 {
            0% {
              -webkit-transform: rotate(0deg);
              transform: rotate(0deg);
            }
            100% {
              -webkit-transform: rotate(360deg);
              transform: rotate(360deg);
            }
          }
        }
        &--noresult {
          .suggesion-list {
            padding-top: 1.6rem;
            font-family: $text-font;
            font-size: 2rem;
            line-height: 3.2rem;
            font-weight: 700;
            color: $blue;
          }
        }
        &--suggestion {
          .suggesion-list-group {
            height: calc(100vh - 2.4rem - 7.2rem - 3.6rem - 2.4rem - 2rem);
            overflow-y: auto;
            width: calc(100% + 2rem);
            padding-right: 2rem;
            &::-webkit-scrollbar {
              width: 0.2rem;
            }
    
            /* Track */
            &::-webkit-scrollbar-track {
              background: #f1f1f1;
            }
    
            /* Handle */
            &::-webkit-scrollbar-thumb {
              background: #004f9f;
            }
    
            /* Handle on hover */
            &::-webkit-scrollbar-thumb:hover {
              background: #004f9f;
            }
          }
          .suggesion-list {
            a {
              padding-top: 1.6rem;
              padding-bottom: 2rem;
              border-bottom: 1px solid $light-blue;
              position: relative;
              text-decoration: none;
              display: flex;
              padding-right: 1rem;
              &::after {
                content: '';
                background: url('./assets/images/search-page-arrow.svg') no-repeat
                  center center;
                width: 0.7rem;
                height: 0.8rem;
                display: inline-block;
                position: absolute;
                top: calc(50% - 0.4rem);
                right: 0;
              }
              .list-info {
                h4 {
                  font-family: $ef-font;
                  font-size: 1.2rem;
                  line-height: 1.2rem;
                  letter-spacing: 0.08em;
                  color: $red;
                  text-transform: uppercase;
                }
                p {
                  font-family: $text-font;
                  font-size: 1.6rem;
                  line-height: 2.4rem;
                  font-weight: 700;
                  color: $blue;
                }
              }
              .list-img {
                width: 5.1rem;
                height: 5.1rem;
                display: flex;
                margin-right: 1.6rem;
                & > img {
                  object-fit: cover;
                }
              }
              &:hover {
                .list-info {
                  p {
                    color: $blue-accent;
                    text-decoration: underline;
                  }
                }
              }
            }
          }
        }
        .see-all-cta {
          display: flex;
          padding: 0.7rem 1.6rem;
          font-family: $ef-font;
          font-size: 1.4rem;
          line-height: 198%;
          letter-spacing: 0.01em;
          color: $blue-accent;
          border: 1px solid $blue-accent;
          border-radius: 0.2rem;
          justify-content: center;
          margin: 1.6rem 0;
          margin-top: 4rem;
          cursor: pointer;
          transition: background-color 0.2s ease-in;
          &:hover {
            background-color: $blue-accent;
            color: $white;
          }
        }
        .popular-list {
          /* stylelint-disable no-descending-specificity */
          .list-info {
            max-width: 21.2rem;
          }
        }
        &--allresults {
          .allresults-tabs {
            display: flex;
            gap: 3.1rem;
            margin-top: 2.4rem;
            position: relative;
            padding-bottom: 1.2rem;
            overflow-x: auto;
            overflow-y: hidden;
            &::-webkit-scrollbar {
              width: 0.1rem;
            }
            &::after {
              content: '';
              border-bottom: 1px solid $light-blue;
              width: 100%;
              position: absolute;
              left: 0;
              bottom: 0;
            }
            a {
              @extend .text-m;
    
              color: $color-interface-light;
              text-decoration: none;
              cursor: pointer;
              position: relative;
              &::after {
                content: '';
                border-bottom: 3px solid $red;
                position: absolute;
                width: 0;
                bottom: -1.2rem;
                left: 0;
                z-index: 1;
                transition: width 0.3s ease-in-out;
              }
              &:hover,
              &[aria-selected='true'] {
                color: $blue;
                &::after {
                  width: 100%;
                }
              }
            }
          }
          .result-lists,
          .more-result-lists {
            display: flex;
            flex-direction: column;
            a {
              text-decoration: none;
              &:hover {
                .efl-search-card__title,
                .efl-search-card__description {
                  text-decoration: underline;
                }
              }
            }
          }
          .result-scroll {
            height: calc(100vh - 2.4rem - 7.2rem - 3.6rem - 2.4rem - 3.6rem - 6rem);
            overflow-y: auto;
            width: calc(100% + 2rem);
            padding-right: 2rem;
            &::-webkit-scrollbar {
              width: 0.2rem;
            }
    
            /* Track */
            &::-webkit-scrollbar-track {
              background: #f1f1f1;
            }
    
            /* Handle */
            &::-webkit-scrollbar-thumb {
              background: #004f9f;
            }
    
            /* Handle on hover */
            &::-webkit-scrollbar-thumb:hover {
              background: #004f9f;
            }
            .result-lists-norsult {
              padding-top: 1.6rem;
              font-family: $text-font;
              font-size: 2rem;
              line-height: 3.2rem;
              font-weight: 700;
              color: $blue;
            }
          }
        }
      }
    
      @media screen and (min-width: $mq-medium) {
        .lightbox-overlay__close {
          width: 4.8rem;
          height: 4.8rem;
          top: 2.4rem;
          &::before {
            width: 4.8rem;
            height: 4.8rem;
          }
        }
        &__inputgroup {
          .clear-input {
            left: 1.6rem;
          }
        }
        &__input {
          font-size: 2rem;
          line-height: 2.8rem;
          padding-top: 2.1rem;
          padding-bottom: 2.1rem;
          &.noempty {
            padding-left: 4.6rem;
            padding-right: 5.6rem;
          }
        }
        &__content {
          padding-top: 13.4rem;
          max-width: 95.1rem;
          &.search-margin {
            padding-top: 3.4rem;
          }
        }
        &__result {
          h3 {
            padding-bottom: 1.6rem;
          }
          &--suggestion {
            display: flex;
            flex-direction: column;
            h3 {
              padding-top: 4.8rem;
            }
            .suggesion-list {
              a {
                .list-info {
                  p {
                    font-family: $text-font;
                    font-size: 2rem;
                    line-height: 3.2rem;
                    font-weight: 700;
                  }
                }
              }
            }
          }
          &--allresults {
            .allresults-tabs {
              justify-content: space-between;
            }
            .result-lists,
            .more-result-lists {
              display: grid;
              grid-template-columns: 27.3rem 27.3rem 27.3rem;
              gap: 2.4rem 3.3rem;
              .efl-search-card {
                max-width: 29.5rem;
              }
            }
            .result-scroll {
              height: calc(
                100vh - 2.4rem - 7.2rem - 3.6rem - 2.4rem - 3.6rem - 4rem
              );
            }
          }
        }
      }
    }
    
    .autocomplete-customizations {
      z-index: 201;
    }
    div.efl-search-play_icon {
      position: relative;
      top: -30px;
      height: 30px;
      width: 30px;
      background: url('./assets/images/video-play-button.svg') #c30024 no-repeat;
      background-position: center;
    }
    
  • URL: /components/raw/efl-search-mechanic/efl-search-mechanic.scss
  • Filesystem Path: src/library/modules/efl-search-mechanic/efl-search-mechanic.scss
  • Size: 12.3 KB
<div class="efl-search-mechanic hidden" data-behavior="efl-search-mechanic" id="efl-search-mechanic">
    <div class="efl-search-mechanic__inputgroup" data-min-text="5">
        <input type="text" class="efl-search-mechanic__input" placeholder="Search England Football" autocomplete="off">
        <a class="clear-input" aria-label="Clear input"></a>
        <span class="line"></span>
    </div>
    <div class="efl-search-mechanic__result hidden">
        <div class="efl-search-mechanic__result--loading hidden">
            <div class="loading">
                <div class="loader"></div>
                <div class="efl-logo"></div>
            </div>
        </div>
        <div class="efl-search-mechanic__result--suggestion hidden">
            <h3>{{suggestion}}</h3>
            <div class="suggesion-list-group">
                <div class="suggesion-list">               
                    <!-- clone suggetion html object -->
                </div>
                <div class="see-all">
                    <a class="see-all-cta">{{see-all-cta}}</a>
                </div>
            </div>
        </div>
        <div class="efl-search-mechanic__result--noresult hidden">
            <h3>{{no-result}}</h3>
            <div class="suggesion-list-group">
                <div class="suggesion-list">               
                    {{no-result-info}}
                </div>
            </div>
        </div>
        <div class="efl-search-mechanic__result--allresults hidden">
            <div class="allresults-tabs" role="tablist" aria-label="Panel Tablist" >
                {{#each tablist}}
                    <a role="tab" aria-selected="{{selected}}"  aria-controls="panel-tab-{{id}}" id="tab-{{id}}" data-search-filter="{{filter}}">{{label}}</a>
                {{/each}}                
            </div>
            {{#each tablist}}
            <div role="tabpanel" id="panel-tab-{{id}}" {{#if hidden}} hidden="true" {{/if}}>
                <h3>0 Results</h3>
                <div class="result-scroll">
                    <div class="result-lists">                          
                    </div>
                    <div class="more-result-lists">                          
                    </div>
                    <div class="result-lists-norsult hidden">               
                        {{no-resulttab-info}}
                    </div>
                    <div class="loading">
                        <div class="loader"></div>
                        <div class="efl-logo"></div>
                    </div>
                </div>
            </div>
            {{/each}}            
        </div>     
    </div>
</div>