- Issue created by @ifrik
- πΊπ¦Ukraine khiminrm
I need this feature too.
As a quick solution I've taken javascript from the facet's module soft-limit.js, modified it to use hardcoded limit, labels, selectors and used it in custom theme. But still need to exclude some filters.function softLimit() { // Soft limit. var limit = 15; var zero_based_limit = (limit - 1); var facetsList = $('..bef-checkboxes'); // Hide facets over the limit. facetsList.each(function () { var allLiElements = $(this).find('.form-check'); $(once('applysoftlimit', allLiElements.slice(zero_based_limit + 1))).hide(); }); // Add "Show more" / "Show less" links. $(once('applysoftlimit', facetsList.filter(function () { return $(this).find('.form-check').length > limit; }))).each(function () { var facet = $(this); var showLessLabel = Drupal.t('Show less'); var showMoreLabel = Drupal.t('Show more'); $('<a href="#" class="facets-soft-limit-link"></a>') .text(showMoreLabel) .on('click', function () { if (facet.find('.form-check:hidden').length > 0) { facet.find('.form-check:gt(' + zero_based_limit + ')').slideDown(); facet.find('.form-check:lt(' + (zero_based_limit + 2) + ') a, .form-check:lt(' + (zero_based_limit + 2) + ') input').focus(); $(this).addClass('open').text(showLessLabel); } else { facet.find('.form-check:gt(' + zero_based_limit + ')').slideUp(); $(this).removeClass('open').text(showMoreLabel); } return false; }).insertAfter($(this)); }); }
- π³πΏNew Zealand dieuwe Auckland, NZ
This would be a great feature, one of the few things missing out of the box with Facets 3 integration with BEF.
The sample JS code there was very helpful for a temporary custom implementation, just a note that "form-item" is the class I needed on my theme as I don't have "form-check" (another option would have been "form-type-checkbox").