Некодим© 2020-2026 Некодим
Готовые модификации для вашего сайта. Улучшайте функциональность и дизайн без программирования.
Журнал изменений История Git Файлы Tilda MCP Каталог файловtilda-zero-forms-1.0.js Следить за файлом 4701 t_zeroForms__combineFieldsWithDefWidth(allLastFieldsWithDefWidth);4702 }4703 }4704 4705 /**4706 * Adds margin-right to the last field in row if common width of fields in row > 100%4707 * @param {Object} allLastFields4708 */4709 function t_zeroForms__moveFieldToNextRow(allLastFields) {4710 var rows = t_zeroForms__createArrWithAllRows(allLastFields, 't-input-group_inrow');4711 rows.forEach(function (row) {4712 История файла и сравнение версий var isLongNextField = false;
4713 row.forEach(function (field) {4715 field.classList.contains('t-input-group_inrow-last') &&4716 field.nextElementSibling &&4717 !field.nextElementSibling.classList.contains('t-input-group_inonerow')4719 isLongNextField = true;4722 if (isLongNextField) return;4724 // Считаем общую ширину всех полей в ряду4725 var commonWidth = row.reduce(function (sum, field) {4726 var fieldClasses = field.classList.value.split(' ');4727 var widthClass = fieldClasses.filter(function (fieldClass) {4728 return fieldClass.indexOf('t-input-group_width') !== -1;4730 widthClass = widthClass[0];4732 var characterQuantity = 2;4733 if (widthClass.indexOf('100') !== -1) {4734 characterQuantity = 3;4736 var fieldWidth = Number(widthClass.substr(widthClass.length - 2, characterQuantity));4737 return sum + fieldWidth;4739 if (commonWidth <= 100) return;4741 // Если ширина > 100, добавляем отступ к последнему полю,4742 // чтобы следующее за ним короткое поле переносилось в следующий ряд4743 row.forEach(function (field) {4744 if (field.classList.contains('t-input-group_inrow-last')) {4745 field.style.marginRight = 'calc(100% - (' + (commonWidth - 100) + '%)';4746 field.style.flex = '0 0 auto';4753 * Combine fields with default width into row4754 * @param {Object} allLastFields4756 function t_zeroForms__combineFieldsWithDefWidth(allLastFields) {4757 var allRowsWithDefWidth = [];4758 var rows = t_zeroForms__createArrWithAllRows(allLastFields, 't-input-group_widthdef');4760 rows.forEach(function (row) {4761 var maxRowLength = 4;4762 if (row.length > maxRowLength) {4763 for (var i = 0; i < row.length; i += maxRowLength) {4764 var newRow = row.slice(i, i + maxRowLength);4765 allRowsWithDefWidth.push(newRow);4768 allRowsWithDefWidth.push(row);4772 allRowsWithDefWidth.forEach(function (row) {4778 var widthClass = 't-input-group_width' + (rowWidth[row.length] || '100');4780 row.forEach(function (field) {4781 field.classList.add(widthClass);4787 * Creates array with every row in form4788 * @param {Object} allLastFields4789 * @param {String} certainClass4792 function t_zeroForms__createArrWithAllRows(allLastFields, certainClass) {4793 var allSequences = [];4794 var oneSequence = [];4796 // Создаём массив с подмассивами из всех последовательностей4797 // с полями в одном ряду4798 Array.prototype.forEach.call(allLastFields, function (field) {4799 oneSequence.push(field);