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

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + import {
2 + setRatioFor,
3 + watchOptionsWithPrefix,
4 + responsiveClassesFor,
5 + getOptionFor,
6 + getPrefixFor,
7 + } from './helpers'
8 +
9 + import { renderSingleEntryMeta } from './helpers/entry-meta'
10 +
11 + watchOptionsWithPrefix({
12 + getOptionsForPrefix: ({ prefix }) => [
13 + `${prefix}_share_box_title`,
14 + `${prefix}_share_box_visibility`,
15 +
16 + `${prefix}_author_box_visibility`,
17 + `${prefix}_post_tags_title`,
18 + `${prefix}_post_tags_visibility`,
19 + `${prefix}_post_nav_title_visibility`,
20 + `${prefix}_post_nav_thumb_visibility`,
21 + `${prefix}_post_nav_visibility`,
22 + `${prefix}_comments_structure`,
23 +
24 + // `${prefix}_related_posts_columns`,
25 + `${prefix}_related_featured_image_ratio`,
26 + `${prefix}_related_label`,
27 + `${prefix}_related_visibility`,
28 + `${prefix}_related_structure`,
29 + `${prefix}_related_posts_containment`,
30 + `${prefix}_related_single_meta_elements`,
31 + ],
32 + render: ({ prefix, id }) => {
33 + const visibilities = [
34 + { selector: '.ct-share-box', id: 'share_box_visibility' },
35 + { selector: '.author-box', id: 'author_box_visibility' },
36 + { selector: '.entry-tags', id: 'post_tags_visibility' },
37 + {
38 + selector: '.post-navigation .item-title',
39 + id: 'post_nav_title_visibility',
40 + },
41 + {
42 + selector: '.post-navigation .ct-media-container',
43 + id: 'post_nav_thumb_visibility',
44 + },
45 + { selector: '.post-navigation', id: 'post_nav_visibility' },
46 + ]
47 +
48 + if (id === `${prefix}_share_box_title`) {
49 + Array.from(
50 + document.querySelectorAll('.ct-share-box .ct-module-title')
51 + ).map((el) => {
52 + el.innerHTML = getOptionFor('share_box_title', prefix)
53 + })
54 + }
55 +
56 + if (id === `${prefix}_post_tags_title`) {
57 + Array.from(
58 + document.querySelectorAll('.entry-tags .ct-module-title')
59 + ).map((el) => {
60 + el.innerHTML = getOptionFor('post_tags_title', prefix)
61 + })
62 + }
63 +
64 + visibilities.map((visibilityDescriptor) => {
65 + if (id !== `${prefix}_${visibilityDescriptor.id}`) {
66 + return
67 + }
68 +
69 + Array.from(
70 + document.querySelectorAll(visibilityDescriptor.selector)
71 + ).map((el) => {
72 + responsiveClassesFor(
73 + getOptionFor(visibilityDescriptor.id, prefix),
74 + el
75 + )
76 + })
77 + })
78 +
79 + if (id === `${prefix}_comments_structure`) {
80 + Array.from(document.querySelectorAll('.ct-comments-container')).map(
81 + (el) => {
82 + let container = getOptionFor('comments_structure', prefix)
83 +
84 + el.firstElementChild.classList.remove(
85 + 'ct-container',
86 + 'ct-container-narrow'
87 + )
88 +
89 + el.firstElementChild.classList.add(
90 + container === 'narrow'
91 + ? 'ct-container-narrow'
92 + : 'ct-container'
93 + )
94 + }
95 + )
96 + }
97 +
98 + /*
99 + if (id === `${prefix}_related_posts_columns`) {
100 + Array.from(document.querySelectorAll('.ct-related-posts')).map(
101 + (el) => {
102 + el.dataset.layout = `grid:columns-${getOptionFor(
103 + 'related_posts_columns',
104 + prefix
105 + )}`
106 + }
107 + )
108 + }
109 + */
110 +
111 + if (id === `${prefix}_related_featured_image_ratio`) {
112 + Array.from(
113 + document.querySelectorAll(
114 + '.ct-related-posts .ct-media-container'
115 + )
116 + ).map((el) => {
117 + setRatioFor({
118 + ratio: getOptionFor(
119 + 'related_featured_image_ratio',
120 + prefix
121 + ),
122 + el,
123 + })
124 + })
125 + }
126 +
127 + if (id === `${prefix}_related_label`) {
128 + Array.from(
129 + document.querySelectorAll('.ct-related-posts .ct-module-title')
130 + ).map((el) => {
131 + el.innerHTML = getOptionFor('related_label', prefix)
132 + })
133 + }
134 +
135 + if (
136 + id === `${prefix}_related_posts_containment` ||
137 + id === `${prefix}_related_visibility`
138 + ) {
139 + Array.from(
140 + document.querySelectorAll('.ct-related-posts-container')
141 + ).map((el) => {
142 + responsiveClassesFor(
143 + getOptionFor('related_visibility', prefix),
144 + el
145 + )
146 + })
147 +
148 + if (
149 + getOptionFor('related_posts_containment', prefix) !==
150 + 'separated'
151 + ) {
152 + Array.from(document.querySelectorAll('.ct-related-posts')).map(
153 + (el) => {
154 + responsiveClassesFor(
155 + getOptionFor('related_visibility', prefix),
156 + el
157 + )
158 + }
159 + )
160 + }
161 + }
162 +
163 + if (id === `${prefix}_related_structure`) {
164 + Array.from(
165 + document.querySelectorAll('.ct-related-posts-container')
166 + ).map((el) => {
167 + let container = getOptionFor('related_structure', prefix)
168 +
169 + el.firstElementChild.classList.remove(
170 + 'ct-container',
171 + 'ct-container-narrow'
172 + )
173 +
174 + el.firstElementChild.classList.add(
175 + container === 'narrow'
176 + ? 'ct-container-narrow'
177 + : 'ct-container'
178 + )
179 + })
180 + }
181 +
182 + if (id === `${prefix}_related_single_meta_elements`) {
183 + Array.from(
184 + document.querySelectorAll('.ct-related-posts .entry-meta')
185 + ).map((el) => {
186 + renderSingleEntryMeta({
187 + el,
188 + meta_divider: 'slash',
189 + meta_type: 'simple',
190 + meta_elements: getOptionFor(
191 + 'related_single_meta_elements',
192 + prefix
193 + ),
194 + })
195 + })
196 + }
197 + },
198 + })
199 +