<?php
/****************** content carousel ********************/
class WPBakeryShortCode_Av_Carousel extends WPBakeryShortCodesContainer{
protected function content($atts, $content=NULL){
	$GLOBALS['caritem_count'] = 0;
	extract(shortcode_atts(array(
		'title' => '',
		'type' => 'custom',
		'automatic' => 'false',
		'interval' => '4000',
		'min' => '1',
		'showarrows' => 'true',
		'max' => '6',
        'slwidth'=>'257',
        'slmargin'=>'0',
		'anim'=>'',
		'class'=>''
	), $atts));
	$randomId = mt_rand(0, 100000);
	$panes = array();	
	$anim= isset($anim)  ? "animation $anim" : '';
	$return = '';
	do_shortcode ($content);
        if($type=='brands') { $mc='clients';} else{$mc='';}
	if(isset( $GLOBALS['caritems']) && is_array( $GLOBALS['caritems'] ) ){
		$return.='
		<div class="carshort ">
				<ul class="clients-logo customcar'.$randomId.' '.$mc.'" id="'.$type.'" >';
					foreach( $GLOBALS['caritems'] as $item ){
						$panes[] = '<li>'.$item['content'].'</li>'; 
					}
					unset($GLOBALS['caritems']);
					$return.=implode( "\n", $panes ).'
				</ul>
		</div>
		<script type="text/javascript">
			jQuery(document).ready(function(){
				jQuery(".customcar'.$randomId.'").bxSlider({ 
					slideWidth: '.$slwidth.',
					minSlides: '.$min.',
					maxSlides: '.$max.',
					auto: '.$automatic.',
					pause : '.$interval.',
					slideMargin: '.$slmargin.',
					pager:false,
					controls: '.$showarrows.',
					nextText: "",
					prevText:""
				});
				})
		</script>';
	}
	return $return;
}
}
add_shortcode('av_carousel', 'alc_carousel' );
/***/
class WPBakeryShortCode_Av_Caritem extends WPBakeryShortCode {
    protected function content( $atts, $content = null){
	extract(shortcode_atts(array(
	'title' => '',
	), $atts));
	$x = $GLOBALS['caritem_count'];
	$GLOBALS['caritems'][$x] = array('title' => $title, 'content' =>  do_shortcode ($content) );
	$GLOBALS['caritem_count']++;	
}
}
add_shortcode( 'av_caritem', 'alc_caritem' );

/****/
vc_map( array(
   "name" => __("Unik Content Carousel", "unik"),
	"show_settings_on_create" => true,
	'is_container' => true,
	"content_element" => true,
	"as_parent" => array('only' => 'av_caritem'),
   "base" => "av_carousel",
   "class" => "",
   "icon" => "icon-wpb-my_av_carousel",
   'admin_enqueue_css' => array(get_template_directory_uri().'/vc_templates/shortcodes.css'),
   "category" => __('Content', "unik"),
   "params" => array(
       array(
         "type" => "dropdown",
         "class" => "",
         "heading" => __("Animation", "unik"),
         "param_name" => "anim",
         "value" => array( "None"=>"", "bounce"=>"bounce", "flash"=>"flash", "pulse"=>"pulse", "shake"=>"shake", "swing"=>"swing", "tada"=>"tada", "wobble"=>"wobble", "bounceIn"=>"bounceIn", "bounceInDown"=>"bounceInDown", "bounceInLeft"=>"bounceInLeft", "bounceInRight"=>"bounceInRight", "bounceInUp"=>"bounceInUp", "bounceOut"=>"bounceOut", "bounceOutDown"=>"bounceOutDown", "bounceOutLeft"=>"bounceOutLeft", "bounceOutRight"=>"bounceOutRight", "bounceOutUp"=>"bounceOutUp", "fadeIn"=>"fadeIn", "fadeInDown"=>"fadeInDown", "fadeInDownBig"=>"fadeInDownBig", "fadeInLeft"=>"fadeInLeft", "fadeInLeftBig"=>"fadeInLeftBig", "fadeInRight"=>"fadeInRight", "fadeInRightBig"=>"fadeInRightBig", "fadeInUp"=>"fadeInUp", "fadeInUpBig"=>"fadeInUpBig", "fadeOut"=>"fadeOut", "fadeOutDown"=>"fadeOutDown", "fadeOutDownBig"=>"fadeOutDownBig", "fadeOutLeft"=>"fadeOutLeft", "fadeOutLeftBig"=>"fadeOutLeftBig", "fadeOutRight"=>"fadeOutRight", "fadeOutRightBig"=>"fadeOutRightBig", "fadeOutUp"=>"fadeOutUp", "fadeOutUpBig"=>"fadeOutUpBig", "flip"=>"flip", "flipInX"=>"flipInX", "flipInY"=>"flipInY", "flipOutX"=>"flipOutX", "flipOutY"=>"flipOutY", "lightSpeedIn"=>"lightSpeedIn", "lightSpeedOut"=>"lightSpeedOut", "rotateIn"=>"rotateIn", "rotateInDownLeft"=>"rotateInDownLeft", "rotateInDownRight"=>"rotateInDownRight", "rotateInUpLeft"=>"rotateInUpLeft", "rotateInUpRight"=>"rotateInUpRight", "rotateOut"=>"rotateOut", "rotateOutDownLeft"=>"rotateOutDownLeft", "rotateOutDownRight"=>"rotateOutDownRight", "rotateOutUpLeft"=>"rotateOutUpLeft", "rotateOutUpRight"=>"rotateOutUpRight",  "hinge"=>"hinge", "rollIn"=>"rollIn", "rollOut"=>"rollOut", "zoomIn"=>"zoomIn","zoomInDown"=>"zoomInDown", "zoomInLeft"=>"zoomInLeft","zoomInRight"=>"zoomInRight","zoomInUp"=>"zoomInUp","zoomOut"=>"zoomOut", "zoomOutLeft"=>"zoomOutLeft", "zoomOutRight"=>"zoomOutRight","zoomOutUp"=>"zoomOutUp"),
         "description" => __(" Animation.", "unik")
      ),
	   array(
         "type" => "dropdown",
         "class" => "",
         "heading" => __("Type", "unik"),
         "param_name" => "type",
         "value" => array("Default"=>"", "Brand slider"=>"brands")
      ), 
	   array(
         "type" => "dropdown",
         "class" => "",
         "heading" => __("Autoplay", "unik"),
         "param_name" => "automatic",
         "value" => array("No"=>"false", "Yes"=>"true")
      ),
	    array(
         "type" => "textfield",
         "class" => "",
         "heading" => __("Autoplay speed(milliseconds)", "unik"),
         "param_name" => "interval",
         "value" => '4000'
      ),
	   array(
         "type" => "dropdown",
         "class" => "",
         "heading" => __("Show Navigation Arrows", "unik"),
         "param_name" => "showarrows",
         "value" => array("Yes"=>"true", "No"=>"false")
      ),
	   array(
         "type" => "textfield",
         "class" => "",
         "heading" => __("Min. visible Items", "unik"),
         "param_name" => "min",
         "value" => '1'
      ),
	   array(
         "type" => "textfield",
         "class" => "",
         "heading" => __("Max. visible Items", "unik"),
         "param_name" => "max",
         "value" => '6'
      ),
	   array(
         "type" => "textfield",
         "class" => "",
         "heading" => __("Slide width", "unik"),
         "param_name" => "slwidth",
         "value" => '257'
      ),
	  
	    array(
         "type" => "textfield",
         "class" => "",
         "heading" => __("Slide margin", "unik"),
         "param_name" => "slmargin",
         "value" => ''
      ),
      array(
         "type" => "textfield",
         "class" => "",
         "heading" => __("Extra class", "unik"),
         "param_name" => "class",
         "description" => __(' Extra class name', "unik")
      ),
   ),
	"js_view" => 'VcColumnView'
) );
/**********************************************************/
vc_map( array(
	'name' => __( 'Carousel Item', 'unik' ),
	'base' => 'av_caritem',
	"icon" => "icon-wpb-ui-accordion",
	"as_child" => array('only' => 'av_carousel'),
	'content_element' => true,
	'params' => array(
		array(
		 "type" => "textarea_html",
		  "holder"=>"div",	
		  "class" => "",
		  "heading" => __("Content", "unik"),
		  "param_name" => "content"
		 ),		
		)
	))
?>
