PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.9.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.9.1
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 1.1.2 All 80 releases
ablocks / includes / blocks / table / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.9.1, at includes/blocks/table/block.php

188 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\Table;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Classes\BlockBaseAbstract;
9 use ABlocks\Classes\CssGenerator;
10 use ABlocks\Controls\Border;
11
12 class Block extends BlockBaseAbstract {
13 protected $block_name = 'table';
14
15 public function build_css( $attributes ) {
16
17 // Generate CSS start
18 $css_generator = new CssGenerator( $attributes, $this->block_name );
19 $css_generator->add_class_styles(
20 '{{WRAPPER}}.ablocks-block--table table',
21 $this->get_table_css( $attributes )
22 );
23 $css_generator->add_class_styles(
24 '{{WRAPPER}}.ablocks-block--table table, {{WRAPPER}}.ablocks-block--table-header .ablocks-block--table-cell , {{WRAPPER}}.ablocks-block--table .ablocks-block--table-cell',
25 $this->get_table_border_css( $attributes ),
26 $this->get_table_border_css( $attributes, 'Tablet' ),
27 $this->get_table_border_css( $attributes, 'Mobile' )
28 );
29 $css_generator->add_class_styles(
30 '{{WRAPPER}}.ablocks-block--table table:hover, {{WRAPPER}}.ablocks-block--table-header .ablocks-block--table-cell:hover, {{WRAPPER}}.ablocks-block--table .ablocks-block--table-cell:hover',
31 $this->get_table_border_hover_css( $attributes ),
32 $this->get_table_border_hover_css( $attributes, 'Tablet' ),
33 $this->get_table_border_hover_css( $attributes, 'Mobile' )
34 );
35 $css_generator->add_class_styles(
36 '{{WRAPPER}} .ablocks-block--table-body .ablocks-table-row--odd',
37 $this->get_row_odd_css( $attributes )
38 );
39 $css_generator->add_class_styles(
40 '{{WRAPPER}} .ablocks-block--table-body .ablocks-table-row--odd:hover',
41 $this->get_row_odd_hover_css( $attributes )
42 );
43 $css_generator->add_class_styles(
44 '{{WRAPPER}} .ablocks-block--table-body .ablocks-table-row--even',
45 $this->get_row_even_css( $attributes )
46 );
47 $css_generator->add_class_styles(
48 '{{WRAPPER}} .ablocks-block--table-body .ablocks-table-row--even:hover',
49 $this->get_row_even_hover_css( $attributes )
50 );
51 // ---header----
52 $css_generator->add_class_styles(
53 '{{WRAPPER}}.ablocks-block--table .ablocks-block--table-header',
54 $this->get_header_css( $attributes )
55 );
56 $css_generator->add_class_styles(
57 '{{WRAPPER}}.ablocks-block--table .ablocks-block--table-header:hover',
58 $this->get_header_hover_css( $attributes )
59 );
60 // --table body----
61 $css_generator->add_class_styles(
62 '{{WRAPPER}} .ablocks-block--table-body',
63 $this->get_body_css( $attributes )
64 );
65 $css_generator->add_class_styles(
66 '{{WRAPPER}} .ablocks-block--table-body:hover',
67 $this->get_body_hover_css( $attributes )
68 );
69
70 // --table footer--
71 $css_generator->add_class_styles(
72 '{{WRAPPER}}.ablocks-block--table .ablocks-block--table-footer',
73 $this->get_footer_css( $attributes )
74 );
75 $css_generator->add_class_styles(
76 '{{WRAPPER}}.ablocks-block--table .ablocks-block--table-footer:hover',
77 $this->get_footer_hover_css( $attributes )
78 );
79 return $css_generator->generate_css();
80 }
81 public function get_table_css( $attributes, $device = '' ) {
82 $css = [];
83
84 if ( ! empty( $attributes['borderCollapse'] ) && $attributes['borderCollapse'] === 'collapse' ) {
85 $css['border-collapse'] = 'collapse';
86 } elseif ( ! empty( $attributes['borderCollapse'] ) && $attributes['borderCollapse'] === 'separate' ) {
87 $css['border-collapse'] = 'separate';
88 }
89
90 return $css;
91 }
92
93 public function get_table_border_css( $attributes, $device = '' ) {
94
95 return Border::get_css( $attributes['border'], '', $device );
96
97 }
98 public function get_table_border_hover_css( $attributes, $device = '' ) {
99
100 return Border::get_hover_css( $attributes['border'], '', $device );
101 }
102
103 public function get_row_odd_css( $attributes, $device = '' ) {
104 $css = [];
105 if ( ! empty( $attributes['rowOddColor'] ) ) {
106 $css['background'] = $attributes['rowOddColor'];
107 }
108 return $css;
109 }
110
111 public function get_row_odd_hover_css( $attributes, $device = '' ) {
112 $css = [];
113 if ( ! empty( $attributes['rowOddColorH'] ) ) {
114 $css['background'] = $attributes['rowOddColorH'];
115 }
116 return $css;
117 }
118
119 public function get_row_even_css( $attributes, $device = '' ) {
120 $css = [];
121 if ( ! empty( $attributes['rowEvenColor'] ) ) {
122 $css['background'] = $attributes['rowEvenColor'];
123 }
124 return $css;
125 }
126
127 public function get_row_even_hover_css( $attributes, $device = '' ) {
128 $css = [];
129 if ( ! empty( $attributes['rowEvenColorH'] ) ) {
130 $css['background'] = $attributes['rowEvenColorH'];
131 }
132 return $css;
133 }
134
135 public function get_header_css( $attributes, $device = '' ) {
136 $css = [];
137 if ( ! empty( $attributes['headerColor'] ) ) {
138 $css['background'] = $attributes['headerColor'] . ' !important';
139 }
140
141 return $css;
142 }
143
144 public function get_header_hover_css( $attributes, $device = '' ) {
145 $css = [];
146 if ( ! empty( $attributes['headerColorH'] ) ) {
147 $css['background'] = $attributes['headerColorH'] . ' !important';
148 }
149
150 return $css;
151 }
152
153 public function get_body_css( $attributes, $device = '' ) {
154 $css = [];
155 if ( ! empty( $attributes['bodyBg'] ) ) {
156 $css['background'] = $attributes['bodyBg'] . ' !important';
157 }
158 return $css;
159 }
160
161 public function get_body_hover_css( $attributes, $device = '' ) {
162 $css = [];
163 if ( ! empty( $attributes['bodyBgH'] ) ) {
164 $css['background'] = $attributes['bodyBgH'] . ' !important';
165 }
166
167 return $css;
168 }
169
170 public function get_footer_css( $attributes, $device = '' ) {
171 $css = [];
172 if ( ! empty( $attributes['footerColor'] ) ) {
173 $css['background'] = $attributes['footerColor'] . ' !important';
174 }
175
176 return $css;
177 }
178
179 public function get_footer_hover_css( $attributes, $device = '' ) {
180 $css = [];
181 if ( ! empty( $attributes['footerColorH'] ) ) {
182 $css['background'] = $attributes['footerColorH'] . ' !important';
183 }
184
185 return $css;
186 }
187 }
188