{"version":3,"sources":["views-exposed-form-details.js"],"names":["jQuery","Drupal","behaviors","summary","querySelectorAll","attach","allDetails","details","updatedText","document","innerText","forEach","addEventListener","e","open","el","target","some","removeAttribute","setTimeout","closeAllDetailsOnClickOutside","length","closeDetailsOnFocusOut","labels","formRadiosWrapper","formCheckboxesWrapper","elementsWrapper","inputs","clientHeight","scrollTop","label","offsetTop","offsetHeight","scrollBottom","elementBottom","classList","add","inputElem","name","charAt","toUpperCase","slice","remove","detailsElem","closest","changingDetailsSummaryText"],"mappings":"69BAgHOA,OAfDC,OAIIC,UAAMC,wBAAsBC,CAgBlCC,OAAQ,WAdF,IAlGmBC,EAGHA,EA+FhBC,EAAIC,mBAAWC,SAAfL,iBAA2B,aAlGRE,EAoGTI,GAnGLC,QAAQ,SAACJ,GAClBA,EAAQK,iBAAiB,SAAU,SAACC,GAC9BN,EAAQO,MACVR,EAAWK,QAAQ,SAACI,GACdA,IAAOF,EAAEG,QAAUD,EAAGD,OACxBC,EAAGD,MAAO,SAHER,EAkGTC,EAjGPD,SAAAA,iBAAmB,QAACS,SAAOF,GACzBP,EAAMW,KAAOD,SAAAA,GAAAA,OAAUD,EAAGD,SAAMD,EAAAG,WAC9BD,EAAGD,QAAO,SAAAC,GAAA,OAAVA,EAAAG,gBAAA,YAgGFX,EA1FTI,QAAA,SAAAJ,GAYGA,EAAQK,iBAAiB,WAAY,WAVzCO,WAASC,WACwC,IAAtCR,EAAAA,iBAA0B,2DAAYS,SACxCf,EAAAA,MAAgB,IAAgC,SAuF/CC,EAjFDe,QAAAA,SAAAA,GACIX,mBAAQJ,EAACA,iBAAY,UAE5BY,QAAW,SAAAJ,GACTA,EAAAH,iBAAYR,QAAAA,WACVG,IAAAA,EAAAQ,EAAeQ,OAAf,GACDC,EAAAjB,EAAAH,iBAAA,gBAHHqB,EAAAlB,EAAAH,iBAAA,oBADFsB,EAAA,KAUJF,EAAAH,OACAK,EAAAF,EAAA,GAcmBC,EAAsBJ,SAC/BK,EAAkBD,EAAsB,IAZlC,OAANE,IAgBqBD,EAAgBE,aAAeF,EAAgBG,WAdnElB,EAAQmB,EAAQC,UAAAD,EAAAE,cAGbR,EAAAA,UAA4BpB,EAARsB,EAA1BE,aACMH,EAAAA,UAAwBlB,EAAQH,YAClCsB,EAAeG,UAAnBC,EAAAC,kBA2DCxB,EAlDCI,QAAMsB,SAAAA,GACN,IAGEP,EAHFC,EAAMO,mBAAAA,EAAgBJ,iBAAkBA,8BAEpCI,EAAJP,EAAIO,SAAJ1B,GACEkB,EAAAA,EAAgBG,IACPN,OAAkBG,GAAAA,YAC3BA,EAAAA,EAAgBG,iBAAkBE,WAAlC,GAEH,QAAAvB,GArBHL,EAAAgC,UAAAC,IAAA,WADFjC,EAAAO,UAAA2B,EAAAC,KAAAC,OAAA,GAAAC,cAAAH,EAAAC,KAAAG,MAAA,KA0BHtC,EAAAgC,UAAAO,OAAA,WAgBOvC,EAAQO,UAAYF,MAsCGD,EA9CnBC,QAAW,SAAAD,GACXJ,mBAAUI,EAAQH,iBAAiB,sBAErCI,QAAAA,SAAAA,GACFL,EAAAA,iBAAkBiC,QAAI,WACtBjC,IAAAA,EAAoBkC,EAAAA,OAAUC,GAAAA,UACzBK,EAAA5B,EAAA6B,QAAA,WACLzC,EAAQgC,EAAiB/B,iBAAzB,WAAA,GAED,QAAAI,GACFL,EAAAgC,UAAAC,IAAA,WAfHjC,EAAAO,UAAAK,EAAAuB,KAAAC,OAAA,GAAAC,cAAAzB,EAAAuB,KAAAG,MAAA,KAiCQtC,EAAQgC,UAAUO,OAAO,WAd1BG,EAAAA,UAAAA,GAEClB,EAAMb,MAAA","file":"views-exposed-form-details.js","sourcesContent":["/* eslint no-undef: \"off\" */\n\n'use strict';\n\n(function ($, Drupal) {\n function closeOtherDetails(allDetails) {\n allDetails.forEach((details) => {\n details.addEventListener('toggle', (e) => {\n if (details.open) {\n allDetails.forEach((el) => {\n if (el !== e.target && el.open) {\n el.open = false;\n }\n });\n }\n });\n });\n }\n\n function closeAllDetailsOnClickOutside(allDetails) {\n document.addEventListener('click', function(e) {\n if (!allDetails.some((el) => el.contains(e.target))) {\n allDetails.forEach((el) => el.removeAttribute('open'));\n }\n });\n }\n\n function closeDetailsOnFocusOut(allDetails) {\n allDetails.forEach((details) => {\n details.addEventListener('focusout', () => {\n setTimeout(function() {\n if (details.querySelectorAll('input:focus, .form-checkboxes:focus, .form-radios:focus').length === 0) {\n details.open = false;\n }\n }, 1000);\n });\n });\n }\n\n // Enabling interaction with the keyboard\n // If element has focus will be scrolled so that it is visible\n function scrollingInputsInDetails(allDetails) {\n allDetails.forEach((details) => {\n const inputs = [...details.querySelectorAll('input')];\n\n inputs.forEach((el) => {\n el.addEventListener('focus', () => {\n const label = el.labels[0];\n const formRadiosWrapper = details.querySelectorAll('.form-radios');\n const formCheckboxesWrapper = details.querySelectorAll('.form-checkboxes');\n let elementsWrapper = null;\n\n if (formRadiosWrapper.length) {\n elementsWrapper = formRadiosWrapper[0];\n } else if (formCheckboxesWrapper.length) {\n elementsWrapper = formCheckboxesWrapper[0];\n }\n\n if (elementsWrapper !== null) {\n const scrollBottom = elementsWrapper.clientHeight + elementsWrapper.scrollTop;\n const elementBottom = label.offsetTop + label.offsetHeight;\n\n if (elementBottom > scrollBottom) {\n elementsWrapper.scrollTop = elementBottom - elementsWrapper.clientHeight;\n } else if (label.offsetTop < elementsWrapper.scrollTop) {\n elementsWrapper.scrollTop = label.offsetTop;\n }\n }\n });\n });\n });\n }\n\n function setDetailsSummaryText(allDetails) {\n allDetails.forEach((details) => {\n const inputs = [...details.querySelectorAll('input[type=radio]:checked')];\n\n if (inputs.length > 0) {\n const inputElem = inputs[0];\n const updatedText = inputElem.labels[0].textContent;\n const summary = details.querySelectorAll('summary')[0];\n\n if (updatedText === 'Any') {\n summary.classList.add('default');\n summary.innerText = inputElem.name.charAt(0).toUpperCase() + inputElem.name.slice(1);\n } else {\n summary.classList.remove('default');\n summary.innerText = updatedText;\n }\n }\n });\n }\n\n function changingDetailsSummaryText(allDetails) {\n allDetails.forEach((details) => {\n const inputs = [...details.querySelectorAll('input[type=radio]')];\n\n inputs.forEach((el) => {\n el.addEventListener('click', () => {\n const updatedText = el.labels[0].innerText;\n const detailsElem = el.closest('details');\n const summary = detailsElem.querySelectorAll('summary')[0];\n\n if (updatedText === 'Any') {\n summary.classList.add('default');\n summary.innerText = el.name.charAt(0).toUpperCase() + el.name.slice(1);\n } else {\n summary.classList.remove('default');\n summary.innerText = updatedText;\n }\n detailsElem.open = false;\n });\n });\n });\n }\n\n Drupal.behaviors.viewsExposedFormDetails = {\n attach: () => {\n const details = [...document.querySelectorAll('details')];\n\n closeOtherDetails(details);\n closeAllDetailsOnClickOutside(details);\n closeDetailsOnFocusOut(details);\n scrollingInputsInDetails(details);\n setDetailsSummaryText(details);\n changingDetailsSummaryText(details);\n }\n }\n}(jQuery, Drupal))\n"]}