2201input.ariaLabel = type;2202} else {2203input.id = 'input_' + elementObj.lid;2204}2205t_zeroForms__appendMainSettingToField(input, inputPreferences, type, '');2206var tildaRuleTypes = ['name', 'time', 'url', 'email'];2207var isTildaRuleType = tildaRuleTypes.some(function (tildaRuleType) {2208return tildaRuleType === type;2209});2210if (isTildaRuleType) input.setAttribute('data-tilda-rule', type);22112212
if (type === 'time') { input.setAttribute('data-tilda-mask', '99:99'); input.classList.add('t-inputtime'); } if (type === 'time' || (type === 'oneline' && elementObj.li_mask)) input.classList.add('js-tilda-mask'); if (type === 'oneline') { if (inputPreferences.rule) input.setAttribute('data-tilda-rule', inputPreferences.rule); if (inputPreferences.mask) input.setAttribute('data-tilda-mask', inputPreferences.mask); } t_zeroForms__appendAttributes(input, inputPreferences); t_zeroForms__appendStylesToField(input, inputStyles); if (type === 'textarea') { var textAreaStyleContent = '.t396__elem .t-input-group_ta textarea.t-input {padding-top:10px; vertical-align: bottom; resize: none; overflow-x: hidden;}'; t_zeroForms__addInlineTag({ tag: 'style', id: 'zero-forms-textarea-styles', content: textAreaStyleContent, zeroForm: null, }); t_zeroForms__setTextareaHeight(elementObj, input); } return input;}/** * * @param {FormObjectEl} elementObj * @param {HTMLTextAreaElement} textarea */function t_zeroForms__setTextareaHeight(elementObj, textarea) { var textAreaRowHeight = 25; var textAreaPadding = 10; if (elementObj.li_rows > 1) { textarea.style.height = elementObj.li_rows * textAreaRowHeight + textAreaPadding + 'px'; textarea.setAttribute('data-rows', elementObj.li_rows); } textarea.rows = parseInt(elementObj.li_rows, 10) || 3;}function t_zeroForms__createSelect(elementObj, inputStyles, inputPreferences, hasBBOnly) { var options = elementObj.li_variants ? elementObj.li_variants.split('\n') : []; var selectedOption = parseInt(elementObj.li_defselitem, 10); var inputWrapper = document.createElement('div'); inputWrapper.classList.add('t-select__wrapper'); if (inputPreferences.secondaryClassName) inputWrapper.classList.add('t-select__wrapper_bbonly'); var input = document.createElement('select'); input.id = 'input_' + elementObj.lid; t_zeroForms__appendMainSettingToField(input, inputPreferences, '', 't-select'); if (inputPreferences.secondaryClassName) input.classList.add('t-select_bbonly'); if (inputPreferences.require) input.setAttribute('data-tilda-req', '1'); t_zeroForms__appendStylesToField(input, inputStyles); var optionHasColor = inputStyles && inputStyles.color && !hasBBOnly; if (elementObj.li_selfirstvar) { var firstOption = document.createElement('option'); firstOption.innerHTML = elementObj.li_selfirstvar; firstOption.setAttribute('value', ''); if (optionHasColor) firstOption.style.color = inputStyles.color; input.insertAdjacentElement('beforeend', firstOption); } var optionHasColor = inputStyles && inputStyles.color && !hasBBOnly; options.forEach(function (option, i) { var optionEl = document.createElement('option'); const { label, labelText, calcValue } = t396_zeroForms__prepareCalcValue(elementObj, option); if (calcValue) { t396_zeroForms__setCalcValue(optionEl, calcValue); } optionEl.value = labelText; optionEl.innerHTML = label; if (optionHasColor) optionEl.style.color = inputStyles.color; if (selectedOption && selectedOption === i + 1) optionEl.selected = true; input.insertAdjacentElement('beforeend', optionEl); }); inputWrapper.insertAdjacentElement('beforeend', input); return inputWrapper;}function t_zeroForms__createRadio(elementObj, formObj, inputPreferences, labelStyles, inputType, recid, formID) { var radioOptions = elementObj.li_variants ? elementObj.li_variants.split('\n') : []; var hasOwnAnswer = elementObj.li_isownvariant === 'y';