<?php
namespace Elementor;

class ThemeDraft_Home_Two_Slider_Widget extends Widget_Base {

	public function get_name() {

		return 'themedraft_home_two_slider';
	}

	public function get_title() {
		return esc_html__( 'Home Two Slider', 'themedraft-core' );
	}

	public function get_icon() {

		return 'eicon-slider-push';
	}

	public function get_categories() {
		return [ 'themedraft_elements' ];
	}


	protected function register_controls() {

		//Content tab start
		$this->start_controls_section(
			'slider_content',
			[
				'label' => esc_html__( 'Add Slides', 'themedraft-core' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			]
		);

		$repeater = new Repeater();

		$repeater->add_control(
		    'subtitle',
		    [
		        'label'       => __( 'Subtitle', 'themedraft-core' ),
		        'type'        => Controls_Manager::TEXTAREA,
		        'rows'        => 5,
		        'default'     => 'We provide the best factory services.',
		    ]
		);

		$repeater->add_control(
			'slide_title',
			[
				'label' => esc_html__( 'Title', 'themedraft-core' ),
				'type' => Controls_Manager::WYSIWYG,
				'default' => '<h2>Expert workers are giving best services.</h2>',
				'description' => __( 'Use Heading ( H1 - H6 ) for title text.' , 'themedraft-core' ),
				'label_block' => true,
			]
		);


		$repeater->add_control(
			'slide_image',
			[
				'label' => __( 'Slide Image', 'themedraft-core' ),
				'type' => Controls_Manager::MEDIA,
				'label_block' => true,
				'default' => [
					'url' => Utils::get_placeholder_image_src(),
				],
			]
		);

		$repeater->add_control(
			'btn1_text',
			[
				'label' => __( 'Button One Text', 'themedraft-core' ),
				'type' => Controls_Manager::TEXT,
				'separator' => 'before',
				'label_block' => true,
				'default' => 'Read More',
				'placeholder' => __( 'Type button text here.', 'themedraft-core' ),
			]
		);

		$repeater->add_control(
			'btn1_url',
			[
				'label' => __( 'Button One URL', 'themedraft-core' ),
				'type' => Controls_Manager::URL,
				'placeholder' => __( 'https://your-link.com', 'themedraft-core' ),
				'show_external' => true,
				'default' => [
					'url' => '',
					'is_external' => false,
					'nofollow' => false,
				],
			]
		);

		//Button 2 Text
		$repeater->add_control(
			'btn2_text',
			[
				'label' => __( 'Button Two Text', 'themedraft-core' ),
				'type' => Controls_Manager::TEXT,
				'separator' => 'before',
				'label_block' => true,
				'placeholder' => __( 'Type button text here.', 'themedraft-core' ),
			]
		);

		//Button 2 Url
		$repeater->add_control(
			'btn2_url',
			[
				'label' => __( 'Button Two URL', 'themedraft-core' ),
				'type' => Controls_Manager::URL,
				'separator' => 'before',
				'placeholder' => __( 'https://your-link.com', 'themedraft-core' ),
				'show_external' => true,
				'default' => [
					'url' => '',
					'is_external' => false,
					'nofollow' => false,
				],
			]
		);

		$this->add_control(
			'slide_items',
			[
				'label' => __( 'Slide List', 'themedraft-core' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'default' => [
					[
						'subtitle' => 'We provide the best factory services.',
						'slide_title' => '<h2>Expert workers are giving best services.</h2>',
						'slide_content_text' => 'Induxter is an experienced company for your business development and success achievement.',
					],
				],
				'title_field' => '{{{ slide_title }}}',
			]
		);

		$this->end_controls_section();

		//Start slider  options control
		$this->start_controls_section(
			'home_slider_options',
			[
				'label' => __( 'Slider Options', 'themedraft-core' ),
				'tab' => Controls_Manager::TAB_CONTENT,
			]
		);

		$this->add_responsive_control(
			'slider_height',
			[
				'label' => __( 'Slider Height (px)', 'themedraft-core' ),
				'type' => Controls_Manager::SLIDER,
				'range' => [
					'px' => [
						'min' => 300,
						'max' => 1200,
					],
				],
				'devices' => [ 'desktop', 'tablet', 'mobile' ],
				'selectors' => [
					'{{WRAPPER}} .td-home-slider-area .td-single-slide-item' => 'height: {{SIZE}}{{UNIT}};',
				],
			]
		);

		$this->add_control(
			'autoplay',
			[
				'label' => __( 'Autoplay', 'themedraft-core' ),
				'type' => Controls_Manager::SWITCHER,
				'show_label' => true,
				'label_block' => false,
				'default' => 'yes',
				'separator' => 'before',
			]
		);

		$this->add_control(
			'autoplay_interval',
			[
				'label' => __( 'Autoplay Interval', 'themedraft-core' ),
				'type' => Controls_Manager::SELECT,
				'show_label' => true,
				'label_block' => false,
				'options' => [
					'2000'  => __( '2 seconds', 'themedraft-core' ),
					'3000'  => __( '3 seconds', 'themedraft-core' ),
					'4000'  => __( '4 seconds', 'themedraft-core' ),
					'5000'  => __( '5 seconds', 'themedraft-core' ),
					'6000'  => __( '6 seconds', 'themedraft-core' ),
					'7000'  => __( '7 seconds', 'themedraft-core' ),
					'8000'  => __( '8 seconds', 'themedraft-core' ),
					'9000'  => __( '9 seconds', 'themedraft-core' ),
					'10000'  => __( '10 seconds', 'themedraft-core' ),
				],
				'default' => '6000',
				'condition' => [
					'autoplay' => 'yes',
				],
			]
		);

		$this->add_control(
			'nav_arrow',
			[
				'label' => __( 'Navigation Arrow On Hover', 'themedraft-core' ),
				'type' => Controls_Manager::SWITCHER,
				'show_label' => true,
				'label_block' => false,
				'default' => 'yes',
			]
		);

		$this->add_control(
			'nav_dots',
			[
				'label' => __( 'Navigation Dots', 'themedraft-core' ),
				'type' => Controls_Manager::SWITCHER,
				'show_label' => true,
				'label_block' => false,
				'default' => 'no',
			]
		);

		$this->add_control(
			'slider_animation',
			[
				'label' => __( 'Animation', 'themedraft-core' ),
				'type' => Controls_Manager::SWITCHER,
				'show_label' => true,
				'label_block' => false,
				'default' => 'yes',
			]
		);

		$this->end_controls_section();
		//Slider  options control end


        $this->start_controls_section(
            'content_setting',
            [
                'label' => esc_html__( 'Content', 'themedraft-core' ),
                'tab'   => Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_control(
            'desktop_column',
            [
                'label'   => __( 'Desktop Column', 'themedraft-core' ),
                'type'    => Controls_Manager::SELECT,
                'default' => 'col-xl-6',
                'options' => [
                    'col-xl-1' => __( '1 Column', 'themedraft-core' ),
                    'col-xl-2'  => __( '2 Column', 'themedraft-core' ),
                    'col-xl-3'  => __( '3 Column', 'themedraft-core' ),
                    'col-xl-4'  => __( '4 Column', 'themedraft-core' ),
                    'col-xl-5'  => __( '5 Column', 'themedraft-core' ),
                    'col-xl-6'  => __( '6 Column', 'themedraft-core' ),
                    'col-xl-7'  => __( '7 Column', 'themedraft-core' ),
                    'col-xl-8'  => __( '8 Column', 'themedraft-core' ),
                    'col-xl-9'  => __( '9 Column', 'themedraft-core' ),
                    'col-xl-10'  => __( '10 Column', 'themedraft-core' ),
                    'col-xl-11'  => __( '11 Column', 'themedraft-core' ),
                    'col-xl-12'  => __( '12 Column', 'themedraft-core' ),
                ],
            ]
        );

		$this->add_control(
			'desktop_offset',
			[
				'label'   => __( 'Desktop Offset', 'themedraft-core' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'offset-xl-6',
				'options' => [
					'offset-xl-1' => __( '1 Column', 'themedraft-core' ),
					'offset-xl-2'  => __( '2 Column', 'themedraft-core' ),
					'offset-xl-3'  => __( '3 Column', 'themedraft-core' ),
					'offset-xl-4'  => __( '4 Column', 'themedraft-core' ),
					'offset-xl-5'  => __( '5 Column', 'themedraft-core' ),
					'offset-xl-6'  => __( '6 Column', 'themedraft-core' ),
					'offset-xl-7'  => __( '7 Column', 'themedraft-core' ),
					'offset-xl-8'  => __( '8 Column', 'themedraft-core' ),
					'offset-xl-9'  => __( '9 Column', 'themedraft-core' ),
					'offset-xl-10'  => __( '10 Column', 'themedraft-core' ),
					'offset-xl-11'  => __( '11 Column', 'themedraft-core' ),
					'offset-xl-12'  => __( '12 Column', 'themedraft-core' ),
				],
			]
		);

		$this->add_control(
			'ipad_pro_column',
			[
				'label'   => __( 'iPad Pro Column', 'themedraft-core' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'col-lg-8',
				'options' => [
					'col-lg-1' => __( '1 Column', 'themedraft-core' ),
					'col-lg-2'  => __( '2 Column', 'themedraft-core' ),
					'col-lg-3'  => __( '3 Column', 'themedraft-core' ),
					'col-lg-4'  => __( '4 Column', 'themedraft-core' ),
					'col-lg-5'  => __( '5 Column', 'themedraft-core' ),
					'col-lg-6'  => __( '6 Column', 'themedraft-core' ),
					'col-lg-7'  => __( '7 Column', 'themedraft-core' ),
					'col-lg-8'  => __( '8 Column', 'themedraft-core' ),
					'col-lg-9'  => __( '9 Column', 'themedraft-core' ),
					'col-lg-10'  => __( '10 Column', 'themedraft-core' ),
					'col-lg-11'  => __( '11 Column', 'themedraft-core' ),
					'col-lg-12'  => __( '12 Column', 'themedraft-core' ),
				],
			]
		);

		$this->add_control(
			'ipad_pro_offset',
			[
				'label'   => __( 'iPad Pro Offset', 'themedraft-core' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'offset-lg-4',
				'options' => [
					'offset-lg-1' => __( '1 Column', 'themedraft-core' ),
					'offset-lg-2'  => __( '2 Column', 'themedraft-core' ),
					'offset-lg-3'  => __( '3 Column', 'themedraft-core' ),
					'offset-lg-4'  => __( '4 Column', 'themedraft-core' ),
					'offset-lg-5'  => __( '5 Column', 'themedraft-core' ),
					'offset-lg-6'  => __( '6 Column', 'themedraft-core' ),
					'offset-lg-7'  => __( '7 Column', 'themedraft-core' ),
					'offset-lg-8'  => __( '8 Column', 'themedraft-core' ),
					'offset-lg-9'  => __( '9 Column', 'themedraft-core' ),
					'offset-lg-10'  => __( '10 Column', 'themedraft-core' ),
					'offset-lg-11'  => __( '11 Column', 'themedraft-core' ),
					'offset-lg-12'  => __( '12 Column', 'themedraft-core' ),
				],
			]
		);

        $this->add_responsive_control(
            'content_margin',
            [
                'label'      => esc_html__( 'Content Margin', 'themedraft-core' ),
                'type'       => Controls_Manager::DIMENSIONS,
                'size_units' => [ 'px', '%', 'em' ],
                'selectors'  => [
                    '{{WRAPPER}} .td-slider-content-wrapper' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );

        $this->end_controls_section();

		// Subtitle Style
		$this->start_controls_section(
			'subtitle_style_options',
			[
				'label' => esc_html__( 'Subtitle', 'themedraft-core' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			[
				'name' => 'subtitle_typo',
				'label' => __( 'Typography', 'themedraft-core' ),
				'selector' => '
                    {{WRAPPER}} .td-home-slider-two .td-slide-subtitle .subtitle
                ',
			]
		);

		$this->add_control(
			'subtitle_color',
			[
				'label'       => esc_html__('Color', 'themedraft-core'),
				'type'        => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .td-home-slider-two .td-slide-subtitle .subtitle' => 'color: {{VALUE}};',
				],
			]
		);

		$this->add_responsive_control(
			'subtitle_margin',
			[
				'label'      => esc_html__( 'Margin', 'themedraft-core' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => [ 'px', '%', 'em' ],
				'selectors'  => [
					'{{WRAPPER}} .td-home-slider-two .td-slide-subtitle .subtitle' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			]
		);

		$this->end_controls_section();


		// Title Style
		$this->start_controls_section(
			'title_style_options',
			[
				'label' => esc_html__( 'Title', 'themedraft-core' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			[
				'name' => 'title_typo',
				'label' => __( 'Typography', 'themedraft-core' ),
				'selector' => '
                    {{WRAPPER}} .td-home-slider-two .td-slide-title h1,
                    {{WRAPPER}} .td-home-slider-two .td-slide-title h2,
                    {{WRAPPER}} .td-home-slider-two .td-slide-title h3,
                    {{WRAPPER}} .td-home-slider-two .td-slide-title h4,
                    {{WRAPPER}} .td-home-slider-two .td-slide-title h5,
                    {{WRAPPER}} .td-home-slider-two .td-slide-title h6
                ',
			]
		);

		$this->add_control(
			'title_color',
			[
				'label'       => esc_html__('Color', 'themedraft-core'),
				'type'        => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .td-home-slider-two .td-slide-title h1,{{WRAPPER}} .td-home-slider-two .td-slide-title h2,{{WRAPPER}} .td-home-slider-two .td-slide-title h3,
                    {{WRAPPER}} .td-home-slider-two .td-slide-title h4,{{WRAPPER}} .td-home-slider-two .td-slide-title h5,{{WRAPPER}} .td-home-slider-two .td-slide-title h6,
                    {{WRAPPER}} .td-home-slider-two .td-slide-title strong' => 'color: {{VALUE}};',
				],
			]
		);

		$this->add_responsive_control(
			'title_margin',
			[
				'label'      => esc_html__( 'Margin', 'themedraft-core' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => [ 'px', '%', 'em' ],
				'selectors'  => [
					'{{WRAPPER}} .td-slide-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			]
		);

		$this->end_controls_section();


		// Start Button section
		$this->start_controls_section(
			'button_style_options',
			[
				'label' => esc_html__('Button Style', 'themedraft-core'),
				'tab'   => Controls_Manager::TAB_STYLE,
			]
		);

		$this->start_controls_tabs('td_button_style_tabs');

		//Default style tab start
		$this->start_controls_tab(
			'td_btn_style_default',
			[
				'label' => esc_html__('Normal', 'themedraft-core'),
			]
		);

		$this->add_control(
			'button_default_bg',
			[
				'label'     => esc_html__('Background Color', 'themedraft-core'),
				'type'      => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .slider-button-wrapper .td-button' => 'background-color: {{VALUE}};',
				],
			]
		);

		$this->add_control(
			'button_default_text_color',
			[
				'label'     => esc_html__('Text Color', 'themedraft-core'),
				'type'      => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .slider-button-wrapper .td-button' => 'color: {{VALUE}};',
				],
			]
		);

		$this->end_controls_tab();//Default style tab end

		//Hover style tab start
		$this->start_controls_tab(
			'td_btn_style_hover',
			[
				'label' => esc_html__('Hover', 'themedraft-core'),
			]
		);

		$this->add_control(
			'button_hover_bg',
			[
				'label'     => esc_html__('Background Color', 'themedraft-core'),
				'type'      => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .slider-button-wrapper .td-button:hover' => 'background-color: {{VALUE}};',
				],
			]
		);

		$this->add_control(
			'button_hover_text_color',
			[
				'label'     => esc_html__('Text Color', 'themedraft-core'),
				'type'      => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .slider-button-wrapper .td-button:hover' => 'color: {{VALUE}};',
				],
			]
		);

		$this->end_controls_tabs();//Hover style tab end

		$this->end_controls_section();// End Button section


		$this->start_controls_section(
			'slider_dot_style',
			[
				'label' => esc_html__( 'Slider Dot And Arrow', 'themedraft-core' ),
				'tab'   => Controls_Manager::TAB_STYLE,
				'conditions' => [
					'relation' => 'or',
					'terms' => [
						[
							'name' => 'nav_arrow',
							'operator' => '==',
							'value' => [
								'yes',
							],
						],
						[
							'name' => 'nav_dots',
							'operator' => '==',
							'value' => [
								'yes',
							],
						],
					],
				],
			]
		);

		$this->add_control(
			'dot_color',
			[
				'label'       => esc_html__('Dot Color', 'themedraft-core'),
				'type'        => Controls_Manager::COLOR,
				'selectors'   => [
					'{{WRAPPER}} .td-home-slider-area .slick-dots button' => 'background-color: {{VALUE}};',
				],
				'condition' => [
					'nav_dots' => 'yes',
				],
			]
		);

		$this->add_control(
			'active_dot_color',
			[
				'label'       => esc_html__('Active Dot Color', 'themedraft-core'),
				'type'        => Controls_Manager::COLOR,
				'selectors'   => [
					'{{WRAPPER}} .td-home-slider-area .slick-dots .slick-active button,
					{{WRAPPER}} .td-home-slider-area .slick-dots button:hover' => 'background-color: {{VALUE}};',
				],
				'condition' => [
					'nav_dots' => 'yes',
				],
			]
		);

		$this->add_control(
			'arrow_bg',
			[
				'label'       => esc_html__('Arrow Background Color', 'themedraft-core'),
				'type'        => Controls_Manager::COLOR,
				'selectors'   => [
					'{{WRAPPER}} .td-home-slider-area .slick-arrow' => 'background-color: {{VALUE}};',
				],
				'condition' => [
					'nav_arrow' => 'yes',
				],
			]
		);

		$this->add_control(
			'arrow_hover_bg',
			[
				'label'       => esc_html__('Arrow Background Hover Color', 'themedraft-core'),
				'type'        => Controls_Manager::COLOR,
				'selectors'   => [
					'{{WRAPPER}} .td-home-slider-area .slick-arrow:hover' => 'background-color: {{VALUE}};',
				],
				'condition' => [
					'nav_arrow' => 'yes',
				],
			]
		);

		$this->end_controls_section();
	}

	//Render In HTML
	protected function render() {
		$settings = $this->get_settings_for_display();
		$sliderId = rand(10, 1000);
		$td_column = $settings['desktop_offset'] .' '. $settings['desktop_column']. ' '. $settings['ipad_pro_offset']. ' '. $settings['ipad_pro_column'];
		if(is_rtl()){
			$slide_dir = 'dir="rtl"';
			$slide_rtl = 'rtl: true,';
			$btn_icon = 'fas fa-arrow-left';
		}else{
			$slide_dir = '';
			$slide_rtl = '';
			$btn_icon = 'fas fa-arrow-right';
		}
		?>
		<div class="td-home-slider-area td-home-slider-two">
			<div <?php echo $slide_dir;?>  id="td-home-slider-<?php echo esc_attr($sliderId);?>" class="td-home-slider-wrapper">

				<?php
				if($settings['slide_items']){
					foreach($settings['slide_items'] as $slider){ ?>

						<div class="td-single-slide-item td-cover-bg" style="background-image: url(<?php echo esc_url($slider['slide_image']['url'])?>)">
							<div class="td-table">
								<div class="td-table-cell">
									<div class="container">
										<div class="row">
											<div class="<?php echo $td_column;?>">
												<div class="td-slider-content-wrapper">
													<div class="td-slider-content">

                                                        <div class="td-slide-subtitle" data-animation="fadeInUp" data-delay=".5s">
															<h5 class="subtitle"><?php echo $slider['subtitle'];?></h5>
                                                        </div>

														<div class="td-slide-title" data-animation="fadeInUp" data-delay="1s">
															<?php echo $slider['slide_title'];?>
														</div>

														<div class="slider-button-wrapper">

															<?php if(!empty($slider['btn1_text'])) :
																$target = $slider['btn1_url']['is_external'] ? ' target="_blank"' : '';
																$nofollow = $slider['btn1_url']['nofollow'] ? ' rel="nofollow"' : '';
																?>
																<a data-animation="fadeInUp"  data-delay="1.5s" href="<?php echo esc_url($slider['btn1_url']['url'])?>" class="td-button" <?php echo  $target . $nofollow?>><?php echo esc_html($slider['btn1_text']) ?><i class="<?php echo $btn_icon;?>"></i></a>
															<?php endif;?>

															<?php if(!empty($slider['btn2_text'])) :
																$target2 = $slider['btn2_url']['is_external'] ? ' target="_blank"' : '';
																$nofollow2 = $slider['btn2_url']['nofollow'] ? ' rel="nofollow"' : '';
																?>
																<a data-animation="fadeInUp"  data-delay="2s" href="<?php echo esc_url($slider['btn2_url']['url'])?>" class="td-button" <?php echo  $target2 . $nofollow2?>><?php echo esc_html($slider['btn2_text']) ?><i class="<?php echo $btn_icon;?>"></i></a>
															<?php endif;?>

														</div>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<?php

					}
				}
				?>
			</div>
		</div>


		<?php if($settings['slide_items'] && count($settings['slide_items']) > 1 ) :?>

			<script>
                (function ($) {
                    "use strict";
                    //Documnet Ready Function
                    $( document ).ready(function() {
                        // slider - active
                        function homeSlider() {
                            var SliderActive = $('#td-home-slider-<?php echo esc_js($sliderId)?>');

                            SliderActive.slick({
                                slidesToShow: 1,
                                autoplay: <?php echo json_encode($settings['autoplay'] == 'yes' ? true : false); ?>,
                                autoplaySpeed: <?php echo json_encode($settings['autoplay_interval'])?>,
                                speed: 1000, // slide speed
                                dots: <?php echo json_encode($settings['nav_dots'] == 'yes' ? true : false); ?>,
                                fade: true,
                                draggable: true,
                                pauseOnHover: false,
	                            <?php echo $slide_rtl;?>
                                arrows: <?php echo json_encode($settings['nav_arrow'] == 'yes' ? true : false); ?>,
                                prevArrow: '<i class="slick-arrow slick-prev fas fa-arrow-left"></i>',
                                nextArrow: '<i class="slick-arrow slick-next fas fa-arrow-right"></i>',
                                responsive: [
                                    {
                                        breakpoint: 992,
                                        settings: {
                                            //768-991
                                            arrows:false
                                        }
                                    },
                                    {
                                        breakpoint: 768,
                                        settings: {
                                            // 0 -767
                                            dots:<?php echo json_encode($settings['nav_dots'] == 'yes' ? true : false); ?>,
                                            arrows:false
                                        }
                                    }
                                ]
                            });

							<?php if($settings['slider_animation'] === 'yes') :?>
                            function doAnimations(elements) {
                                var animationEndEvents = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
                                elements.each(function () {
                                    var $this = $(this);
                                    var $animationDelay = $this.data('delay');
                                    var $animationType = 'animated ' + $this.data('animation');
                                    $this.css({
                                        'animation-delay': $animationDelay,
                                        '-webkit-animation-delay': $animationDelay
                                    });
                                    $this.addClass($animationType).one(animationEndEvents, function () {
                                        $this.removeClass($animationType);
                                    });
                                });
                            }

                            SliderActive.on('init', function (e, slick) {
                                var $firstAnimatingElements = $('.td-single-slide-item:first-child').find('[data-animation]');
                                doAnimations($firstAnimatingElements);
                            });

                            SliderActive.on('beforeChange', function (e, slick, currentSlide, nextSlide) {
                                var $animatingElements = $('.td-single-slide-item[data-slick-index="' + nextSlide + '"]').find('[data-animation]');
                                doAnimations($animatingElements);
                            });
							<?php endif;?>
                        }
                        homeSlider();

                    });
                })(jQuery);
			</script>

		<?php endif; ?>
		<?php
	}
}

Plugin::instance()->widgets_manager->register( new ThemeDraft_Home_Two_Slider_Widget );
