Каталог файловtilda-zero-forms-1.0.js
4201 * @param {HTMLDivElement | HTMLLabelElement} textEl4202 * @param titleStyles4203 * @param {string} titleFontWeight4204 */4205function t_zeroForms__setTitleStyles(textEl, titleStyles, titleFontWeight) {4206 var isTitle = textEl.classList.contains('t-input-title');4207 textEl.style.color = titleStyles.color || '';4208 textEl.style.fontFamily = titleStyles.fontFamily || '';4209 if (!textEl.style.fontFamily && titleStyles.fontFamily) {4210 textEl.style.fontFamily = '"' + titleStyles.fontFamily + '"';4211 }
История файла и сравнение версий
textEl.style.paddingBottom = titleStyles.paddingBottom ? titleStyles.paddingBottom + 'px' : '';
4213 if (isTitle) textEl.style.fontSize = titleStyles.fontSize ? titleStyles.fontSize + 'px' : ''; 4214 if (isTitle && titleFontWeight) textEl.style.fontWeight = titleFontWeight; 4217/* ============== support functions ============== */ 4220 * if zeroblock placed inside innactive tab, don't render it 4222 * @param {HTMLElement} rec 4223 * @returns {boolean} 4225function t_zeroForms__isRecordHidden(rec) { 4226 if (!rec) return false; 4227 if (rec.getAttribute('data-connect-with-tab') !== 'yes') return false; 4228 var classList = ['t397__off', 't395__off', 't400__off']; 4229 return classList.some(function (className) { 4230 return rec.classList.contains(className); 4235 * if form placed outsize zeroblock (left/right), don't render it. 4236 * Don't necessary use form bottom pos, because non-render form will have 0px height. 4238 * @param {HTMLElement} form 4239 * @returns {boolean} 4241function t_zeroForms__isFormOutside(form) { 4242 var animationAttributes = ['data-animate-sbs-opts', 'data-animate-style']; 4243 var hasAnimation = animationAttributes.some(function (attribute) { 4244 return form.hasAttribute(attribute); 4246 var artBoard = form.closest('.t396__artboard'); 4247 if (!artBoard || hasAnimation) return false; 4249 var overflow = t396_ab__getFieldValue(artBoard, 'ovrflw'); 4250 var isOverflow = overflow === 'auto' || overflow === 'custom'; 4251 if (isOverflow) return false; 4253 var artBoardPos = artBoard.getBoundingClientRect(); 4254 var formPos = form.getBoundingClientRect(); 4255 var artBoardRightPos = artBoardPos.right + window.pageXOffset; 4256 if (formPos.right < 0 && artBoardRightPos > 0) return true; 4258 var overflowValue = artBoard ? artBoard.getAttribute('data-artboard-ovrflw') : false; 4259 var isOverflowNotHidden = overflowValue === 'auto' || overflowValue === 'visible'; 4260 if (isOverflowNotHidden) return false; 4262 var formScaleFactor = t396_zeroForms__getScaleFactor(form); 4263 var formLeftPos = t_zeroForms__setScaleFactor(formPos.left, formScaleFactor); 4264 var formTopPos = t_zeroForms__setScaleFactor(parseInt(form.style.top, 10), formScaleFactor) || 0; 4266 // если форма не сильно выше верхней границы артборда - не скрывать её 4267 if (formTopPos < 0 && formTopPos > -50) formTopPos = 0; 4268 var hasFixedAnimation = form.hasAttribute('data-animate-fix'); 4269 var hasParallax = form.getAttribute('data-animate-prx') === 'scroll'; 4270 var isVerticalTopOutside = formTopPos < 0 && !hasFixedAnimation && !hasParallax; 4271 var isVerticalBotttomOutside = artBoardPos.height > 0 && formTopPos > artBoardPos.height && !hasParallax; 4273 return isVerticalTopOutside || isVerticalBotttomOutside || formLeftPos > artBoardRightPos; 4276function t_zeroForms__setScaleFactor(value, scaleFactor) { 4277 if (window.shouldUseScaleFactor) return value * scaleFactor; 4281function t_zeroForms__getFieldValue(element, attrName, prop) { 4282 if (!element || typeof window.tn === 'undefined') return; 4284 var artBoard = element.closest('.t396__artboard, .tn-artboard'); 4285 var abResObj = t_zeroForms__getResOpts(artBoard); 4286 var postfix = attrName === 'data-field' ? '-value' : ''; 4287 var desktopAttr = t_zeroForms__generateAttribute(attrName, prop, postfix, false); 4289 if (abResObj.res === abResObj.resMax) return element.getAttribute(desktopAttr); 4291 var responsiveAttr = t_zeroForms__generateAttribute(attrName, prop, postfix, abResObj.res); 4292 var currentValue = element.getAttribute(responsiveAttr); 4293 if (typeof currentValue === 'string') return currentValue; 4295 abResObj.breakpoints.forEach(function (breakpoint) { 4296 if (breakpoint <= abResObj.res || typeof currentValue === 'string') return; 4297 var curBreakpointAttr = t_zeroForms__generateAttribute(attrName, prop, postfix, breakpoint); 4298 currentValue = element.getAttribute(curBreakpointAttr);