Каталог файловtilda-step-form-1.1.js
201 202 var nextBtnEl = rec.querySelector('.t-form__screen-btn-next');203 var prevBtnEl = rec.querySelector('.t-form__screen-btn-prev');204 205 if (nextBtnEl && prevBtnEl) {206 const prevButtonText = prevBtnEl.querySelector('.js-btn-txt');207 const nexButtonText = nextBtnEl.querySelector('.js-btn-txt');208 if (prevButtonText) {209 prevButtonText.innerHTML = `← ${btnPrev}`;210 }211 if (nexButtonText) {212
История файла и сравнение версий
nexButtonText.innerHTML = `${btnNext} →`;
215 t_form__parseButtonsVariables([nextBtnEl, prevBtnEl]); 220 const template = document.getElementById(`button_step_${recId}`); 221 const buttonSource = options.buttonTemplate || (template && template.content.firstElementChild); 223 const prevButton = buttonSource.cloneNode(true); 224 const nextButton = buttonSource.cloneNode(true); 225 prevButton.classList.add('t-form__screen-btn-prev'); 226 prevButton.style.display = 'none'; 227 nextButton.classList.add('t-form__screen-btn-next'); 228 const prevButtonText = prevButton.querySelector('.js-btn-txt'); 229 const nexButtonText = nextButton.querySelector('.js-btn-txt'); 230 if (prevButtonText) { 231 prevButtonText.innerHTML = `← ${btnPrev}`; 234 nexButtonText.innerHTML = `${btnNext} →`; 236 submitWrapper.insertAdjacentHTML('beforeend', `${prevButton.outerHTML}${nextButton.outerHTML}`); 239 const progressHTML = '<div class="t-form__screen-current-view t-name"></div>'; 240 submitWrapper.insertAdjacentHTML('beforeend', progressHTML); 242 t_form__parseButtonsVariables([submitWrapper]); 246 * Подставляет переменные в тексты кнопок. В редакторе Zero Block t_onFuncLoad нет, там переменные не подставляются 247 * @param {Element[]} elements 249 function t_form__parseButtonsVariables(elements) { 250 if (typeof t_onFuncLoad !== 'function') return; 251 t_onFuncLoad('t_forms__parseVariables', () => { 252 elements.forEach(function (element) { 253 t_forms__parseVariables(element); 258 // Collecting inputs in groups for step by step 259 function t_form__breakOnStep() { 260 var inputGroups = inputsbox.querySelectorAll('.t-input-group'); 261 var wrapper = t_form__createInputWrapper(); 265 Array.prototype.forEach.call(inputGroups, function (input) { 266 if (!input.classList.contains('t-input-group_st')) { 267 wrapper.appendChild(input); 270 wrapper = t_form__createInputWrapper(); 276 Array.prototype.forEach.call(inputsbox.children, function (element, index) { 277 if (element.classList.contains('t-input-group_st')) { 278 listIndex.push(index); 282 listIndex.push(listIndex[listIndex.length - 1] + 1); 284 Array.prototype.forEach.call(list, function (element, index) { 285 inputsbox.insertBefore(element, inputsbox.children[listIndex[index]]); 286 t_form__incSubsequentValue(listIndex, index + 1); 291 * Increments subsequent values in the array by one, relative to the index 292 * @param {Array} array - arr index step 293 * @param {Number} begin - begin index 295 function t_form__incSubsequentValue(array, begin) { 296 for (var i = begin; i < array.length; i++) {