Added handle for .is-active for pager linke in Pager block with ajax

This commit is contained in:
Kyle Huynh 2022-01-27 04:39:35 +00:00
parent 17274d141e
commit 3e3b68c72d
3 changed files with 34 additions and 4 deletions

View file

@ -77,7 +77,6 @@
Drupal.behaviors.islandoraAdvancedSearchViewsAjax = {
attach: function (context, settings) {
window.historyInitiated = true;
// Remove existing behavior from form.
if (settings && settings.views && settings.views.ajaxViews) {
$.each(settings.views.ajaxViews, function (index, settings) {
@ -114,7 +113,34 @@
});
});
});
if (window.location.search.includes("display=") === true) {
$("li.pager__item a.pager__display").each(function () {
$(this).parent().removeClass("is-active");
$(this).removeClass("pager__link--is-active");
if ($(this).text().trim().toLowerCase() === getParam(window.location.search, "display").trim().toLowerCase()) {
$(this).addClass("pager__link--is-active");
}
});
}
if (window.location.search.includes("items_per_page=") === true) {
$("li.pager__item a.pager__itemsperpage").each(function() {
$(this).parent().removeClass("is-active");
$(this).removeClass("pager__link--is-active");
if ($(this).text().trim().toLowerCase() === getParam(window.location.search, "items_per_page").trim().toLowerCase()) {
$(this).addClass("pager__link--is-active");
}
});
}
}
function getParam(urlstring, param) {
var searchparam = new URLSearchParams(urlstring);
return searchparam.get(param);
}
// Attach behavior to pager, summary, facet links.
$("[data-drupal-pager-id], [data-drupal-facets-summary-id], [data-drupal-facet-id]")