/** hide entire section of facets if none have options
** facet-wrap is individual facet wrapper element
** facetwp-wrapper is wrapper elenement around all facets (grandparent)
**/
function($) {
document.addEventListener('facetwp-loaded', function() {
var $all = 0; // for checking all facets
$.each(FWP.settings.num_choices, function(key, val) {
var $facet = $('.facetwp-facet-' + key);
var $parent = $facet.closest('.facet-wrap');
var $flyout = $facet.closest('.flyout-row');
if ($parent.length || $flyout.length) {
var $which = $parent.length ? $parent : $flyout;
(0 === val) ? $which.hide() : $which.show();
}
$all += val; // add any values from this facet
});
(0 === $all) ? $('.facetwp-wrapper').hide() : $('.facetwp-wrapper').show(); // show hide wrapper depending on whether any facets had values
});
})(jQuery);