Каталог файловtilda-zero-forms-1.0.js
3301 3302function t_zeroForms__generateBtnStyles(btn, recid, formID, formObj, zeroForm) {3303 const btnFontFamily = window.getComputedStyle(btn).fontFamily;3304 const buttonStyles = t_zeroForms__generateButtonStyles(formObj, btnFontFamily);3305 3306 const buttonHoverStyles = t_zeroForms__processButtonBG(formObj, true);3307 const baseSelector = t_zeroForms__createSelector(recid, formID, '');3308 3309 const selector = baseSelector + '.t-submit';3310 let styleValue = selector + '{' + buttonStyles + '}';3311
История файла и сравнение версий
const buttonGradientStyles = t_zeroForms__getGradientButtonBGStyles(formObj, selector + '.tn-form__btn-gradient');
3313 if (buttonGradientStyles) styleValue += buttonGradientStyles; 3314 btn.classList.toggle('tn-form__btn-gradient', Boolean(buttonGradientStyles)); 3316 const submitTextColorStyles = t_zeroForms__getButtonColorStyles(formObj, baseSelector + '.t-submit'); 3317 if (submitTextColorStyles) styleValue += submitTextColorStyles; 3319 const btnStylesID = 't-zero-form-btn-styles-' + formID + '-' + recid; 3320 const btnStyles = document.getElementById(btnStylesID); 3321 if (btnStyles && btnStyles.parentElement) btnStyles.parentElement.removeChild(btnStyles); 3322 t_zeroForms__addInlineTag({ tag: 'style', id: btnStylesID, content: styleValue, zeroForm }); 3324 // удаляем hover-стили до проверки, чтобы при ресайзе не остались стили от другого разрешения 3325 const btnHoverStylesID = 't-zero-form-btn-hover-styles-' + formID + '-' + recid; 3326 const btnHoverStyles = document.getElementById(btnHoverStylesID); 3327 if (btnHoverStyles && btnHoverStyles.parentElement) btnHoverStyles.parentElement.removeChild(btnHoverStyles); 3329 if (buttonHoverStyles) { 3330 let hoverSelector = selector.split(', ').map(function (selectorPart) { 3331 return selectorPart + ':hover'; 3333 hoverSelector = hoverSelector.join(', '); 3334 const styleHoverValue = hoverSelector + '{' + buttonHoverStyles + '}'; 3335 t_zeroForms__addInlineTag({ tag: 'style', id: btnHoverStylesID, content: styleHoverValue, zeroForm }); 3340 * create styles in string for submit and upload buttons 3341 * in t_zeroForms__createFormButton() 3343 * @param {formObj} formObj 3344 * @param {string} btnFontFamily 3347function t_zeroForms__generateButtonStyles(formObj, btnFontFamily) { 3348 var buttonStyles = { 3350 'border-radius': formObj.buttonradius || '0', 3351 'font-size': formObj.buttonfontsize || '', 3352 'font-family': formObj.buttonfontfamily || btnFontFamily, 3355 var stylesString = ''; 3356 var pxValues = ['height']; 3357 if (!t396__isGlobalStyleCSSVar(buttonStyles['border-radius'])) pxValues.push('border-radius'); 3358 if (!t396__isGlobalStyleCSSVar(buttonStyles['font-size'])) pxValues.push('font-size'); 3360 for (var k in buttonStyles) { 3361 if (buttonStyles[k]) { 3362 var isPxContains = pxValues.some(function (key) { 3363 return key === k.toString(); 3365 if (isPxContains) buttonStyles[k] += 'px'; 3366 stylesString += k + ':' + buttonStyles[k] + ';'; 3369 stylesString += t_zeroForms__processButtonBG(formObj, false); 3370 return stylesString; 3373function t_zeroForms__processButtonBG(formObj, isHover) { 3374 var buttonBGObj = t_zeroForms__getButtonBGObj(formObj); 3375 var currentBG = isHover ? buttonBGObj.buttonHoverBG : buttonBGObj.buttonBG; 3376 if (buttonBGObj.buttonBGHasGradient || buttonBGObj.buttonHoverBGHasGradient) return ''; 3377 if (!currentBG) return isHover ? '' : 'background-color: transparent;'; 3378 return 'background-color: ' + currentBG + ';'; 3381function t_zeroForms__getButtonBGObj(formObj) { 3382 var buttonBG = formObj.buttonbgcolor; 3383 var buttonHoverBG = formObj.buttonhoverbgcolor; 3384 var buttonBGHasGradient = t_zeroForms__isColorContainsGradient(buttonBG); 3385 var buttonHoverBGHasGradient = t_zeroForms__isColorContainsGradient(buttonHoverBG); 3388 buttonHoverBG: buttonHoverBG, 3389 buttonBGHasGradient: buttonBGHasGradient, 3390 buttonHoverBGHasGradient: buttonHoverBGHasGradient, 3394function t_zeroForms__isColorContainsGradient(string) { 3395 return string && string.indexOf('-gradient(') !== -1; 3398function t_zeroForms__getGradientButtonBGStyles(formObj, selector) { 3399 var buttonBGObj = t_zeroForms__getButtonBGObj(formObj); 3400 var buttonBGHasGradient = buttonBGObj.buttonBGHasGradient;