Update soft-limit.js
This commit is contained in:
parent
812ca8a37d
commit
f1a680e5ad
1 changed files with 63 additions and 59 deletions
|
|
@ -1,9 +1,8 @@
|
||||||
//# sourceURL=modules/contrib/islandora/modules/advanced_search/js/facets/soft-limit.js
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
* Overrides the soft-limit.js behavior from the 'facets' module.
|
* Provides the soft limit functionality.
|
||||||
* As when having many facets the original version causes the page to slow down and snap to hidden when rendering.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function ($) {
|
(function ($) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
@ -42,28 +41,33 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hide facets over the limit.
|
||||||
|
facetsList.each(function () {
|
||||||
|
$(this).children('li:gt(' + zero_based_limit + ')').once('applysoftlimit').hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Add "Show more" / "Show less" links.
|
// Add "Show more" / "Show less" links.
|
||||||
facetsList.filter(function () {
|
facetsList.filter(function () {
|
||||||
return $(this).next('ul').length == 1; // Has expanding list.
|
return ($(this).find('li').length > limit && $(this).parent().find('a.facets-soft-limit-link').length < 1);
|
||||||
}).each(function () {
|
}).each(function () {
|
||||||
var facet = $(this);
|
var facet = $(this);
|
||||||
var expand = facet.next('ul');
|
|
||||||
var link = expand.next('a');
|
|
||||||
var showLessLabel = settings.facets.softLimitSettings[facet_id].showLessLabel;
|
var showLessLabel = settings.facets.softLimitSettings[facet_id].showLessLabel;
|
||||||
var showMoreLabel = settings.facets.softLimitSettings[facet_id].showMoreLabel;
|
var showMoreLabel = settings.facets.softLimitSettings[facet_id].showMoreLabel;
|
||||||
link.text(showMoreLabel)
|
$('<a href="#" class="facets-soft-limit-link"></a>')
|
||||||
.once()
|
.text(showMoreLabel).attr("aria-expanded", "false")
|
||||||
.on('click', function () {
|
.on('click', function () {
|
||||||
if (!expand.is(":visible")) {
|
if (facet.find('li:hidden').length > 0) {
|
||||||
expand.slideDown();
|
facet.find('li:gt(' + zero_based_limit + ')').slideDown();
|
||||||
$(this).addClass('open').text(showLessLabel);
|
facet.find('li:lt(' + (zero_based_limit + 2) + ') input').focus();
|
||||||
|
$(this).addClass('open').text(showLessLabel).attr("aria-expanded", "true");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
expand.slideUp();
|
facet.find('li:gt(' + zero_based_limit + ')').slideUp();
|
||||||
$(this).removeClass('open').text(showMoreLabel);
|
$(this).removeClass('open').text(showMoreLabel).attr("aria-expanded", "false");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
})
|
}).insertAfter($(this));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue