GRAYBYTE WORDPRESS FILE MANAGER4350

Server IP : 198.54.121.189 / Your IP : 216.73.216.140
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /home/giriqfky/trustyourlawyer.com/wp-content/plugins/essential-blocks/src/helpers/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/giriqfky/trustyourlawyer.com/wp-content/plugins/essential-blocks/src/helpers//helpers.js
import {
    loadGoogleFontEditor,
    softMinifyCssStrings
} from "@essential-blocks/controls";

export const getGlobalSettings = (select) => {
    return {
        getGlobalColors: select('essential-blocks').getGlobalColors(),
        getCustomColors: select('essential-blocks').getCustomColors(),
        getGradientColors: select('essential-blocks').getGradientColors(),
        getCustomGradientColors: select('essential-blocks').getCustomGradientColors(),
        getGlobalTypography: select('essential-blocks').getGlobalTypography()
    }
}

export const generateTypographyCSS = (styles, deviceType) => {
    let cssString = '';
    let customCssString = '';

    // Iterate over each element and its styles
    for (const element in styles) {
        let selector = element
        if (element === 'body') {
            selector = 'p'
        }
        else if (element === 'link') {
            selector = 'a'
        }
        else if (element === 'allHeadings') {
            selector = ':is(h1, h2, h3, h4, h5, h6)'
        }

        //
        if (element === 'custom') {
            cssString += generateCustomTypographyCSS(styles[element], deviceType)
        }
        else {
            const selectorParam = `.editor-styles-wrapper .eb-parent-wrapper ${selector} { `;
            if (element === 'allHeadings') {
                customCssString += generateCSSStyles(selectorParam, styles[element], deviceType)
            }
            else {
                cssString += generateCSSStyles(selectorParam, styles[element], deviceType)
            }
        }
    }

    return customCssString + cssString;
}

const generateCustomTypographyCSS = (styles, deviceType) => {

    if (typeof styles === 'object' && Object.keys(styles).length === 0) {
        return ''
    }
    let css = ''
    const selector = 'body {'
    for (const element in styles) {
        css += generateCSSStyles(selector, styles[element], deviceType, element)
    }
    return css;
}

const generateCSSStyles = (selector, styles, deviceType = 'Desktop', varPrefix = '') => {
    if (typeof styles === 'object' && Object.keys(styles).length === 0) {
        return ''
    }
    if (varPrefix.length > 0) {
        varPrefix = `--${varPrefix}-`
    }
    let css = selector
    let tablet_css = selector
    let mobile_css = selector
    for (const style in styles) {
        const cssValue = styles[style];

        //Generate CSS for each Property
        if (style === 'fontFamily') {
            css += `${varPrefix}font-family: ${cssValue}; `;
        }
        else if (style === 'fontSize') {
            css += `${varPrefix}font-size: ${cssValue}${styles?.fontSizeUnit || 'px'}; `;
        }
        else if (style === 'TABfontSize') {
            tablet_css += `${varPrefix}font-size: ${cssValue}${styles?.TABfontSizeUnit || styles?.fontSizeUnit || 'px'}; `;
        }
        else if (style === 'MOBfontSize') {
            mobile_css += `${varPrefix}font-size: ${cssValue}${styles?.MOBfontSizeUnit || styles?.fontSizeUnit || 'px'}; `;
        }
        else if (style === 'fontWeight') {
            css += `${varPrefix}font-weight: ${cssValue}; `;
        }
        else if (style === 'letterSpacing') {
            css += `${varPrefix}letter-spacing: ${cssValue}${styles?.letterSpacingUnit || 'px'}; `;
        }
        else if (style === 'TABletterSpacing') {
            tablet_css += `${varPrefix}letter-spacing: ${cssValue}${styles?.TABletterSpacingUnit || styles?.letterSpacingUnit || 'px'}; `;
        }
        else if (style === 'MOBletterSpacing') {
            mobile_css += `${varPrefix}letter-spacing: ${cssValue}${styles?.MOBletterSpacingUnit || styles?.letterSpacingUnit || 'px'}; `;
        }
        else if (style === 'lineHeight') {
            css += `${varPrefix}line-height: ${cssValue}${styles?.lineHeightUnit || 'px'}; `;
        }
        else if (style === 'TABlineHeight') {
            tablet_css += `${varPrefix}line-height: ${cssValue}${styles?.TABlineHeightUnit || styles?.lineHeightUnit || 'px'}; `;
        }
        else if (style === 'MOBlineHeight') {
            mobile_css += `${varPrefix}line-height: ${cssValue}${styles?.MOBlineHeightUnit || styles?.lineHeightUnit || 'px'}; `;
        }
        else if (style === 'fontStyle') {
            css += `${varPrefix}font-style: ${cssValue}; `;
        }
        else if (style === 'textDecoration') {
            css += `${varPrefix}text-decoration: ${cssValue}; `;
        }
        else if (style === 'textTransform') {
            css += `${varPrefix}text-transform: ${cssValue}; `;
        }
    }
    css += `}\n`
    tablet_css += `}\n`
    mobile_css += `}\n`

    if (deviceType === 'Desktop') {
        return softMinifyCssStrings(css)
    }
    else if (deviceType === 'Tablet') {
        return softMinifyCssStrings(tablet_css)
    }
    else if (deviceType === 'Mobile') {
        return softMinifyCssStrings(mobile_css)
    }
}

export const applyTypographyCSS = (cssString) => {
    setTimeout(() => {
        let rootDocument = document
        const iframe = document.querySelector('[name="editor-canvas"]');
        if (iframe) {
            rootDocument = iframe.contentDocument || iframe.contentWindow.document;
        }

        const styleTag = rootDocument.createElement('style');
        styleTag.type = 'text/css';
        styleTag.innerHTML = cssString;
        rootDocument.head.appendChild(styleTag);
    }, 100)
}

export const loadGoogleFonts = (fontObj) => {
    const googleFontFamily = getGoogleFonts(fontObj);
    loadGoogleFontEditor(googleFontFamily)
}

export const getGoogleFonts = (fontObj) => {
    const fontFamilyList = [];

    function traverseStyles(styleObject) {
        for (const key in styleObject) {
            if (styleObject.hasOwnProperty(key)) {
                const value = styleObject[key];

                // Check if the current property is an object
                if (typeof value === 'object') {
                    // Recurse deeper
                    traverseStyles(value);
                }

                // Check for fontFamily and add to list
                if (key === 'fontFamily') {
                    fontFamilyList.push(`${value}:100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic`);
                }
            }
        }
    }

    traverseStyles(fontObj);
    return fontFamilyList;
}

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 10 2025 04:32:24
giriqfky / giriqfky
0755
.htaccess
0.41 KB
July 10 2025 04:32:25
giriqfky / giriqfky
0644
LoadAssets.js
2.848 KB
August 27 2024 16:37:06
giriqfky / giriqfky
0644
fetch.js
3.166 KB
February 26 2025 16:22:10
giriqfky / giriqfky
0644
helpers.js
6.286 KB
September 03 2024 16:13:22
giriqfky / giriqfky
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF