Diff: STRATO-apps/wordpress_03/app/wp-content/themes/blocksy/static/js/customizer/controls.js

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + import './public-path'
2 + import { createElement, createRoot } from '@wordpress/element'
3 + import { defineCustomizerControl } from './controls/utils.js'
4 + import { listenToChanges } from './customizer-color-scheme.js'
5 + import './preview-events'
6 + import { listenToVariables } from './customizer-variables'
7 + import './reset'
8 + import { initAllPanels } from '../options/initPanels'
9 +
10 + import { initBuilder } from './panels-builder'
11 +
12 + import Options from './controls/options'
13 + import { initWidget } from '../backend/widgets'
14 +
15 + import $ from 'jquery'
16 + import ctEvents from 'ct-events'
17 + import ProOverlay from './components/ProOverlay'
18 +
19 + import WidgetArea from './options/ct-widget-area'
20 + import { mountCoreBlocksFix } from '../editor/utils/fix-core-blocks-registration'
21 +
22 + mountCoreBlocksFix()
23 +
24 + ctEvents.on('blocksy:options:register', (opts) => {
25 + opts['ct-widget-area'] = WidgetArea
26 + })
27 +
28 + listenToChanges()
29 + listenToVariables()
30 +
31 + defineCustomizerControl('ct-options', Options)
32 +
33 + if ($ && $.fn) {
34 + $(document).on('widget-added', (event, widget) => {
35 + initWidget(widget[0])
36 + })
37 +
38 + if (wp && wp.customize && wp.customize.control) {
39 + wp.customize.control.bind('add', (control) => {
40 + setTimeout(() => {
41 + initWidget(control.container[0])
42 + }, 100)
43 + })
44 + }
45 + }
46 +
47 + document.addEventListener('DOMContentLoaded', () => {
48 + initAllPanels()
49 + initBuilder()
50 +
51 + setTimeout(() => {
52 + if (document.querySelector('.ct-onboarding-button')) {
53 + const root = createRoot(
54 + document.querySelector('.ct-onboarding-button')
55 + )
56 + root.render(
57 + <ProOverlay username={ct_customizer_localizations.username} />
58 + )
59 + }
60 + }, 50)
61 +
62 + setTimeout(() => {
63 + Object.values(wp.customize.control._value)
64 + .filter(({ params: { type } }) => type === 'ct-options')
65 + .map((control) => {
66 + if (wp.customize.section(control.section)) {
67 + wp.customize
68 + .section(control.section)
69 + .container.on('keydown', function (event) {
70 + return
71 +
72 + // Pressing the escape key fires a theme:collapse event
73 + if (27 === event.keyCode) {
74 + if (section.$body.hasClass('modal-open')) {
75 + // Escape from the details modal.
76 + section.closeDetails()
77 + } else {
78 + // Escape from the inifinite scroll list.
79 + section.headerContainer
80 + .find('.customize-themes-section-title')
81 + .focus()
82 + }
83 + event.stopPropagation() // Prevent section from being collapsed.
84 + }
85 + })
86 + }
87 +
88 + ;(wp.customize.panel(control.section())
89 + ? wp.customize.panel
90 + : wp.customize.section)(control.section(), (section) => {
91 + section.expanded.bind((value) => {
92 + let root = control.container[0].__reactRoot
93 +
94 + if (!root) {
95 + control.container[0].__reactRoot = createRoot(
96 + control.container[0]
97 + )
98 + root = control.container[0].__reactRoot
99 + }
100 +
101 + if (value) {
102 + const ChildComponent = Options
103 +
104 + let MyChildComponent = Options
105 +
106 + // block | inline
107 + let design = 'none'
108 +
109 + root.render(
110 + <MyChildComponent
111 + id={control.id}
112 + onChange={(v) => control.setting.set(v)}
113 + value={control.setting.get()}
114 + option={control.params.option}>
115 + {(props) => <ChildComponent {...props} />}
116 + </MyChildComponent>
117 + )
118 +
119 + return
120 + }
121 +
122 + setTimeout(() => {
123 + root.unmount()
124 +
125 + control.container[0].__reactRoot = null
126 + }, 500)
127 + })
128 + })
129 + })
130 + })
131 +
132 + if ($ && $.fn) {
133 + $(document).on('click', '[data-trigger-section]', (e) => {
134 + e.preventDefault()
135 +
136 + wp.customize.previewer.trigger(
137 + 'ct-initiate-deep-link',
138 + e.target.dataset.triggerSection
139 + )
140 + })
141 +
142 + var urlParams = new URLSearchParams(window.location.search)
143 +
144 + if (urlParams.get('ct_autofocus')) {
145 + setTimeout(() => {
146 + wp.customize.previewer.trigger(
147 + 'ct-initiate-deep-link',
148 + urlParams.get('ct_autofocus')
149 + )
150 + }, 800)
151 + }
152 + }
153 + })
154 +
155 + export { default as Overlay } from './components/Overlay'
156 + export {
157 + getValueFromInput,
158 + getFirstLevelOptions,
159 + } from '../options/helpers/get-value-from-input'
160 + export { default as OptionsPanel } from '../options/OptionsPanel'
161 + export { default as Panel, PanelMetaWrapper } from '../options/options/ct-panel'
162 + export { DeviceManagerProvider } from './components/useDeviceManager'
163 + export { default as PanelLevel } from '../options/components/PanelLevel'
164 + export { default as Switch } from '../options/options/ct-switch'
165 + export { default as ImageUploader } from '../options/options/ct-image-uploader'
166 + export { default as Select } from '../options/options/ct-select'
167 + export { default as DateTimePicker } from '../options/options/date-time-picker'
168 + export { default as EntityIdPicker } from '../options/options/ct-entity-picker'
169 +
170 + export { default as OutsideClickHandler } from '../options/options/react-outside-click-handler'
171 +
172 + export { Transition, animated } from 'react-spring'
173 + export { default as bezierEasing } from 'bezier-easing'
174 + export { default as usePopoverMaker } from '../options/helpers/usePopoverMaker'
175 +
176 + export {
177 + getAttributesFromOptions,
178 + getDefaultsFromOptions,
179 + getOptionsForBlock,
180 + } from '../editor/utils'
181 +
182 + export { getColorsDefaults } from '../editor/utils/colors'
183 +
184 + export * as syncHelpers from 'customizer-sync-helpers'
185 +
186 + /**
187 + * Expose builder values
188 + */
189 + export { DragDropContext as PlacementsDragDropContext } from './panels-builder/placements/BuilderRoot'
190 + export { DragDropContext as ColumnsDragDropContext } from '../options/options/ct-footer-builder'
191 + export const onDocumentLoaded = (cb) => {
192 + if (/comp|inter|loaded/.test(document.readyState)) {
193 + cb()
194 + } else {
195 + document.addEventListener('DOMContentLoaded', cb, false)
196 + }
197 + }
198 +