<?php
class WPBakeryShortCode_Av_Tabs extends WPBakeryShortCodesContainer{
protected function content($atts, $content=NULL){
    extract(shortcode_atts(array(
        'position'=>'',
        'anim'=>'',
        'class'=>'',
        ), $atts));
	$GLOBALS['tab_count'] = 0;	
	do_shortcode( $content );
    $rtl =  weblusive_get_option('rtl_mode');
	$anim = empty($anim) ? '' : "animation $anim";
	$randomId = mt_rand(0, 100000);
	$counter = 0;
	$tabs = array();
	$return = '<div class="'.$position.' '.$anim.' '.$class.'">';
		if( is_array( $GLOBALS['tabs'] ) ){
			foreach( $GLOBALS['tabs'] as $tab ){
				$active = ($counter == 0) ? ' class="active"' : '';
                $activeContent = ($counter == 0) ? 'active' : '';
				if($rtl){
					$tabs[] = '<li'.$active.'><a href="#tabs-'.$randomId.'" data-toggle="tab">'.$tab['title'].'<i class="fa '.$tab['icon'].'"></i></a></li>'; 
				}
				else{
					$tabs[] = '<li'.$active.'><a href="#tabs-'.$randomId.'" data-toggle="tab"><i class="fa '.$tab['icon'].'"></i>'.$tab['title'].'</a></li>';                
				}
				$tabcontent[] = '<div id="tabs-'.$randomId.'" class="tab-pane  '.$activeContent.'">'.do_shortcode($tab['content']).'</div>';	
				
				$randomId++;
				$counter ++;
			}
			if($rtl){
				$return.= '<div class="tab-content">'.implode( "\n", $tabcontent ).'</div>';
				$return.= '<ul class="nav nav-tabs ">'.implode( "\n", $tabs ).'</ul>';
			}
			else{
				$return.= '<ul class="nav nav-tabs ">'.implode( "\n", $tabs ).'</ul>';
				$return.= '<div class="tab-content">'.implode( "\n", $tabcontent ).'</div>';
			}
			unset($GLOBALS['tabs']);
		}
	$return.='</div><div class="clearfix"></div>';
	return $return;
}
}
add_shortcode('av_tabs', 'alc_tabs');
/*******************************************/
class WPBakeryShortCode_Av_Tab_Item extends WPBakeryShortCode {
    protected function content( $atts, $content = null){
	extract(shortcode_atts(array(
	'title' => 'Tab %d',
         'icon'=>''     
	), $atts));
	
	$x = $GLOBALS['tab_count'];
	$GLOBALS['tabs'][$x] = array( 'title' => sprintf( $title, $GLOBALS['tab_count'] ), 'content' =>  $content, 'icon'=>$icon );
	
	$GLOBALS['tab_count']++;
	}
}
add_shortcode('av_tab_item', 'alc_tab_item');
/**********************************************************/
vc_map( array(
	"name" => __("Unik Tabs", "unik"),
	"show_settings_on_create" => true,
	'is_container' => true,
	"content_element" => true,
	"as_parent" => array('only' => 'av_tab_item'),
	"base" => "av_tabs",
	"class" => "",
	"icon" => "icon-wpb-my_tabs",
	'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" => __("Position", "unik"),
         "param_name" => "position",
         "value"=>array("Horizontal"=>"horizontal-tabs-box", "Vertical"=>"vertical-tabs-box")
      ),
	   
        array(
         "type" => "textfield",
         "class" => "",
         "heading" => __("Extra class", "unik"),
         "param_name" => "class"
      ),
   ),
	"js_view" => 'VcColumnView'
) );
/**********************************************************/
vc_map( array(
	'name' => __( 'Tab Item', 'unik' ),
	'base' => 'av_tab_item',
	"icon" => "icon-wpb-ui-accordion",
	"as_child" => array('only' => 'av_tabs'),
	'content_element' => true,
	'params' => array(
		array(
		 "type" => "textfield",
		"holder"=>"div",
		  "class" => "",
		  "heading" => __("Title", "unik"),
		  "param_name" => "title"
		 ),
		array(
		 "type" => "textfield",
		  "class" => "",
		  "heading" => __("Icon", "unik"),
		  "param_name" => "icon",
		  "description" => __(' <small>Choose your icon from <a href="http://fortawesome.github.io/Font-Awesome/icons/" target="blank">this list</a>.</small>', "unik")
		 ),
		array(
		  "type" => "textarea_html",
		  "class" => "",
		  "heading" => __("Tab Content", "unik"),
		  "param_name" => "content"
		 ),
		)
	))
?>