PageSourceSearch

https://www.nano-di.com/wp-content/themes/berg-theme-child/inc/fac…/js/facetwp-custom-functions.js?ver=6.9.7

js nano-di.com collected 2026-09-24 21:19:39 UTC 4,925 bytes, 148 lines download raw bytes

1(function ($) {
2
3  $(window).on("load", () => {
4    if (typeof FWP != "undefined") {
5      let queryString = FWP.buildQueryString();
6      if ('' === queryString) { // no facets are selected
7        $('.reset-selection').hide();
8        $('.facetwp-filter-tags button.remove-facet').remove();
9      } else {
10        $('.reset-selection').show();
11      }
12
13      const facets = FWP.facets;
14      //on page reload, when facet filter items applied, uncheck the relavent facet 'All' checkbox
15      $.each(facets, (key, facet) => {
16        if (facets[key].length) {
17          $(`.facetwp-all-${key}`).removeClass('checked');
18        }
19      });
20    }
21  });
22
23  //hide reset button when facet items are not selected
24  $(document).on('facetwp-loaded', () => {
25    let $resetSelection = $('.facetwp-filter-tags-wrapper .reset-filters');
26    let $selectedFilters = $('.facetwp-filter-tags-wrapper .facetwp-filter-tags');
27    $selectedFilters.html('');
28    let queryString = FWP.buildQueryString();
29    if ('' === queryString) { // no facets are selected
30      $resetSelection.hide();
31    } else {
32      $resetSelection.show();
33      let $facets = FWP.facets;
34      $.each($facets, (facetName, facet) => {
35        if ($.isArray($facets[facetName])) {
36          if ($facets[facetName].length > 0) {
37            $.each(facet, (key, value) => {
38              let $tag = '<button class="remove-facet" data-facet=' + facetName + ' data-value=' + value + '>' + makeTitle(value) + '</button>'
39              $selectedFilters.append($tag);
40            });
41          }
42        } else {
43          if (facet.length > 0) {
44            let $tag = '<button class="remove-facet" data-facet=' + facetName + ' data-value=' + facet + '>' + makeTitle(facet) + '</button>'
45            $selectedFilters.append($tag);
46          }
47        }
48      });
49    }
50
51    if (FWP.settings.pager.total_pages <= 1) {
52      // hide pagination
53      $('.facetwp-type-pager').hide();
54    } else {
55      // show pagination
56      $('.facetwp-type-pager').show();
57    }
58
59    // Featured section toggle class hide-featured
60    if ($('.facetwp-pager, .facetwp-load-more').length) {
61      const featuredPostBlock = $('.bs-posts__featured');
62      const featuredSection = featuredPostBlock.closest('section');
63      const hasFeaturedPost = featuredPostBlock.find('.bs-post').length;
64      if (FWP.settings.pager.page <= 1 && hasFeaturedPost) {
65        // 1st page
66        featuredSection.show();
67        featuredSection.prev().removeClass('hide-featured');
68      } else {
69        // Other pages
70        featuredSection.hide();
71        featuredSection.prev().addClass('hide-featured');
72      }
73    }
74
75    const facets = FWP.facets;
76    //on facet load, when facet filter items applied, uncheck the relavent facet 'All' checkbox
77    $.each(facets, (key, facet) => {
78      if (facets[key].length) {
79        $(`.facetwp-all-${key}`).removeClass('checked');
80      } else {
81        $(`.facetwp-all-${key}`).addClass('checked');
82      }
83    });
84
85    postAppendWrapper();
86    addVideosToPlaylist();
87  });
88
89  // click on remove icon on filter tag
90  $(document).on('click', '.remove-facet', (e) => {
91    let self = e.target.dataset;
92    FWP.is_reset = true;
93    if ($.isArray(FWP.facets[self.facet])) {
94      FWP.facets[self.facet].splice(FWP.facets[self.facet].indexOf(self.value), 1);
95      delete FWP.facets['paged'];
96
97    } else {
98      $('button[data-facet=' + self.facet + ']').remove();
99      FWP.facets[self.facet] = [];
100    }
101    FWP.refresh();
102  });
103
104  function makeTitle(slug) {
105    let words = slug.split('-');
106    for (let i = 0; i < words.length; i++) {
107      let word = words[i];
108      words[i] = word.charAt(0).toUpperCase() + word.slice(1);
109    }
110    return words.join(' ');
111  }
112
113  const postAppendWrapper = () => {
114    const eventNormalPost = $('.facetwp-template[data-name="upcoming_event_list"]');
115    const innerMenuWrapper = eventNormalPost.find('.bs-post__inner');
116    innerMenuWrapper.each((index, element) => {
117      if ($(element).find('.bs-post__taxonomy-wrapper').length == 0) {
118        $(element)
119          .find(
120            '.bs-post-event_date, .bs-post-taxonomy_event-location'
121          )
122          .wrapAll('<div class="bs-post__taxonomy-wrapper" />');
123      }
124    });
125  };
126
127  const addVideosToPlaylist = () => {
128    window._wq = window._wq || [];
129    let wistiaVideoDiv = $(".wistia-video-div")
130    let allIds = wistiaVideoDiv.map(function () {
131      return $(this).data("id");
132    }).get();
133    wistiaVideoDiv.each((i, e) => {
134      let wistiaVideoId = $(e).data("id");
135      if (allIds.length) {
136        const currentIndex = allIds.indexOf(wistiaVideoId);
137        const nextIndex = (currentIndex + 1) % allIds.length;
138        const nextVideoId = allIds[nextIndex];
139        _wq.push({
140          id: wistiaVideoId,
141          onHasData: function (video) {
142            video.addToPlaylist(nextVideoId);
143          }
144        });
145      }
146    });
147  };
148})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.