4401* after trigger checkboxes4402*/4403function t_zeroForms__updateCheckboxesValues(e) {4404var inputWrapper = e.target.closest('[data-input-lid]');4405var checkedCheckboxes = Array.prototype.slice.call(inputWrapper.querySelectorAll('.t-checkbox:checked'));4406var value = '';4407checkedCheckboxes.forEach(function (checkbox) {4408if (value) value += '; ';4409value += checkbox.value;4410});4411var hiddenInput = inputWrapper.querySelector('.t-checkboxes__hiddeninput');4412
if (hiddenInput) { hiddenInput.value = value; hiddenInput.dispatchEvent(new Event('change', { bubbles: true, cancelable: true })); }}/** * support function to update quanity count by click. * we should trigger input event to correct update calculation field * * @param e */function t_zeroForms__initQuanityClickCount(e) { const quantityBtn = e.target.closest('.t-inputquantity__btn'); if (!quantityBtn) return; const currentParent = quantityBtn.closest('[data-input-lid]'); const currentInput = currentParent.querySelector('.t-inputquantity'); const isMinusBtn = quantityBtn.closest('.t-inputquantity__btn-minus'); const inputEvent = new Event('input', { bubbles: true, cancelable: true, }); const changeEvent = new Event('change', { bubbles: true, cancelable: true, }); if (isMinusBtn) { if (currentInput.value > 0) { currentInput.value = Number(currentInput.value) - 1; currentInput.dispatchEvent(inputEvent); currentInput.dispatchEvent(changeEvent); } } else if (currentInput.value >= 0) { currentInput.value = Number(currentInput.value) + 1; currentInput.dispatchEvent(inputEvent); currentInput.dispatchEvent(changeEvent); }}/** * support function to close errorbox * * @param e */function t_zeroForms__initErrorBoxClose(e) { var closeBtn = e.target.closest('.js-errorbox-close'); if (closeBtn) closeBtn.parentElement.style.display = 'none';}function t_zeroForms__onReady(func) { document.readyState !== 'loading' ? func() : document.addEventListener('DOMContentLoaded', func);}/** * run callback function after render zero-form * * @param {HTMLElement} form * @param {Boolean} modeChecked * @param {Function} callback */function t_zeroForms__onRender(form, modeChecked, callback) { if ((window.tildamode === 'edit' || window.tildamode === 'zero') && modeChecked) return; t_zeroForms__onReady(function () { form.classList.contains('zero-form-rendered') ? callback() : form.addEventListener('render', callback); });}/** * Вызывает callback после текущего рендера формы, когда сгенерированные поля уже находятся в DOM. Работает во всех режимах. * В отличие от t_zeroForms__onRender, не вызывает callback сразу, если форма уже была отрендерена: * при повторном рендере (например, в редакторе) callback вызвался бы до того, как новые поля попадут в DOM. * * @param {HTMLElement} form * @param {Function} callback */function t_zeroForms__onNextRender(form, callback) { form.addEventListener('render', callback, { once: true });}/** * get tildamode * * @returns {'edit' | 'preview'| 'published' | 'zero' | undefined} - void if attr in switch case cannot find current options */function t_zeroForms__getTildaMode() { if (typeof window.tildamode !== 'undefined') { return window.tildamode; } var allRec = document.getElementById('allrecords');