| 1 |
<?php |
| 2 |
namespace Easyel\EasyElements\Extensions\Jarallax; |
| 3 |
use Elementor\Controls_Manager; |
| 4 |
use Elementor\Element_Base; |
| 5 |
|
| 6 |
if (!defined('ABSPATH')) { |
| 7 |
exit; |
| 8 |
} // Exit if accessed directly |
| 9 |
|
| 10 |
|
| 11 |
class JaralaxControl { |
| 12 |
|
| 13 |
private static $instance = null; |
| 14 |
|
| 15 |
public static function get_instance() { |
| 16 |
if ( self::$instance === null ) { |
| 17 |
self::$instance = new self(); |
| 18 |
} |
| 19 |
return self::$instance; |
| 20 |
} |
| 21 |
|
| 22 |
public static function init() { |
| 23 |
add_action('elementor/element/image/section_style_image/after_section_end', [__CLASS__, 'Easyel_inject_section_class'], 199, 2); |
| 24 |
add_action('elementor/element/eel-advance-image/image_style_section/after_section_end', [__CLASS__, 'Easyel_inject_section_class'], 199, 2); |
| 25 |
} |
| 26 |
|
| 27 |
public static function Easyel_inject_section_class( $element, $args ) { |
| 28 |
|
| 29 |
$element->start_controls_section( |
| 30 |
'rt_jarallax_section', |
| 31 |
[ |
| 32 |
'label' => esc_html__( 'Easy Parallax', 'easy-elements' ), |
| 33 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 34 |
] |
| 35 |
); |
| 36 |
|
| 37 |
$element->add_control( |
| 38 |
'enable_jarallax', |
| 39 |
[ |
| 40 |
'label' => esc_html__( 'Enable Parallax', 'easy-elements' ), |
| 41 |
'type' => Controls_Manager::SWITCHER, |
| 42 |
'label_on' => esc_html__( 'Yes', 'easy-elements' ), |
| 43 |
'label_off' => esc_html__( 'No', 'easy-elements' ), |
| 44 |
'return_value' => 'yes', |
| 45 |
'prefix_class' => 'eele-has-jarallax-img-', |
| 46 |
'render_type' => 'template', |
| 47 |
] |
| 48 |
); |
| 49 |
|
| 50 |
$element->add_responsive_control( |
| 51 |
'jarallax_image_width', |
| 52 |
[ |
| 53 |
'label' => esc_html__( 'Width', 'easy-elements' ), |
| 54 |
'type' => Controls_Manager::SLIDER, |
| 55 |
'size_units' => [ 'px', '%' ], |
| 56 |
'range' => [ |
| 57 |
'px' => [ 'min' => 0, 'max' => 1000, 'step' => 1 ], |
| 58 |
'%' => [ 'min' => 0, 'max' => 100 ], |
| 59 |
], |
| 60 |
'selectors' => [ |
| 61 |
'{{WRAPPER}} .elementor-widget-container .jarallax' => 'width: {{SIZE}}{{UNIT}} !important;', |
| 62 |
'{{WRAPPER}} .elementor-widget-container img, {{WRAPPER}} .jarallax img' => 'width: {{SIZE}}{{UNIT}};', |
| 63 |
], |
| 64 |
'condition' => [ |
| 65 |
'enable_jarallax' => 'yes', |
| 66 |
] |
| 67 |
] |
| 68 |
); |
| 69 |
|
| 70 |
$element->add_responsive_control( |
| 71 |
'jarallax_image_height', |
| 72 |
[ |
| 73 |
'label' => esc_html__( 'Height', 'easy-elements' ), |
| 74 |
'type' => Controls_Manager::SLIDER, |
| 75 |
'size_units' => [ 'px', '%' ], |
| 76 |
'range' => [ |
| 77 |
'px' => [ 'min' => 0, 'max' => 1000, 'step' => 1 ], |
| 78 |
'%' => [ 'min' => 0, 'max' => 100 ], |
| 79 |
], |
| 80 |
'selectors' => [ |
| 81 |
'{{WRAPPER}} .elementor-widget-container .jarallax, {{WRAPPER}} .jarallax-container' => 'height: {{SIZE}}{{UNIT}} !important;', |
| 82 |
'{{WRAPPER}} .elementor-widget-container img, {{WRAPPER}} .jarallax img' => 'height: {{SIZE}}{{UNIT}};', |
| 83 |
], |
| 84 |
'condition' => [ |
| 85 |
'enable_jarallax' => 'yes', |
| 86 |
] |
| 87 |
] |
| 88 |
); |
| 89 |
|
| 90 |
$element->add_responsive_control( |
| 91 |
'jarallax_image_border_radius', |
| 92 |
[ |
| 93 |
'label' => esc_html__( 'Image Border Radius', 'easy-elements' ), |
| 94 |
'type' => Controls_Manager::DIMENSIONS, |
| 95 |
'size_units' => [ 'px', '%' ], |
| 96 |
'selectors' => [ |
| 97 |
'{{WRAPPER}} .jarallax-container' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;', |
| 98 |
'{{WRAPPER}} .jarallax-container img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;', |
| 99 |
], |
| 100 |
'condition' => [ |
| 101 |
'enable_jarallax' => 'yes', |
| 102 |
] |
| 103 |
] |
| 104 |
); |
| 105 |
|
| 106 |
$element->end_controls_section(); |
| 107 |
} |
| 108 |
} |