| Server IP : 38.190.208.107 / Your IP : 216.73.217.21 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.12/wp-content/themes/blocksy/static/js/options/options/background/ |
Upload File : |
import {
Fragment,
createElement,
Component,
useRef,
useEffect,
useMemo,
useCallback,
useState,
} from '@wordpress/element'
import classnames from 'classnames'
import { __ } from 'ct-i18n'
import GenericOptionType from '../../GenericOptionType'
const ImagePicker = ({ option, value, onChange, setOutsideClickFreezed }) => {
return (
<Fragment>
<GenericOptionType
value={value['background_image']}
values={value}
option={{
id: 'background_image',
label: false,
type: 'ct-image-uploader',
value: option.value['background_image'],
has_position_picker: true,
emptyLabel: __('Select Image', 'blocksy'),
filledLabel: __('Change Image', 'blocksy'),
onFrameOpen: () => {
setOutsideClickFreezed(true)
},
onFrameClose: () => {
setOutsideClickFreezed(false)
},
}}
hasRevertButton={false}
onChange={(newValue) =>
onChange({
...value,
background_image: newValue,
})
}
/>
<GenericOptionType
value={value['background_repeat']}
values={value}
option={{
id: 'background_repeat',
label: __('Background Repeat', 'blocksy'),
type: 'ct-radio',
view: 'text',
design: 'block',
attr: { 'data-type': 'repeat' },
choice_attr: {'data-tooltip-reveal': 'top'},
value: option.value['background_repeat'],
choices: {
repeat: `<svg viewBox="0 0 16 16"><path d="M0,0h4v4H0V0z M6,0h4v4H6V0z M12,0h4v4h-4V0z M0,6h4v4H0V6z M6,6h4v4H6V6z M12,6h4v4h-4V6z M0,12h4v4H0V12z M6,12h4v4H6V12zM12,12h4v4h-4V12z"/></svg>
<span class="ct-tooltip">${__('Repeat', 'blocksy')}</span>`,
'repeat-y': `<svg viewBox="0 0 16 16"><rect x="6" width="4" height="4"/><rect x="6" y="6" width="4" height="4"/><rect x="6" y="12" width="4" height="4"/></svg>
<span class="ct-tooltip">${__('Repeat Y', 'blocksy')}</span>`,
'repeat-x': `<svg viewBox="0 0 16 16"><rect y="6" width="4" height="4"/><rect x="6" y="6" width="4" height="4"/><rect x="12" y="6" width="4" height="4"/></svg>
<span class="ct-tooltip">${__('Repeat X', 'blocksy')}</span>`,
'no-repeat': `<svg viewBox="0 0 16 16"><rect x="6" y="6" width="4" height="4"/></svg>
<span class="ct-tooltip">${__('No Repeat', 'blocksy')}</span>`,
},
}}
hasRevertButton={false}
onChange={(newValue) =>
onChange({
...value,
background_repeat: newValue,
})
}
/>
<GenericOptionType
value={value['background_size']}
values={value}
option={{
id: 'background_size',
label: __('Background Size', 'blocksy'),
type: 'ct-radio',
view: 'text',
design: 'block',
value: option.value['background_size'],
choices: {
auto: __('Auto', 'blocksy'),
cover: __('Cover', 'blocksy'),
contain: __('Contain', 'blocksy'),
},
}}
hasRevertButton={false}
onChange={(newValue) =>
onChange({
...value,
background_size: newValue,
})
}
/>
<GenericOptionType
value={value['background_attachment']}
values={value}
option={{
id: 'background_size',
label: __('Background Attachment', 'blocksy'),
type: 'ct-radio',
view: 'text',
design: 'block',
value: option.value['background_attachment'],
choices: {
scroll: __('Scroll', 'blocksy'),
fixed: __('Fixed', 'blocksy'),
inherit: __('Inherit', 'blocksy'),
},
}}
hasRevertButton={false}
onChange={(newValue) =>
onChange({
...value,
background_attachment: newValue,
})
}
/>
{value.background_image.url && (
<Fragment>
<GenericOptionType
value={
value.overlayColor &&
value.overlayColor.default.color.indexOf(
'CT_CSS_SKIP_RULE'
) === -1
? 'yes'
: 'no'
}
values={{}}
option={{
id: 'has_overlay',
label: __('Image Overlay', 'blocksy'),
type: 'ct-radio',
view: 'text',
design: 'block',
value: 'no',
choices: {
no: __('Disabled', 'blocksy'),
yes: __('Enabled', 'blocksy'),
},
}}
hasRevertButton={false}
onChange={(newValue) => {
let hasOverlay =
value.overlayColor.default.color.indexOf(
'CT_CSS_SKIP_RULE'
) === -1
onChange({
...value,
overlayColor: {
default: {
color: hasOverlay
? 'CT_CSS_SKIP_RULE'
: 'rgba(0, 0, 0, 0.2)',
},
},
})
}}
/>
{value.overlayColor &&
value.overlayColor.default.color.indexOf(
'CT_CSS_SKIP_RULE'
) === -1 && (
<GenericOptionType
value={value['overlayColor']}
values={value}
option={{
id: 'overlayColor',
label: __('Image Overlay Color', 'blocksy'),
type: 'ct-color-picker',
design: 'inline',
value: option.value['overlayColor'],
pickers: [
{
title: __('Initial', 'blocksy'),
id: 'default',
},
],
skipArrow: true,
appendToBody: false,
}}
hasRevertButton={false}
onChange={(newValue) =>
onChange({
...value,
overlayColor: newValue,
})
}
/>
)}
</Fragment>
)}
</Fragment>
)
}
export default ImagePicker