← Back
Editing: preview.min.js
let themesCommon=window.WPFormsThemesCommon;export default function(n){let t=jQuery,{BG_STYLE_NONE:a,EMPTY_URL:s}=themesCommon,l="none";return{resolveBackgroundStyle(e){var t,r=e.backgroundImage??a;return r!==a&&""!==r||!n.noneKeepsColor()?(t=n.hasBackgroundUrl(e),(r===a||""===r||!t&&["library","stock"].includes(r))&&(e.backgroundImage=n.hasTransparentBackgroundColor(e)?a:"solid")):e.backgroundImage=a,e},noneKeepsColor(){return!!n.getSchema().backgroundColor?.noneKeepsColor},hasBackgroundUrl(e){e=String(e.backgroundUrl??s).trim();return""!==e&&e!==l&&e!==s},hasTransparentBackgroundColor(e){e=String(e.backgroundColor??"").replace(/\s+/g,"");return""===e||"transparent"===e||n.isTransparentColor(e)},buildGradient(){var e=n.getSettings(),t=n.getColorSetting("backgroundGradientStart","#ffffff"),r=n.getColorSetting("backgroundGradientEnd",n.getButtonAccentColor(n.getColorSetting("buttonBackgroundColor"),n.getColorSetting("buttonBorderColor"))),o={vertical:"180deg",horizontal:"90deg",diagonal:"135deg"},e=e.backgroundGradientDirection||"radial";return e in o?`linear-gradient( ${o[e]}, ${t} 0%, ${r} 100% )`:`radial-gradient( ellipse at center, ${t} 0%, ${r} 100% )`},updateBackgroundLayer(){var e,t=n.getSettings(),r=t.backgroundImage??a;let o=l;"gradient"===r?o=n.buildGradient():r!==a&&"solid"!==r&&(e=n.prepareValue(t.backgroundUrl??s,"backgroundUrl"),o=e===s?l:e),n.setVar("--wpforms-background-url",o),n.setVar("--wpforms-background-color",r!==a&&t.backgroundColor||"rgba( 0, 0, 0, 0 )"),n.applyBackgroundPlacement(t,"gradient"===r)},applyBackgroundPlacement(e,o){e={"background-position":[e.backgroundPosition,"center center"],"background-repeat":[e.backgroundRepeat,"no-repeat"],"background-size":[e.backgroundSize,"cover"]};t.each(e,(e,[t,r])=>{n.setVar("--wpforms-"+e,o?r:t??r)})},activateBridge(){document.body.classList.contains("wpforms-themes-bridge")||(document.body.classList.add("wpforms-themes-bridge"),document.querySelectorAll("[data-wpforms-themes-legacy]").forEach(e=>e.remove()),n.applyAllSettings(),n.getItem()?.isLegacy&&(n.getItem().isLegacy=!1,n.showSelectedTheme()))},applyAllSettings(){t.each(n.getSettings(),(e,t)=>{n.applySetting(e,t)}),n.updateBackgroundLayer()},sizeProperties:["field-size","label-size","button-size","container-shadow-size"],backgroundLayerProperties:["background-url","background-image","background-gradient-direction","background-gradient-start","background-gradient-end"],buttonColorProperties:["button-background-color","button-border-color","button-text-color"],applySetting(e,t){var r;n.getContainer()&&(n.getStyleKeys().includes(e)||n.getSurfaceKeys().includes(e))&&(n.activateBridge(),r=e.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()),""!==(t=n.prepareValue(n.getPinnedValue(e,t),e))||!/color/i.test(e)&&"number"!==n.getSchema()[e]?.type||(t=n.prepareValue(n.getSchema()[e]?.default??"transparent",e)),n.applySettingProperty(r,t))},getColorSetting(e,t=void 0){var r=n.getSettings()[e];return""===r?n.getSchema()[e]?.default:r??t},applySettingProperty(e,t){n.sizeProperties.includes(e)?n.applySizeSetting(e,t):n.backgroundLayerProperties.includes(e)?n.updateBackgroundLayer():n.buttonColorProperties.includes(e)?n.applyButtonColorSetting(e,t):n.applySettingVariables(e,t)},applySizeSetting(r,e){t.each(n.data.sizes[r][e]||{},(e,t)=>{n.setVar(`--wpforms-${r}-`+e,t)})},applyButtonColorSetting(e,t){var r;"button-text-color"===e?(r=n.getButtonAccentColor(n.getColorSetting("buttonBackgroundColor"),n.getColorSetting("buttonBorderColor")),n.setVar("--wpforms-button-text-color",n.maybeSetButtonAltTextColor(t,r))):("button-border-color"===e&&(n.applySettingVariables(e,t),t=n.getColorSetting("buttonBackgroundColor")),t=n.maybeSetButtonAltBackgroundColor(t),n.setVar("--wpforms-button-text-color",n.maybeSetButtonAltTextColor(n.getColorSetting("buttonTextColor"),t)),n.setVar("--wpforms-button-background-color",t))},applySettingVariables(e,t){switch(e){case"background-size-mode":n.recomputeBackgroundSize();break;case"background-width":case"background-height":n.setVar("--wpforms-"+e,t),n.recomputeBackgroundSize();break;default:n.setVar("--wpforms-"+e,t),n.setVar(`--wpforms-${e}-spare`,t)}},setVar(t,r){var e=n.getContainers();e.length&&(e.forEach(e=>e.style.setProperty(t,r)),n.triggerEditorEvent("wpformsThemesEditorSetVar",[t,r,e[0]]))},applyCustomCss(){var e=n.getItem(),t="wpforms-themes-editor-custom-css-"+(e.isEmbed?e.selector.slice(1):e.formId);let r=e.isEmbed?"#wpforms-"+e.formId+e.selector:e.selector;var o=[...document.querySelectorAll("style[data-wpforms-custom-css]")].filter(e=>e.dataset.wpformsCustomCss===r);let a=document.getElementById(t);a||((a=document.createElement("style")).id=t,o.length?o[0].before(a):document.body.appendChild(a)),o.forEach(e=>e.remove());t=(n.getSettings().customCss||"").trim();e.blockCss?a.textContent=t:a.textContent=t?r+` { ${t} }`:""},isRgbValue(e){return String(e??"").trim().toLowerCase().startsWith("rgb")}}}
Save File
Cancel