PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 2.6.8
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v2.6.8
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 2.3.1 2.3.2 All 195 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 2.6.8, at includes/integrations/divi/scripts/builder-bundle.min.js

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