From ec81ea16e63a9617cfce464455f048352eb53600 Mon Sep 17 00:00:00 2001 From: Josh d'Entremont Date: Tue, 10 Oct 2023 16:15:17 -0300 Subject: [PATCH] combined sort function calls --- js/facets/facets-views-ajax.js | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/js/facets/facets-views-ajax.js b/js/facets/facets-views-ajax.js index 2ffb70a..f918167 100644 --- a/js/facets/facets-views-ajax.js +++ b/js/facets/facets-views-ajax.js @@ -246,35 +246,20 @@ window.history.pushState(null, document.title, $(this).attr("href")); }); - /* digitalutsc added */ - $(once('params-sort', '.pager__sort select[name="order"]')) + // Trigger on sort change. + $(once('params-sort', '[data-drupal-pager-id] select[name="order"], .pager__sort select[name="order"]')) .change(function () { var href = window.location.href; var params = Drupal.Views.parseQueryString(href); var selection = $(this).val(); var option = selection.split('_'); - //params.sort_by = option[0]; params.sort_order = option[option.length - 1].toUpperCase(); params.sort_by = selection.replace("_" + option[option.length - 1], ""); - href = href.split("?")[0] + "?" + $.param(params); window.history.pushState(null, document.title, href); }); - - // Trigger on sort change. - $(once('sort-change', '[data-drupal-pager-id] select[name="order"]')) - .change(function () { - var href = window.location.href; - var params = Drupal.Views.parseQueryString(href); - var selection = $(this).val(); - var option = $('option[value="' + selection + '"]'); - params.sort_order = option.data("sort_order"); - params.sort_by = option.data("sort_by"); - href = href.split("?")[0] + "?" + $.param(params); - window.history.pushState(null, document.title, href); - }); }, }; })(jQuery, Drupal);