PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.14.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.14.0
2.14.0 2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 81 releases
← All changes | includes/blocks/form-input/block.php +112 -0 2.7.6 → 2.14.0 View file →
@@ -1,0 +1,112 @@
1 +<?php
2 +namespace ABlocks\Blocks\FormInput;
3 +
4 +use ABlocks\Controls\Color;
5 +use ABlocks\Controls\Range;
6 +
7 +if ( ! defined( 'ABSPATH' ) ) {
8 + exit;
9 +}
10 +
11 +use ABlocks\Classes\BlockBaseAbstract;
12 +use ABlocks\Classes\CssGenerator;
13 +
14 +class Block extends BlockBaseAbstract {
15 + protected $parent_block_name = 'form-builder';
16 + protected $block_name = 'form-input';
17 +
18 + public function build_css( $attributes ) {
19 + $css_generator = new CssGenerator( $attributes );
20 + $css_generator->add_class_styles(
21 + '{{WRAPPER}}',
22 + $this->get_wrapper_css( $attributes ),
23 + $this->get_wrapper_css( $attributes, 'Tablet' ),
24 + $this->get_wrapper_css( $attributes, 'Mobile' ),
25 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_wrapper_css( $attributes, $device ); } )
26 + );
27 + $css_generator->add_class_styles(
28 + '{{WRAPPER}}.ablocks-block--form-input',
29 + $this->get_input_block_main_wrapper( $attributes ),
30 + $this->get_input_block_main_wrapper( $attributes, 'Tablet' ),
31 + $this->get_input_block_main_wrapper( $attributes, 'Mobile' ),
32 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_block_main_wrapper( $attributes, $device ); } )
33 + );
34 +
35 + // Generate button icon CSS start
36 + $css_generator->add_class_styles(
37 + '{{WRAPPER}} .ablocks-icon-wrap',
38 + $this->get_icon_wrapper_css( $attributes ),
39 + $this->get_icon_wrapper_css( $attributes, 'Tablet' ),
40 + $this->get_icon_wrapper_css( $attributes, 'Mobile' ),
41 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_icon_wrapper_css( $attributes, $device ); } )
42 + );
43 + $css_generator->add_class_styles(
44 + '{{WRAPPER}} .ablocks-form-builder__input-show-icon',
45 + $this->get_icon_space_css( $attributes ),
46 + $this->get_icon_space_css( $attributes, 'Tablet' ),
47 + $this->get_icon_space_css( $attributes, 'Mobile' ),
48 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_icon_space_css( $attributes, $device ); } )
49 + );
50 +
51 + $css_generator->add_class_styles(
52 + '{{WRAPPER}} .ablocks-form-builder__input-toggle-password .ablocks-icon-wrap ',
53 + $this->get_password_show_hide_icon_wrapper_css( $attributes )
54 + );
55 + return $css_generator->generate_css();
56 + }
57 +
58 + public function get_wrapper_css() {
59 +
60 + return [];
61 +
62 + }
63 + public function get_icon_wrapper_css( $attributes, $device = '' ) {
64 + $css = [];
65 + if ( isset( $attributes['inputIconSize'] ) ) {
66 + $css['font-size'] = $attributes['inputIconSize'] . 'px';
67 + }
68 + return array_merge(
69 + [ 'fill' => Color::get_css( isset( $attributes['iconColor'] ) ? $attributes['iconColor'] : '' ) ],
70 + $css
71 + );
72 + }
73 + public function get_icon_space_css( $attributes, $device = '' ) {
74 + $css = [];
75 + if ( isset( $attributes['inputIconSpace'] ) ) {
76 + $css['padding-left'] = $attributes['inputIconSpace'] . 'px';
77 + }
78 +
79 + return $css;
80 + }
81 +
82 + public function get_input_block_main_wrapper( $attributes, $device = '' ) {
83 + $css = [];
84 + $css['box-sizing'] = 'border-box';
85 +
86 + // The device's own width, else the nearest containing wider device's
87 + // (custom breakpoints included), else Desktop's.
88 + $input_width = isset( $attributes['inputWidth'] ) ? (array) $attributes['inputWidth'] : [];
89 + $widthValue = \ABlocks\Helper::get_responsive_value( $input_width, 'value', $device );
90 + $widthValue = false === $widthValue ? 100 : $widthValue;
91 + $widthUnit = \ABlocks\Helper::get_responsive_value( $input_width, 'valueUnit', $device );
92 + $widthUnit = false === $widthUnit ? '%' : $widthUnit;
93 +
94 + if ( is_numeric( $widthValue ) ) {
95 + $widthValue = max( 0, floatval( $widthValue ) - 1 );
96 + }
97 +
98 + $css['width'] = $widthValue . $widthUnit;
99 +
100 + return $css;
101 + }
102 +
103 + public function get_password_show_hide_icon_wrapper_css( $attributes ) {
104 + $password_show_hide_icon_wrapper_css = [];
105 +
106 + if ( isset( $attributes['passwordShowHideIconSize'] ) ) {
107 + $password_show_hide_icon_wrapper_css['font-size'] = $attributes['passwordShowHideIconSize'] . 'px';
108 + }
109 +
110 + return $password_show_hide_icon_wrapper_css;
111 + }
112 +}