PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.2.4
UiCore Elements – Free widgets and templates for Elementor v1.2.4
1.3.17 1.3.16 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 41 releases
uicore-elements / includes / widgets / gallery-carousel.php

gallery-carousel.php in UiCore Elements – Free widgets and templates for Elementor 1.2.4, at includes/widgets/gallery-carousel.php

320 lines 10.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace UiCoreElements;
3
4 use Elementor\Controls_Manager;
5 use Elementor\Group_Control_Background;
6
7 use UiCoreElements\UiCoreWidget;
8 use UiCoreElements\Utils\Animation_Trait;
9 use UiCoreElements\Utils\Gallery_Trait;
10 use UiCoreElements\Utils\Carousel_Trait;
11 use UicoreElements\Utils\Item_Style_Component;
12
13 defined('ABSPATH') || exit();
14
15 /**
16 * Gallery Carousel
17 *
18 * @author Lucas Marini Falbo <lucas95@uicore.co>
19 * @since 1.0.14
20 */
21
22 class GalleryCarousel extends UiCoreWidget
23 {
24 use Animation_Trait;
25 use Gallery_Trait;
26 use Carousel_Trait;
27 use Item_Style_Component;
28
29 public function get_name()
30 {
31 return 'uicore-gallery-carousel';
32 }
33 public function get_title()
34 {
35 return esc_html__('Gallery Carousel', 'uicore-elements');
36 }
37 public function get_icon()
38 {
39 return 'eicon-carousel-loop ui-e-widget';
40 }
41 public function get_categories()
42 {
43 return ['uicore'];
44 }
45 public function get_keywords()
46 {
47 return ['gallery', 'carousel', 'slides', 'content', 'box'];
48 }
49 public function get_styles()
50 {
51 $styles = [
52 'gallery-carousel',
53 'carousel',
54 'animation', // hover animations
55 'entrance', // entrance basic style
56 ];
57 if(!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')){
58 $styles['e-animations'] = [ // entrance animations
59 'external' => true,
60 ];
61 }
62 return $styles;
63 }
64 public function get_scripts()
65 {
66 return $this->TRAIT_get_carousel_scripts();
67 }
68 public function has_widget_inner_wrapper(): bool {
69 // TODO: remove after 3.30, when the full deprecation of widget innet wrapper is ready
70 return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
71 }
72 protected function register_controls()
73 {
74 $this->TRAIT_register_gallery_repeater_controls('Content');
75 $this->TRAIT_register_additional_controls(true);
76
77 $this->start_controls_section(
78 'carousel_section',
79 [
80 'label' => esc_html__('Carousel Settings', 'uicore-elements'),
81 'tab' => Controls_Manager::TAB_CONTENT,
82 ]
83 );
84 $this->TRAIT_register_carousel_additional_controls();
85 $this->add_control(
86 'divider',
87 [
88 'type' => Controls_Manager::DIVIDER,
89 ]
90 );
91 $this->TRAIT_register_carousel_settings_controls();
92
93 $this->end_controls_section();
94
95 $this->TRAIT_register_navigation_controls();
96
97 $this->start_controls_section(
98 'items_style_section',
99 [
100 'label' => esc_html__('Item', 'uicore-elements'),
101 'tab' => Controls_Manager::TAB_STYLE,
102 ]
103 );
104
105 $this->TRAIT_register_all_item_style_controls();
106
107 $this->end_controls_section();
108
109 $this->TRAIT_register_filters_style_controls();
110 $this->TRAIT_register_image_style_controls(true);
111 $this->TRAIT_register_title_style_controls();
112 $this->TRAIT_register_description_style_controls();
113 $this->TRAIT_register_tags_style_controls();
114 $this->TRAIT_register_badge_style_controls();
115 $this->TRAIT_register_navigation_style_controls();
116 $this->TRAIT_register_gallery_animations();
117
118 // Update some component controls
119 $this->update_control(
120 'item_border_border',
121 [
122 'default' => 'none'
123 ]
124 );
125 $this->update_control(
126 'item_padding',
127 [
128 'default' => [
129 'top' => 10,
130 'right' => 10,
131 'bottom' => 10,
132 'left' => 10,
133 ],
134 'selectors' => [
135 '{{WRAPPER}} .ui-e-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
136 ],
137 ]
138 );
139 $this->update_control(
140 'item_border_radius',
141 [
142 'default' => [
143 'top' => 0,
144 'right' => 0,
145 'bottom' => 0,
146 'left' => 0,
147 'unit' => 'px',
148 ]
149 ]
150 );
151 $this->update_control(
152 'match_height', [
153 'render_type' => 'template',
154 ]
155 );
156
157 $image_conditions = [
158 'relation' => 'or',
159 'terms' => [
160 [
161 'relation' => 'and',
162 'terms' => [
163 [
164 'name' => 'layout',
165 'operator' => '==',
166 'value' => '',
167 ],
168 [
169 'name' => 'vertical',
170 'operator' => '!=',
171 'value' => 'true',
172 ],
173 ]
174 ],
175 [
176 'relation' => 'and',
177 'terms' => [
178 [
179 'name' => 'layout',
180 'operator' => '==',
181 'value' => 'ui-e-overlay',
182 ],
183 [
184 'name' => 'match_height',
185 'operator' => '==',
186 'value' => 'yes',
187 ],
188 [
189 'name' => 'vertical',
190 'operator' => '!=',
191 'value' => 'true',
192 ],
193 ],
194 ]
195 ],
196 ];
197
198 $this->update_responsive_control(
199 'image_height', [
200 'conditions' => $image_conditions
201 ]
202 );
203 $this->update_responsive_control(
204 'style_image_section', [
205 'conditions' => $image_conditions
206 ]
207 );
208
209
210 // Remove some useless component controls or group controls that can't be properly updated
211 $this->remove_control('item_background_background');
212 $this->remove_control('item_hover_background_background');
213 $this->remove_control('item_background_color');
214 $this->remove_control('item_background_image');
215 $this->remove_control('item_background_gradient');
216
217 // Inject new controls
218 $this->start_injection([
219 'of' => 'animation_style',
220 'at' => 'after',
221 ]);
222
223 $this->add_control(
224 'main_image',
225 [
226 'label' => __('Main image', 'uicore-elements'),
227 'type' => Controls_Manager::SELECT,
228 'default' => '',
229 'options' => [
230 '' => esc_html__('Default', 'uicore-elements'),
231 'ui-e-main-image-scale' => esc_html__('Scale', 'uicore-elements'),
232 'ui-e-main-image-show' => esc_html__('Show Info', 'uicore-elements'),
233 'ui-e-main-image-show_scale' => esc_html__('Show Info & Scale', 'uicore-elements'),
234 ],
235 'description' => __('Works best with centered slides.', 'uicore-elements'),
236 'prefix_class' => '',
237 'render_type' => 'template',
238 'frontend_available' => true,
239 'condition' => [
240 'animation_style!' => 'marquee',
241 ]
242 ]
243 );
244
245 $this->end_injection();
246
247 $this->start_injection([
248 'of' => 'item_border_border',
249 'at' => 'before',
250 ]);
251
252 // normal background controls
253 $this->add_group_control(
254 Group_Control_Background::get_type(),
255 [
256 'name' => 'item_gallery_background',
257 'selector' => '{{WRAPPER}} .ui-e-item',
258 'condition' => [
259 'layout' => '',
260 ]
261 ]
262 );
263 $this->add_group_control(
264 Group_Control_Background::get_type(),
265 [
266 'name' => 'item_content_background',
267 'selector' => '{{WRAPPER}} .ui-e-content',
268 'condition' => [
269 'layout' => 'ui-e-overlay',
270 ]
271 ]
272 );
273
274 $this->end_injection();
275
276 $this->start_injection([
277 'of' => 'item_hover_border_color',
278 'at' => 'before',
279 ]);
280
281 // hover background controls
282 $this->add_group_control(
283 Group_Control_Background::get_type(),
284 [
285 'name' => 'item_gallery_hover_background',
286 'selector' => '{{WRAPPER}} .ui-e-item:hover',
287 'condition' => [
288 'layout' => '',
289 ]
290 ]
291 );
292 $this->add_group_control(
293 Group_Control_Background::get_type(),
294 [
295 'name' => 'item_content_hover_background',
296 'selector' => '{{WRAPPER}} .ui-e-item:hover .ui-e-content',
297 'condition' => [
298 'layout' => 'ui-e-overlay',
299 ]
300 ]
301 );
302
303 $this->end_injection();
304 }
305
306 public function render()
307 {
308 $settings = $this->get_settings_for_display();
309 ?>
310 <div class="ui-e-carousel swiper">
311 <div class='swiper-wrapper'>
312 <?php $this->TRAIT_render_gallery($settings, true); ?>
313 </div>
314 </div>
315 <?php $this->TRAIT_render_carousel_navigations(); ?>
316 <?php
317 }
318
319 }
320 \Elementor\Plugin::instance()->widgets_manager->register(new GalleryCarousel());