<?php
$total_pages = $this->_total_items / $this->_shortcode_attributes['items_per_slide'];
if ($total_pages>1){
  $navigation = (empty($this->_shortcode_attributes['nav_button'])) ? 'false' : 'true';
  $bullets = (empty($this->_shortcode_attributes['bullets'])) ? 'false' : 'true';
  if (empty($this->_shortcode_attributes['autoplay'])){
    $autoplay = 'false';
    $autoplayTimeout = 5000;
  } else {
    $autoplay = 'true';
    $autoplayTimeout = $this->_shortcode_attributes['speed'];
  }
  $autoheight = (empty($this->_shortcode_attributes['autoheight'])) ? 'false' : 'true';
  $stop_hover = (empty($this->_shortcode_attributes['stop_hover'])) ? 'false' : 'true';
  $loop = (empty($this->_shortcode_attributes['loop'])) ? 'false' : 'true';
  $responsive = (empty($this->_shortcode_attributes['responsive'])) ? 'false' : 'true';
  $lazy_load = (empty($this->_shortcode_attributes['lazy_load'])) ? 'false' : 'true';
  $animation_in = (($this->_shortcode_attributes['animation_in'])=='none') ? 'false' : "'{$this->_shortcode_attributes['animation_in']}'";
  $animation_out = (($this->_shortcode_attributes['animation_out'])=='none') ? 'false' : "'{$this->_shortcode_attributes['animation_out']}'";
  $slide_pagination_speed = $this->_shortcode_attributes['pagination_speed'];
  $str .= "<script>
                jQuery(document).ready(function() {
                  var owl = jQuery('#" . $this->_div_parent_id . "');
                  owl.owlUlpCarousel({
                      items : 1,
                      mouseDrag: true,
                      touchDrag: true,
                      autoHeight: $autoheight,
                      animateOut: $animation_out,
                      animateIn: $animation_in,
                      lazyLoad : $lazy_load,
                      loop: $loop,
                      autoplay : $autoplay,
                      autoplayTimeout: $autoplayTimeout,
                      autoplayHoverPause: $stop_hover,
                      autoplaySpeed: $slide_pagination_speed,
                      nav : $navigation,
                      navSpeed : $slide_pagination_speed,
                      navText: [ '', '' ],
                      dots: $bullets,
                      dotsSpeed : $slide_pagination_speed,
                      responsiveClass: $responsive,
                      responsive:{
                        0:{
                          nav:false
                        },
                        450:{
                          nav : $navigation
                        }
                      }
                  });
                });
  </script>";
}
