Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/blocksy-companion-pro/static/js/sync/header.js

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + import ctEvents from 'ct-events'
2 + import {
3 + withKeys,
4 + handleBackgroundOptionFor,
5 + assembleSelector,
6 + mutateSelector,
7 + getRootSelectorFor,
8 + } from 'blocksy-customizer-sync'
9 +
10 + ctEvents.on(
11 + 'ct:header:sync:collect-variable-descriptors',
12 + (variableDescriptors) => {
13 + variableDescriptors['global'] = () => ({
14 + transparent_behaviour: {
15 + selector: assembleSelector(getRootSelectorFor()),
16 + variable: 'has-transparent-header',
17 + responsive: true,
18 + extractValue: (value) => ({
19 + desktop: value.desktop ? 'var(--true)' : 'var(--false)',
20 + tablet: value.mobile ? 'var(--true)' : 'var(--false)',
21 + mobile: value.mobile ? 'var(--true)' : 'var(--false)',
22 + }),
23 + unit: '',
24 + },
25 +
26 + ...handleBackgroundOptionFor({
27 + id: 'headerBackground',
28 + selector: assembleSelector(
29 + mutateSelector({
30 + selector: getRootSelectorFor(),
31 + operation: 'suffix',
32 + to_add: '.ct-header',
33 + })
34 + ),
35 + responsive: true,
36 + forced_background_image: true,
37 + }),
38 +
39 + ...handleBackgroundOptionFor({
40 + id: 'transparentHeaderBackground',
41 + selector: assembleSelector(
42 + mutateSelector({
43 + selector: getRootSelectorFor(),
44 + operation: 'suffix',
45 + to_add: '[data-transparent]',
46 + })
47 + ),
48 + responsive: true,
49 + forced_background_image: true,
50 + }),
51 +
52 + ...handleBackgroundOptionFor({
53 + id: 'stickyHeaderBackground',
54 + selector: assembleSelector(
55 + mutateSelector({
56 + selector: getRootSelectorFor(),
57 + operation: 'suffix',
58 + to_add: '[data-sticky*="yes"]',
59 + })
60 + ),
61 + responsive: true,
62 + forced_background_image: true,
63 + }),
64 + })
65 + }
66 + )
67 +
68 + ctEvents.on(
69 + 'ct:header:sync:item:global',
70 + ({ optionId, optionValue, values }) => {
71 + if (
72 + optionId === 'has_sticky_header' ||
73 + optionId === 'sticky_rows' ||
74 + optionId === 'sticky_behaviour'
75 + ) {
76 + const { has_sticky_header, sticky_rows, sticky_behaviour } = values
77 +
78 + Array.from(document.querySelectorAll('[data-sticky]')).map(
79 + (row) => {
80 + row.removeAttribute('data-sticky')
81 + }
82 + )
83 +
84 + if (has_sticky_header === 'yes') {
85 + Array.from(document.querySelectorAll('[data-row]')).map(
86 + (row) => {
87 + let rowType = row.dataset.row
88 +
89 + if (!sticky_rows[rowType]) {
90 + return
91 + }
92 +
93 + let stickyResult = []
94 +
95 + if (sticky_behaviour.desktop) {
96 + stickyResult.push('desktop')
97 + }
98 +
99 + if (sticky_behaviour.mobile) {
100 + stickyResult.push('mobile')
101 + }
102 +
103 + row.dataset.sticky = stickyResult.join(':')
104 + }
105 + )
106 + }
107 +
108 + ctEvents.trigger('blocksy:frontend:init')
109 + }
110 +
111 + if (optionId === 'transparent_behaviour') {
112 + if (!document.querySelector('[data-transparent]')) {
113 + return
114 + }
115 +
116 + Array.from(document.querySelectorAll('[data-device]')).map(
117 + (device) => {
118 + device.removeAttribute('data-transparent')
119 + Array.from(device.querySelectorAll('[data-row]')).map(
120 + (el) => el.removeAttribute('data-transparent-row')
121 + )
122 +
123 + if (optionValue[device.dataset.device]) {
124 + device.dataset.transparent = ''
125 +
126 + Array.from(device.querySelectorAll('[data-row]')).map(
127 + (el) => (el.dataset.transparentRow = 'yes')
128 + )
129 + }
130 +
131 + ctEvents.trigger('blocksy:frontend:init')
132 + }
133 + )
134 + }
135 + }
136 + )
137 +