Skip to content

Commit

Permalink
combined sort function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdentremont committed Oct 10, 2023
1 parent b76df3f commit ec81ea1
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions js/facets/facets-views-ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit ec81ea1

Please sign in to comment.