Jacks_Bastards_Website/static/wagtailadmin/js/bulk-actions.js

1 line
5.4 KiB
JavaScript
Raw Permalink Normal View History

(()=>{"use strict";var e,t={4625:(e,t,c)=>{var n=c(9675);const o="[data-bulk-action-checkbox]",r="[data-bulk-action-select-all-checkbox]",d="[data-bulk-action-footer]",a="[data-bulk-action-num-objects]",l="[data-bulk-action-num-objects-in-listing]",i=document.querySelector(d).getAttribute("data-bulk-action-footer");let s={};function u(e){return wagtailConfig.STRINGS.BULK_ACTIONS[i]?wagtailConfig.STRINGS.BULK_ACTIONS[i][e]:wagtailConfig.STRINGS.BULK_ACTIONS.ITEM[e]}function h(e){document.querySelectorAll(r).forEach(t=>{t.checked=e.target.checked});const t=new Event("change");document.querySelectorAll(o).forEach(c=>{c.checked!==e.target.checked&&(c.checked=e.target.checked,e.target.checked?c.dispatchEvent(t):c.classList.remove("show"))}),e.target.checked||(s.checkedObjects.clear(),document.querySelector(d).classList.add("hidden"))}function b(e){if(e.shiftKey&&s.prevCheckedObject){const t=[...document.querySelectorAll(o)],c=t.findIndex(e=>e.dataset.objectId===s.prevCheckedObject),r=t.findIndex(t=>t.dataset.objectId===e.target.dataset.objectId),d=(c>r?r:c)+1,a=c<=r?r:c;(0,n.y)(d,a).forEach(e=>{const n=new Event("change");t[e].checked=t[c].checked,t[e].dispatchEvent(n)}),s.prevCheckedObject=e.target.dataset.objectId}}function f(e){s.selectAllInListing&&(s.selectAllInListing=!1);const t=s.checkedObjects.size;e.target.checked?s.checkedObjects.add(e.target.dataset.objectId):(document.querySelectorAll(r).forEach(e=>{e.checked=!1}),s.checkedObjects.delete(e.target.dataset.objectId));const c=s.checkedObjects.size;if(0===c?(document.querySelector(d).classList.add("hidden"),document.querySelectorAll(o).forEach(e=>e.classList.remove("show"))):1===c&&0===t&&(document.querySelectorAll(o).forEach(e=>{e.classList.add("show")}),document.querySelector(d).classList.remove("hidden")),c===s.numObjects?(document.querySelectorAll(r).forEach(e=>{e.checked=!0}),s.shouldShowAllInListingText&&document.querySelector(l).classList.remove("w-hidden")):s.shouldShowAllInListingText&&document.querySelector(l).classList.add("w-hidden"),c>0){let e="";e=1===c?u("SINGULAR"):c===s.numObjects?u("ALL").replace("%(objects)s",c):u("PLURAL").replace("%(objects)s",c),document.querySelector(a).textContent=e}s.prevCheckedObject=e.target.dataset.objectId}function g(e){e.preventDefault(),s.selectAllInListing=!0,document.querySelector(a).textContent=`${u("ALL_IN_LISTING")}.`,document.querySelector(l).classList.add("w-hidden")}function v(e){e.preventDefault();const t=e.target.getAttribute("href"),c=new URLSearchParams(window.location.search);if(s.selectAllInListing){c.append("id","all");const e=document.querySelector("[data-bulk-action-parent-id]");if(e){const t=e.dataset.bulkActionParentId;c.append("childOf",t)}}else s.checkedObjects.forEach(e=>{c.append("id",e)});window.location.href=`${t}&${c.toString()}`}document.addEventListener("DOMContentLoaded",function(){s={checkedObjects:new Set,numObjects:0,selectAllInListing:!1,shouldShowAllInListingText:!0,prevCheckedObject:null};const e=new Event("change");document.querySelectorAll(o).forEach(e=>{s.numObjects+=1,e.addEventListener("change",f),e.addEventListener("click",b)}),document.querySelectorAll(r).forEach(e=>{e.addEventListener("change",h)}),document.querySelectorAll(`${d} [data-bulk-action-button]`).forEach(e=>e.addEventListener("click",v)),document.addEventListener("w-dropdown:shown",()=>{document.querySelectorAll(`${d} [data-bulk-action-button]`).forEach(e=>{e.removeEventListener("click",v),e.addEventListener("click",v)})});const t=document.querySelector(l);t?t.addEventListener("click",g):s.shouldShowAllInListingText=!1,document.querySelectorAll(o).forEach(t=>{t.checked&&t.dispatchEvent(e)})}),document.addEventListener("w-swap:success",function(){document.querySelectorAll(r).forEach(e=>{e.checked=!1}),document.querySelector(d).classList.add("hidden"),document.querySelectorAll(r).forEach(e=>{e.removeEventListener("change",h),e.addEventListener("change",h)}),s.checkedObjects.clear(),s.numObjects=0,document.querySelectorAll(o).forEach(e=>{s.numObjects+=1,e.addEventListener("change",f)})})}},c={};function n(e){var o=c[e]