PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.4
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.4
3.4.4 3.4.3 3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 All 197 releases
convertkit / includes / integrations / divi / scripts / builder-bundle.min.js

builder-bundle.min.js in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages 3.4.4, at includes/integrations/divi/scripts/builder-bundle.min.js

298 lines 6.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * ConvertKit Broadcasts Divi Module.
3 */
4 class ConvertKitDiviBroadcasts extends React.Component {
5 /**
6 * The Divi module name. Must match the slug defined in
7 * the PHP class ConvertKit_Divi_Module_Broadcasts.
8 *
9 * @since 2.5.7
10 */
11 static slug = 'convertkit_broadcasts';
12
13 /**
14 * Renders the frontend output for this module.
15 *
16 * @since 2.5.7
17 */
18 render() {
19 const block = window.ConvertkitDiviBuilderData.broadcasts;
20
21 // If no Access Token has been defined in the Plugin, show a message in the module to tell the user what to do.
22 if (!block.has_access_token) {
23 return ConvertKitDiviNoAccessMessage(block);
24 }
25
26 // If no resources exist in ConvertKit, show a message in the module to tell the user what to do.
27 if (!block.has_resources) {
28 return ConvertKitDiviNoResourcesMessage(block);
29 }
30
31 // Return module with text.
32 return ConvertKitDiviMessage(
33 'Configure this broadcasts module by clicking the settings cog.'
34 );
35 }
36 }
37
38 /**
39 * ConvertKit Form Divi Module.
40 */
41 class ConvertKitDiviForm extends React.Component {
42 /**
43 * The Divi module name. Must match the slug defined in
44 * the PHP class ConvertKit_Divi_Module_Form.
45 *
46 * @since 2.5.6
47 */
48 static slug = 'convertkit_form';
49
50 /**
51 * Renders the frontend output for this module.
52 *
53 * @since 2.5.6
54 */
55 render() {
56 const form =
57 typeof this.props.form !== 'undefined' ? this.props.form : '';
58
59 return ConvertKitDiviRenderResourceModule(
60 window.ConvertkitDiviBuilderData.form,
61 form,
62 form
63 ? window.ConvertkitDiviBuilderData.form.fields.form.data.forms[
64 form
65 ].name
66 : '',
67 window.ConvertkitDiviBuilderData.form.fields.form.label
68 );
69 }
70 }
71
72 /**
73 * ConvertKit Form Trigger Divi Module.
74 */
75 class ConvertKitDiviFormTrigger extends React.Component {
76 /**
77 * The Divi module name. Must match the slug defined in
78 * the PHP class ConvertKit_Divi_Module_Form.
79 *
80 * @since 2.5.7
81 */
82 static slug = 'convertkit_formtrigger';
83
84 /**
85 * Renders the frontend output for this module.
86 *
87 * @since 2.5.7
88 */
89 render() {
90 const form = Number(
91 typeof this.props.form !== 'undefined' ? this.props.form : 0
92 );
93
94 return ConvertKitDiviRenderResourceModule(
95 window.ConvertkitDiviBuilderData.formtrigger,
96 form,
97 form > 0
98 ? window.ConvertkitDiviBuilderData.formtrigger.fields.form
99 .values[form]
100 : '',
101 window.ConvertkitDiviBuilderData.formtrigger.fields.form.label
102 );
103 }
104 }
105
106 /**
107 * ConvertKit Product Divi Module.
108 */
109 class ConvertKitDiviProduct extends React.Component {
110 /**
111 * The Divi module name. Must match the slug defined in
112 * the PHP class ConvertKit_Divi_Module_Product.
113 *
114 * @since 2.5.7
115 */
116 static slug = 'convertkit_product';
117
118 /**
119 * Renders the frontend output for this module.
120 *
121 * @since 2.5.7
122 */
123 render() {
124 const product =
125 typeof this.props.product !== 'undefined' ? this.props.product : '';
126
127 return ConvertKitDiviRenderResourceModule(
128 window.ConvertkitDiviBuilderData.product,
129 product,
130 product
131 ? window.ConvertkitDiviBuilderData.product.fields.product
132 .values[product]
133 : '',
134 window.ConvertkitDiviBuilderData.product.fields.product.label
135 );
136 }
137 }
138
139 /**
140 * ConvertKit Member Content Login Divi Module.
141 */
142 class ConvertKitDiviLogin extends React.Component {
143 /**
144 * The Divi module name. Must match the slug defined in
145 * the PHP class ConvertKit_Divi_Module_Login.
146 *
147 * @since 3.4.4
148 */
149 static slug = 'convertkit_login';
150
151 /**
152 * Renders the frontend output for this module.
153 *
154 * @since 3.4.4
155 */
156 render() {
157 const block = window.ConvertkitDiviBuilderData.login;
158
159 // If no Access Token has been defined in the Plugin, show a message in the module to tell the user what to do.
160 if (!block.has_access_token) {
161 return ConvertKitDiviNoAccessMessage(block);
162 }
163
164 // Return module with text.
165 return ConvertKitDiviMessage(
166 'Configure this member content login module by clicking the settings cog.'
167 );
168 }
169 }
170
171 /**
172 * Returns the block's notice and instruction text when no access token exists.
173 *
174 * @since 2.5.7
175 *
176 * @param {Object} block Block.
177 */
178 function ConvertKitDiviNoAccessMessage(block) {
179 return React.createElement(
180 'div',
181 {
182 className: 'convertkit-divi-module convertkit-no-content',
183 },
184 [
185 React.createElement('p', {}, block.no_access_token.notice),
186 React.createElement(
187 'p',
188 {},
189 block.no_access_token.instruction_text
190 ),
191 ]
192 );
193 }
194
195 /**
196 * Returns the block's notice and instruction text when no resources
197 * (forms, products etc) exist.
198 *
199 * @since 2.5.7
200 *
201 * @param {Object} block Block.
202 */
203 function ConvertKitDiviNoResourcesMessage(block) {
204 return React.createElement(
205 'div',
206 {
207 className: 'convertkit-divi-module convertkit-no-content',
208 },
209 [
210 React.createElement('p', {}, block.no_resources.notice),
211 React.createElement('p', {}, block.no_resources.instruction_text),
212 ]
213 );
214 }
215
216 /**
217 * Returns the given text.
218 *
219 * @since 2.5.7
220 *
221 * @param {string} message Message to display.
222 */
223 function ConvertKitDiviMessage(message) {
224 return React.createElement(
225 'div',
226 {
227 className: 'convertkit-divi-module',
228 },
229 message
230 );
231 }
232
233 /**
234 * Renders the Divi module for the given ConvertKit block (form, product, broadcast etc).
235 * and message, based on the Plugin and Divi module's configuration.
236 *
237 * @since 2.5.7
238 *
239 * @param {Object} block Block.
240 * @param {string} value Selected value.
241 * @param {string} valueLabel Selected value's label.
242 * @param {string} resourceName Resource name (form,product).
243 */
244 function ConvertKitDiviRenderResourceModule(
245 block,
246 value,
247 valueLabel,
248 resourceName
249 ) {
250 // If no Access Token has been defined in the Plugin, show a message in the module to tell the user what to do.
251 if (!block.has_access_token) {
252 return ConvertKitDiviNoAccessMessage(block);
253 }
254
255 // If no resources exist in ConvertKit, show a message in the module to tell the user what to do.
256 if (!block.has_resources) {
257 return ConvertKitDiviNoResourcesMessage(block);
258 }
259
260 // Show instructions if no resource selected.
261 if (value.length === 0) {
262 return ConvertKitDiviMessage(
263 'Configure this module by clicking the settings cog.'
264 );
265 }
266
267 // Return module with text.
268 return ConvertKitDiviMessage(
269 'Kit ' +
270 resourceName +
271 ' "' +
272 valueLabel +
273 '" selected. View on the frontend site to see the ' +
274 resourceName +
275 '.'
276 );
277 }
278
279 /**
280 * Register Divi modules when the Divi Builder API is ready.
281 *
282 * @since 2.5.6
283 *
284 * @param {Object} event Event.
285 * @param {Object} API Divi Buidler API.
286 */
287 jQuery(window).on('et_builder_api_ready', function (event, API) {
288 // eslint-disable-line no-unused-vars
289 // Register Divi modules.
290 API.registerModules([
291 ConvertKitDiviBroadcasts,
292 ConvertKitDiviForm,
293 ConvertKitDiviFormTrigger,
294 ConvertKitDiviLogin,
295 ConvertKitDiviProduct,
296 ]);
297 });
298