PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 1.3.0
JetFormBuilder — Dynamic Blocks Form Builder v1.3.0
3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / blocks / modules / general-style.php
jetformbuilder / includes / blocks / modules Last commit date
fields-errors 4 years ago base-module.php 4 years ago general-style-functions.php 4 years ago general-style.php 4 years ago
general-style.php
563 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Blocks\Modules;
5
6 use JET_SM\Gutenberg\Controls_Manager;
7
8 /**
9 * @property Controls_Manager controls_manager
10 *
11 * Trait General_Style
12 * @package Jet_Form_Builder\Blocks\Modules
13 */
14 trait General_Style {
15
16 use General_Style_Functions;
17
18 public function general_style_manager_options() {
19 $this->maybe_add_controls_type( 'wrap' );
20 $this->maybe_add_controls_type( 'input' );
21 $this->maybe_add_controls_type( 'label' );
22 $this->maybe_add_controls_type( 'required' );
23 $this->maybe_add_controls_type( 'description' );
24 }
25
26 public function general_css_scheme() {
27 return array(
28 'wrap' => $this->get_field_wrap(),
29 'label' => $this->get_label_selector(),
30 'input' => $this->get_field_input(),
31 'required' => $this->get_required_selector(),
32 'description' => $this->get_description_selector()
33 );
34 }
35
36 public function general_controls_callbacks() {
37 return array(
38 'wrap' => array( $this, 'add_content_controls' ),
39 'label' => array( $this, 'add_label_controls' ),
40 'input' => array( $this, 'add_input_controls' ),
41 'required' => array( $this, 'add_required_mark_controls' ),
42 'description' => array( $this, 'add_description_controls' ),
43 );
44 }
45
46 public function general_style_unregister() {
47 return array( 'input' );
48 }
49
50 public function get_label_selector() {
51 return '__label.%1$s__label.%1$s__label';
52 }
53
54 public function get_required_selector() {
55 return '__label span.%1$s__required.%1$s__required.%1$s__required';
56 }
57
58 public function get_description_selector() {
59 return '__desc.%1$s__desc.%1$s__desc';
60 }
61
62 public function get_field_wrap() {
63 return '-row.%1$s-row.%1$s-row.%1$s-row';
64 }
65
66 public function get_field_input() {
67 return '-row.%1$s-row.%1$s-row input';
68 }
69
70
71 public function general_style_attributes() {
72 return array(
73 'label_margin' => array(
74 'type' => 'object'
75 ),
76 'label_padding' => array(
77 'type' => 'object'
78 ),
79 'label_typography' => array(
80 'type' => 'object'
81 ),
82 'label_color' => array(
83 'type' => 'object'
84 ),
85 'label_border' => array(
86 'type' => 'object'
87 ),
88 'label_alignment' => array(
89 'type' => 'object'
90 ),
91 'label_background_color' => array(
92 'type' => 'object'
93 ),
94 'description_margin' => array(
95 'type' => 'object'
96 ),
97 'description_padding' => array(
98 'type' => 'object'
99 ),
100 'description_typography' => array(
101 'type' => 'object'
102 ),
103 'description_color' => array(
104 'type' => 'object'
105 ),
106 'description_background_color' => array(
107 'type' => 'object'
108 ),
109 'description_border' => array(
110 'type' => 'object'
111 ),
112 'description_alignment' => array(
113 'type' => 'object'
114 ),
115 'required_color' => array(
116 'type' => 'object'
117 ),
118 'required_background_color' => array(
119 'type' => 'object'
120 ),
121 'required_typography' => array(
122 'type' => 'object'
123 ),
124 );
125 }
126
127 public function _get_default_control( $selector ) {
128 return array(
129 'padding' => array(
130 'type' => 'dimensions',
131 'label' => __( 'Padding', 'jet-form-builder' ),
132 'units' => array( 'px', '%' ),
133 'css_selector' => array(
134 $selector => 'padding: {{TOP}} {{RIGHT}} {{BOTTOM}} {{LEFT}};',
135 ),
136 ),
137 'margin' => array(
138 'type' => 'dimensions',
139 'label' => __( 'Margin', 'jet-form-builder' ),
140 'units' => array( 'px', '%' ),
141 'css_selector' => array(
142 $selector => 'margin: {{TOP}} {{RIGHT}} {{BOTTOM}} {{LEFT}};',
143 ),
144 )
145 );
146 }
147
148 public function add_margin_padding( $selector, $control_options, $responsive = array() ) {
149 foreach ( $control_options as $type => $options ) {
150 $options = $this->merge_controls_or_add_id( $this->_get_default_control( $selector )[ $type ], $options );
151
152 if ( in_array( $type, $responsive ) ) {
153 $this->controls_manager->add_responsive_control( $options );
154 } else {
155 $this->controls_manager->add_control( $options );
156 }
157 }
158 }
159
160 public function merge_controls_or_add_id( $control, $options ) {
161 if ( is_array( $options ) ) {
162 return array_merge( $control, $options );
163
164 } elseif ( is_string( $options ) ) {
165
166 $control['id'] = $options;
167
168 return $control;
169 }
170 }
171
172
173 private function add_content_controls() {
174 $this->controls_manager->start_section(
175 'style_controls',
176 [
177 'id' => 'content_style',
178 'title' => __( 'Content', 'jet-form-builder' )
179 ]
180 );
181
182 $this->add_margin_padding(
183 $this->selector( 'wrap' ),
184 array(
185 'margin' => array(
186 'id' => 'field_margin',
187 'separator' => 'after',
188 ),
189 'padding' => array(
190 'id' => 'field_padding',
191 'separator' => 'after',
192 )
193 ),
194 array( 'padding', 'margin' )
195 );
196
197 $this->controls_manager->add_control( [
198 'id' => 'field_alignment',
199 'type' => 'choose',
200 'label' => __( 'Alignment', 'jet-form-builder' ),
201 'separator' => 'after',
202 'options' => [
203 'left' => [
204 'shortcut' => __( 'Left', 'jet-form-builder' ),
205 'icon' => 'dashicons-editor-alignleft',
206 ],
207 'center' => [
208 'shortcut' => __( 'Center', 'jet-form-builder' ),
209 'icon' => 'dashicons-editor-aligncenter',
210 ],
211 'right' => [
212 'shortcut' => __( 'Right', 'jet-form-builder' ),
213 'icon' => 'dashicons-editor-alignright',
214 ],
215 ],
216 'css_selector' => [
217 $this->selector( 'wrap' ) => 'text-align: {{VALUE}};',
218 ],
219 ] );
220
221
222 $this->controls_manager->add_control( [
223 'id' => 'field_border',
224 'type' => 'border',
225 'label' => __( 'Border', 'jet-form-builder' ),
226 'separator' => 'after',
227 'css_selector' => array(
228 $this->selector( 'wrap' ) => 'border-style:{{STYLE}};border-width:{{WIDTH}};border-radius:{{RADIUS}};border-color:{{COLOR}};',
229 ),
230 ] );
231
232 $this->controls_manager->add_control( [
233 'id' => 'field_background_color',
234 'type' => 'color-picker',
235 'label' => __( 'Background Color', 'jet-form-builder' ),
236 'css_selector' => array(
237 $this->selector( 'wrap' ) => 'background-color: {{VALUE}}',
238 ),
239 ] );
240
241 $this->controls_manager->end_section();
242 }
243
244 private function add_label_controls() {
245 $this->controls_manager->start_section(
246 'style_controls',
247 [
248 'id' => 'label_style',
249 'title' => __( 'Label', 'jet-form-builder' )
250 ]
251 );
252
253 $this->add_margin_padding(
254 $this->selector( 'label' ),
255 array(
256 'margin' => array(
257 'id' => 'label_margin',
258 'separator' => 'after',
259 ),
260 'padding' => array(
261 'id' => 'label_padding',
262 'separator' => 'after',
263 )
264 )
265 );
266
267 $this->controls_manager->add_control( [
268 'id' => 'label_alignment',
269 'type' => 'choose',
270 'label' => __( 'Alignment', 'jet-form-builder' ),
271 'separator' => 'after',
272 'options' => [
273 'left' => [
274 'shortcut' => __( 'Left', 'jet-form-builder' ),
275 'icon' => 'dashicons-editor-alignleft',
276 ],
277 'center' => [
278 'shortcut' => __( 'Center', 'jet-form-builder' ),
279 'icon' => 'dashicons-editor-aligncenter',
280 ],
281 'right' => [
282 'shortcut' => __( 'Right', 'jet-form-builder' ),
283 'icon' => 'dashicons-editor-alignright',
284 ],
285 ],
286 'css_selector' => [
287 $this->selector( 'label' ) => 'text-align: {{VALUE}};',
288 ],
289 ] );
290
291 $this->controls_manager->add_control( [
292 'id' => 'label_typography',
293 'type' => 'typography',
294 'separator' => 'after',
295 'css_selector' => [
296 $this->selector( 'label' ) => 'font-family: {{FAMILY}}; font-weight: {{WEIGHT}}; text-transform: {{TRANSFORM}}; font-style: {{STYLE}}; text-decoration: {{DECORATION}}; line-height: {{LINEHEIGHT}}{{LH_UNIT}}; letter-spacing: {{LETTERSPACING}}{{LS_UNIT}}; font-size: {{SIZE}}{{S_UNIT}};',
297 ],
298 ] );
299
300 $this->controls_manager->add_control( [
301 'id' => 'label_border',
302 'type' => 'border',
303 'label' => __( 'Border', 'jet-form-builder' ),
304 'separator' => 'after',
305 'css_selector' => array(
306 $this->selector( 'label' ) => 'border-style:{{STYLE}};border-width:{{WIDTH}};border-radius:{{RADIUS}};border-color:{{COLOR}};',
307 ),
308 ] );
309
310 $this->controls_manager->add_control( [
311 'id' => 'label_color',
312 'type' => 'color-picker',
313 'separator' => 'after',
314 'label' => __( 'Text Color', 'jet-form-builder' ),
315 'css_selector' => array(
316 $this->selector( 'label' ) => 'color: {{VALUE}}',
317 ),
318 ] );
319
320 $this->controls_manager->add_control( [
321 'id' => 'label_background_color',
322 'type' => 'color-picker',
323 'label' => __( 'Background Color', 'jet-form-builder' ),
324 'css_selector' => array(
325 $this->selector( 'label' ) => 'background-color: {{VALUE}}',
326 ),
327 ] );
328
329 $this->controls_manager->end_section();
330 }
331
332 private function add_description_controls() {
333 $this->controls_manager->start_section(
334 'style_controls',
335 [
336 'id' => 'description_style',
337 'title' => __( 'Description', 'jet-form-builder' ),
338 /*'condition' => array(
339 'desc' => true
340 ),*/
341 ]
342 );
343
344 $this->add_margin_padding(
345 $this->selector( 'description' ),
346 array(
347 'margin' => array(
348 'id' => 'description_margin',
349 'separator' => 'after',
350 ),
351 'padding' => array(
352 'id' => 'description_padding',
353 'separator' => 'after',
354 )
355 )
356 );
357
358 $this->controls_manager->add_control( [
359 'id' => 'description_alignment',
360 'type' => 'choose',
361 'label' => __( 'Alignment', 'jet-form-builder' ),
362 'separator' => 'after',
363 'options' => [
364 'left' => [
365 'shortcut' => __( 'Left', 'jet-form-builder' ),
366 'icon' => 'dashicons-editor-alignleft',
367 ],
368 'center' => [
369 'shortcut' => __( 'Center', 'jet-form-builder' ),
370 'icon' => 'dashicons-editor-aligncenter',
371 ],
372 'right' => [
373 'shortcut' => __( 'Right', 'jet-form-builder' ),
374 'icon' => 'dashicons-editor-alignright',
375 ],
376 ],
377 'css_selector' => [
378 $this->selector( 'description' ) => 'text-align: {{VALUE}};',
379 ],
380 ] );
381
382 $this->controls_manager->add_control( [
383 'id' => 'description_border',
384 'type' => 'border',
385 'label' => __( 'Border', 'jet-form-builder' ),
386 'separator' => 'after',
387 'css_selector' => array(
388 $this->selector( 'description' ) => 'border-style:{{STYLE}};border-width:{{WIDTH}};border-radius:{{RADIUS}};border-color:{{COLOR}};',
389 ),
390 ] );
391
392 $this->controls_manager->add_control( [
393 'id' => 'description_typography',
394 'type' => 'typography',
395 'separator' => 'after',
396 'css_selector' => [
397 $this->selector( 'description' ) => 'font-family: {{FAMILY}}; font-weight: {{WEIGHT}}; text-transform: {{TRANSFORM}}; font-style: {{STYLE}}; text-decoration: {{DECORATION}}; line-height: {{LINEHEIGHT}}{{LH_UNIT}}; letter-spacing: {{LETTERSPACING}}{{LS_UNIT}}; font-size: {{SIZE}}{{S_UNIT}};',
398 ],
399 ] );
400
401 $this->controls_manager->add_control( [
402 'id' => 'description_color',
403 'type' => 'color-picker',
404 'separator' => 'after',
405 'label' => __( 'Text Color', 'jet-form-builder' ),
406 'css_selector' => array(
407 $this->selector( 'description' ) => 'color: {{VALUE}}',
408 ),
409 ] );
410
411 $this->controls_manager->add_control( [
412 'id' => 'description_background_color',
413 'type' => 'color-picker',
414 'label' => __( 'Background Color', 'jet-form-builder' ),
415 'css_selector' => array(
416 $this->selector( 'description' ) => 'background-color: {{VALUE}}',
417 ),
418 ] );
419
420 $this->controls_manager->end_section();
421 }
422
423 private function add_required_mark_controls() {
424 $this->controls_manager->start_section(
425 'style_controls',
426 [
427 'id' => 'required_style',
428 'title' => __( 'Required Mark', 'jet-form-builder' )
429 ]
430 );
431
432 $this->controls_manager->add_control( [
433 'id' => 'required_typography',
434
435 'disable_line_height' => true,
436 'disable_family' => true,
437 'disable_transform' => true,
438 'disable_style' => true,
439 'disable_decoration' => true,
440 'disable_letter_spacing' => true,
441 'separator' => 'after',
442 'type' => 'typography',
443 'css_selector' => [
444 $this->selector( 'required' ) => 'font-weight: {{WEIGHT}}; font-size: {{SIZE}}{{S_UNIT}};',
445 ],
446 ] );
447
448 $this->controls_manager->add_control( [
449 'id' => 'required_color',
450 'type' => 'color-picker',
451 'separator' => 'after',
452 'label' => __( 'Text Color', 'jet-form-builder' ),
453 'css_selector' => array(
454 $this->selector( 'required' ) => 'color: {{VALUE}}',
455 ),
456 ] );
457
458 $this->controls_manager->add_control( [
459 'id' => 'required_background_color',
460 'type' => 'color-picker',
461 'label' => __( 'Background Color', 'jet-form-builder' ),
462 'css_selector' => array(
463 $this->selector( 'required' ) => 'background-color: {{VALUE}}',
464 ),
465 ] );
466
467
468 $this->controls_manager->end_section();
469 }
470
471 private function add_input_controls() {
472 $this->controls_manager->start_section(
473 'style_controls',
474 [
475 'id' => 'input_style',
476 'title' => __( 'Field', 'jet-form-builder' )
477 ]
478 );
479
480 $this->add_margin_padding(
481 $this->selector( 'input' ),
482 array(
483 'margin' => array(
484 'id' => 'input_margin',
485 'separator' => 'after',
486 ),
487 'padding' => array(
488 'id' => 'input_padding',
489 'separator' => 'after',
490 )
491 )
492 );
493
494 $this->controls_manager->add_control( $this->merge_controls_or_add_id(
495 array(
496 'id' => 'input_alignment',
497 'type' => 'choose',
498 'label' => __( 'Alignment', 'jet-form-builder' ),
499 'separator' => 'after',
500 'options' => [
501 'left' => [
502 'shortcut' => __( 'Left', 'jet-form-builder' ),
503 'icon' => 'dashicons-editor-alignleft',
504 ],
505 'center' => [
506 'shortcut' => __( 'Center', 'jet-form-builder' ),
507 'icon' => 'dashicons-editor-aligncenter',
508 ],
509 'right' => [
510 'shortcut' => __( 'Right', 'jet-form-builder' ),
511 'icon' => 'dashicons-editor-alignright',
512 ],
513 ],
514 'css_selector' => array(
515 $this->selector( 'input' ) => 'text-align: {{VALUE}};',
516 ),
517 ),
518 $this->get_additional_styles( 'input_alignment' )
519 ) );
520
521 $this->controls_manager->add_control( [
522 'id' => 'input_typography',
523 'type' => 'typography',
524 'separator' => 'after',
525 'css_selector' => [
526 $this->selector( 'input' ) => 'font-family: {{FAMILY}}; font-weight: {{WEIGHT}}; text-transform: {{TRANSFORM}}; font-style: {{STYLE}}; text-decoration: {{DECORATION}}; line-height: {{LINEHEIGHT}}{{LH_UNIT}}; letter-spacing: {{LETTERSPACING}}{{LS_UNIT}}; font-size: {{SIZE}}{{S_UNIT}};',
527 ],
528 ] );
529
530 $this->controls_manager->add_control( [
531 'id' => 'input_border',
532 'type' => 'border',
533 'label' => __( 'Border', 'jet-form-builder' ),
534 'separator' => 'after',
535 'css_selector' => array(
536 $this->selector( 'input' ) => 'border-style:{{STYLE}};border-width:{{WIDTH}};border-radius:{{RADIUS}};border-color:{{COLOR}};',
537 ),
538 ] );
539
540 $this->controls_manager->add_control( [
541 'id' => 'input_color',
542 'type' => 'color-picker',
543 'separator' => 'after',
544 'label' => __( 'Text Color', 'jet-form-builder' ),
545 'css_selector' => array(
546 $this->selector( 'input' ) => 'color: {{VALUE}}',
547 ),
548 ] );
549
550 $this->controls_manager->add_control( [
551 'id' => 'input_background_color',
552 'type' => 'color-picker',
553 'label' => __( 'Background Color', 'jet-form-builder' ),
554 'css_selector' => array(
555 $this->selector( 'input' ) => 'background-color: {{VALUE}}',
556 ),
557 ] );
558
559 $this->controls_manager->end_section();
560 }
561
562
563 }