<?php if(! defined('ABSPATH')){ return; }
/*
 Name: Call Out Banner
 Description: Create and display a Call Out Banner element
 Class: TH_CallOutBanner
 Category: content
 Level: 3
*/
/**
 * Class TH_CallOutBanner
 *
 * Create and display a Call Out Banner element
 *
 * @package  Kallyas
 * @category Page Builder
 * @author   Team Hogash
 * @since    3.8.0
 */
class TH_CallOutBanner extends ZnElements
{
	public static function getName(){
		return __( "Call Out Banner", 'zn_framework' );
	}

	/**
	 * This method is used to display the output of the element.
	 * @return void
	 */
	function element()
	{
		$options = $this->data['options'];

		if( empty( $options ) ) { return; }

		$button   = false;
		$div_size = 'col-sm-12';

		if ( ! empty ( $options['cab_button_text'] ) ) {
			$button   = true;
			$div_size = 'col-sm-10';
		}

		echo '<div class="callout-banner clearfix '.$this->data['uid'].'">';
			echo '<div class="row">';

			if ( ! empty ( $options['cab_main_title'] ) || ! empty ( $options['cab_sec_title'] ) ) {

				echo '<div class="' . $div_size . '">';

				if ( ! empty ( $options['cab_main_title'] ) ) {
					echo '<h3 class="m_title">' . $options['cab_main_title'] . '</h3>';
				}

				if ( ! empty ( $options['cab_sec_title'] ) ) {
					echo '<p>' . $options['cab_sec_title'] . '</p>';
				}

				echo '</div>';
			}

			if ( $button ) {

				echo '<div class="col-sm-2">';
					echo '<a href="' . $options['cab_button_link']['url'] . '"
							class="circlehover with-symbol '.$this->opt( 'calloutbox_style', 'style1' ).'"
							data-size=""
							data-position="top-left"
							data-align="right"
							target="' . $options['cab_button_link']['target'] . '">';
						echo '<span class="text">' . $options['cab_button_text'] . '</span>';
						if ( ! empty ( $options['cab_button_image'] ) ) {
							echo '<span class="symbol"><img src="' . $options['cab_button_image'] . '" alt=""></span>';
						}
						else {
							echo '<span class="symbol"><img src="' . THEME_BASE_URI . '/images/ok.png" alt=""></span>';
						}
						echo '<div class="triangle"><span class="play-icon"></span></div>';
					echo '</a>';
				echo '</div>';
			}
			echo '</div>';
		echo '</div>';
	}

	/**
	 * This method is used to retrieve the configurable options of the element.
	 * @return array The list of options that compose the element and then passed as the argument for the render() function
	 */
	function options()
	{
		return array (
			'has_tabs'  => true,
			'general' => array(
				'title' => 'General options',
				'options' => array(
					array (
						"name"        => __( "Style", 'zn_framework' ),
						"description" => __( "Please select the style you want to use.", 'zn_framework' ),
						"id"          => "calloutbox_style",
						"std"         => "style1",
						"options"     => array (
							'style1'     => __( 'Style 1', 'zn_framework' ),
							'style2'    => __( 'Style 2 (since v4.0)', 'zn_framework' ),
							'style3'    => __( 'Style 3 (since v4.0)', 'zn_framework' )
						),
						"type"        => "select",
						'live'        => array(
							'type'      => 'class',
							'css_class' => '.'.$this->data['uid'] .' .circlehover'
						),
					),
					array (
						"name"        => __( "Main Title", 'zn_framework' ),
						"description" => __( "Enter a title for your Call Out Banner element", 'zn_framework' ),
						"id"          => "cab_main_title",
						"std"         => "",
						"type"        => "textarea",
					),
					array (
						"name"        => __( "Secondary Title", 'zn_framework' ),
						"description" => __( "Enter a secondary title for your Call Out Banner element", 'zn_framework' ),
						"id"          => "cab_sec_title",
						"std"         => "",
						"type"        => "textarea",
					),
				),
			),
			'button' => array(
				'title' => 'Button options',
				'options' => array(
					array (
						"name"        => __( "Button Text", 'zn_framework' ),
						"description" => __( "Please enter a text that will appear on the right button.", 'zn_framework' ),
						"id"          => "cab_button_text",
						"std"         => "",
						"type"        => "text",
					),
					array (
						"name"        => __( "Button Hover Image", 'zn_framework' ),
						"description" => __( "Please select an image that will appear when
											hovering the mouse over the button. If no image is chosen , the default OK image will be used", 'zn_framework' ),
						"id"          => "cab_button_image",
						"std"         => "",
						"type"        => "media",
					),
					array (
						"name"        => __( "Button link", 'zn_framework' ),
						"description" => __( "Please choose the link you want to use for your button.", 'zn_framework' ),
						"id"          => "cab_button_link",
						"std"         => "",
						"type"        => "link",
						"options"     => array (
							'_blank' => __( "New window", 'zn_framework' ),
							'_self'  => __( "Same window", 'zn_framework' )
						)
					),
				),
			),
		);
	}
}
