Sha256: a27f96b5614f35a51776df987f096e999c044b0a06faed19c625d053110d7385
Contents?: true
Size: 1.3 KB
Versions: 15
Compression:
Stored size: 1.3 KB
Contents
// = require_self ((exports) => { const { pushState, registerCallback } = window.Decidim.History; const initializeListingOptionsMenu = (options) => { exports.$(document).on("click", `${options.containerSelector} a`, (event) => { const $target = $(event.target); $target.parents(".menu").find("a:first").text($target.text()); pushState($target.attr("href")); }) registerCallback(options.callbackName, () => { const url = window.location.toString(); const match = url.match(/${options.urlParameter}=([^&]*)/); const $targetMenu = $(`${options.containerSelector} .menu`); let value = $targetMenu.find(".menu a:first").data(options.dataAttribute); if (match) { value = match[1]; } const linkText = $targetMenu.find(`.menu a[data-${options.dataAttribute}="${value}"]`).text(); $targetMenu.find("a:first").text(linkText); }); }; exports.$(() => { initializeListingOptionsMenu({ containerSelector: ".order-by", callbackName: "orders", urlParameter: "order", dataAttribute: "order" }); initializeListingOptionsMenu({ containerSelector: ".results-per-page", callbackName: "results_per_page", urlParameter: "per_page", dataAttribute: "per-page-option" }); }); })(window)
Version data entries
15 entries across 15 versions & 1 rubygems