<?php



use Elementor\Widget_Base;
use Elementor\Controls_Manager;

if (!defined('ABSPATH')) exit; // Exit if accessed directly


class Sliderninethkaveh extends Widget_Base{

  public function get_name(){
    return 'sliderninethkaveh';
  }

  public function get_title(){
    return esc_html__( 'Slider Style Nine', 'kavehTheme' );
  }

  public function get_icon(){
    return 'eicon-archive-posts';
  }

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

  protected function register_controls(){
    
    $this->start_controls_section(
        'contentsliderninethkaveh',
        [
          'label' => esc_html__( 'Content', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $repeater = new \Elementor\Repeater();

      $repeater->add_control(
        'backsliderninethkaveh',
        [
          'label' => esc_html__( 'Select Your Image', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::MEDIA,
          'default' => [
            'url' => \Elementor\Utils::get_placeholder_image_src(),
          ],
        ]
      );
      $repeater->add_control(
        'linksliderninethkaveh',
        [
            'label' => esc_html__( 'Slide Link', 'kavehTheme' ),
            'type' => \Elementor\Controls_Manager::TEXT,
            'default' => esc_html__( '#', 'kavehTheme' ),
    
        ]
    );
    $repeater->add_control(
      'shape1color1sliderninethkaveh',
      [
        'label' => esc_html__( 'First Shape Color', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::COLOR,
      ]
    );
    $repeater->add_control(
      'shape2color1sliderninethkaveh',
      [
        'label' => esc_html__( 'Second Shape Color', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::COLOR,
      ]
    );
      $this->add_control(
        'slidessliderninethkaveh',
        [
          'label' => esc_html__( 'Slides', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::REPEATER,
          'fields' => $repeater->get_controls(),
          ],
      );
      $this->add_control(
        'arrowssliderninethkaveh',
        [
          'label' => esc_html__( 'Show Arrows?', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SWITCHER,
          'yes' => esc_html__( 'Yes', 'kavehTheme' ),
          'no' => esc_html__( 'No', 'kavehTheme' ),
          'return_value' => 'yes',
          'default' => 'yes',
        ]
      );
      $this->add_control(
        'bulletssliderninethkaveh',
        [
          'label' => esc_html__( 'Show Dots?', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SWITCHER,
          'yes' => esc_html__( 'Yes', 'kavehTheme' ),
          'no' => esc_html__( 'No', 'kavehTheme' ),
          'return_value' => 'yes',
          'default' => 'yes',
        ]
      );
      $this->end_controls_section();

      $this->start_controls_section(
        'style1_sliderninethkaveh',
        [
          'label' => esc_html__( 'Slider Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'heightbgsliderninethkaveh',
        [
          'label' => esc_html__( 'Slider Height', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 100,
              'max' => 2000,
              'step' => 5,
            ],
          ],
          'default' => [
            'unit' => 'px',
            'size' => 452,
          ],
          'selectors' => [
            '{{WRAPPER}} .slider-home-three-item img' => 'max-height: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'dotno1sliderninethkaveh',
        [
          'label' => esc_html__( 'Inactive Dot Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .slider-home-three-wrapper .swiper-pagination-bullet' => 'background-color: {{VALUE}}',
          ],
        ]
      );
      $this->add_control(
        'doty1sliderninethkaveh',
        [
          'label' => esc_html__( 'Active Dot Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .slider-home-three-wrapper .swiper-pagination-bullet-active' => 'background-color: {{VALUE}}',
          ],
        ]
      );
       $this->end_controls_section();

          
        }


  protected function render(){
    $settings = $this->get_settings_for_display();
    $clsid = $this->get_id();
    ?>
        <section class="slider-home-three">
      <div class="container">
        <div class="slider-home-three-wrapper position-relative">
          <div class="swiper swiper-home-three swiper-button-fill" data-swiper='{"slidesPerView":1,"spaceBetween":0,"pagination":{"el":".swiper-pagination","type":"bullets","clickable":true},"autoplay":{"delay":5000},"effect":"fade","fadeEffect":{"crossFade":true},"loop":true,"navigation":{"nextEl":".swiper-button-next","prevEl":".swiper-button-prev"}}'>
            <div class="swiper-wrapper">
            <?php
              if ( $settings['slidessliderninethkaveh'] ) {
              foreach (  $settings['slidessliderninethkaveh'] as $item ) {
              ?>
              <!-- Start Slide -->
              <div class="swiper-slide">
                <div class="slider-home-three-item position-relative">
                  <span class="shape-1 position-absolute" style="background-color: <?php echo  esc_attr($item['shape1color1sliderninethkaveh']); ?>;"></span>
                  <span class="shape-2 position-absolute" style="background-color: <?php echo  esc_attr($item['shape2color1sliderninethkaveh']); ?>;"></span>
                  <a href="<?php echo  esc_url($item['linksliderninethkaveh']); ?>">
                  <img src="<?php echo esc_url($item['backsliderninethkaveh']['url']); ?>" alt="<?php echo esc_attr(\Elementor\Control_Media::get_image_alt( $item['backsliderninethkaveh'] )); ?>" width="855" height="410"
                    class="w-100 d-block">
                    </a>
                </div>
              </div>
              <!-- End Slide -->
              <?php
                }
              }
                ?>
            </div>
            
            <?php if("yes"===$settings['bulletssliderninethkaveh']){?>
            <div class="swiper-pagination bottom-0"></div>
            <?php
            }
             if("yes"===$settings['arrowssliderninethkaveh']){?>
            <div class="swiper-button-next"></div>
            <div class="swiper-button-prev"></div>
            <?php } ?>
          </div>
        </div>
      </div>
    </section>
    
    <?php
  }


}
