<?php

class DDBUILDER_Content_Toggle_Module extends ET_Builder_Module {

	public $slug      	= 'dondivi_content_toggle';
	public $vb_support 	= 'on';
	public $icon_path;

	protected $module_credits = array(
		'module_uri' => 'https://dondivi.com/content-toggle',
		'author'     => 'DonDivi',
		'author_uri' => 'https://dondivi.com/',
	);

	public function init() {
		$this->name 		= esc_html__( 'DonDivi Content Toggle', 'dd_builder' );
		$this->icon_path   	= plugin_dir_path( DDB_PLUGIN_PATH ) . 'builder/icon.svg';

		$this->main_css_element	= '%%order_class%%';
		
		$this->settings_modal_toggles = array(
			'general'    => array(
				'toggles' => array(
					'content1'      => esc_html__( 'Content One', 'dd_builder' ),
                    'content2'      => esc_html__( 'Content Two', 'dd_builder' ),
				),
			),
            'advanced'    => array(
				'toggles' => array(
					'main_content'  	=> esc_html__( 'Switcher', 'et_builder' ),
					'labels' => array(
						'sub_toggles'       => array(
							'label1' => array(
								'name' => esc_html__( 'Label One', 'dd_builder' ),
							),
							'label2' => array(
								'name' => esc_html__( 'Label Two', 'dd_builder' ),
							),
						),
						'tabbed_subtoggles' => true,
						'title'             =>  esc_html__( 'Labels', 'et_builder' ),
					),
					'content1'      	=> esc_html__( 'Content One', 'dd_builder' ),    
					'content1_icon' 	=> sprintf( '%1$s %2$s', esc_html__( 'Content One', 'dd_builder' ), esc_html__( 'Image & Icon', 'et_builder' ) ),      
					'content1_title' 	=> sprintf( '%1$s %2$s', esc_html__( 'Content One', 'dd_builder' ), et_builder_i18n( 'Title' ) ),
					'content1_body' 	=> array(
						'title'             => sprintf( '%1$s %2$s', esc_html__( 'Content One', 'dd_builder' ), et_builder_i18n( 'Body' ) ),
						'tabbed_subtoggles' => true,
						'bb_icons_support'  => true,
						'sub_toggles'       => array(
							'p'     => array(
								'name' => 'P',
								'icon' => 'text-left',
							),
							'a'     => array(
								'name' => 'A',
								'icon' => 'text-link',
							),
							'ul'    => array(
								'name' => 'UL',
								'icon' => 'list',
							),
							'ol'    => array(
								'name' => 'OL',
								'icon' => 'numbered-list',
							),
							'quote' => array(
								'name' => 'QUOTE',
								'icon' => 'text-quote',
							),
						),
					),
					'content1_button' 	=> sprintf( '%1$s %2$s', esc_html__( 'Content One', 'dd_builder' ), et_builder_i18n( 'Button' ) ),
					'content1_effects'  => sprintf( '%1$s %2$s', esc_html__( 'Content One', 'dd_builder' ), esc_html__( 'Animation', 'et_builder' ) ),	
					'content2'      	=> esc_html__( 'Content Two', 'dd_builder' ),								  
					'content2_icon' 	=> sprintf( '%1$s %2$s', esc_html__( 'Content Two', 'dd_builder' ), esc_html__( 'Image & Icon', 'et_builder' ) ),
					'content2_title' 	=> sprintf( '%1$s %2$s', esc_html__( 'Content Two', 'dd_builder' ), et_builder_i18n( 'Title' ) ),
					'content2_body' 	=> array(
						'title'             => sprintf( '%1$s %2$s', esc_html__( 'Content Two', 'dd_builder' ), et_builder_i18n( 'Body' ) ),
						'tabbed_subtoggles' => true,
						'bb_icons_support'  => true,
						'sub_toggles'       => array(
							'p'     => array(
								'name' => 'P',
								'icon' => 'text-left',
							),
							'a'     => array(
								'name' => 'A',
								'icon' => 'text-link',
							),
							'ul'    => array(
								'name' => 'UL',
								'icon' => 'list',
							),
							'ol'    => array(
								'name' => 'OL',
								'icon' => 'numbered-list',
							),
							'quote' => array(
								'name' => 'QUOTE',
								'icon' => 'text-quote',
							),
						),
					),				
					'content2_button' 	=> sprintf( '%1$s %2$s', esc_html__( 'Content Two', 'dd_builder' ), et_builder_i18n( 'Button' ) ),
					'content2_effects'  => sprintf( '%1$s %2$s', esc_html__( 'Content Two', 'dd_builder' ), esc_html__( 'Animation', 'et_builder' ) ),
				),
			),
		);

		$this->advanced_fields = array(
			'borders' => array(
				'default' => array(),
				'content1' => array(
					'label_prefix' => esc_html__( 'Content One', 'dd_builder' ),
					'css'      => array(
						'main' => array(
							'border_radii'  => '%%order_class%% .ddb-content-one > div',
							'border_styles' => '%%order_class%% .ddb-content-one > div',
						),
					),
					'depends_on'    	=> array( 'item_content1' ),
					'depends_show_if' 	=> 'custom', 
					'toggle_slug' 		=> 'content1',
				),
				'content2' => array (
					'label_prefix'    => esc_html__( 'Content Two', 'dd_builder' ),
					'css' => array(
						'main' => array(
							'border_radii' =>  "{$this->main_css_element} .ddb-content-two > div",
							'border_styles' => "{$this->main_css_element} .ddb-content-two > div",
						),													
					),	
					'depends_on'    	=> array( 'item_content2' ),
					'depends_show_if' 	=> 'custom',
					'toggle_slug' 		=> 'content2',				
				),
			),
			'button'         => array(
				'c1_button' => array(
					'label'          => et_builder_i18n( 'Button' ),
					'css'            => array(
						'main'         => "{$this->main_css_element} .ddb-content-one .ddb-c1-button",
						'alignment'    => "{$this->main_css_element} .ddb-content-one .et_pb_button_module_wrapper", 
					),	
					'use_alignment'  	=> true,
					'box_shadow'     => array(
						'css' => array(
							'main' => '%%order_class%%_popup .ddb-c1-button',
						),
					),
					'margin_padding' => array(
						'css' => array(
							'important' => 'all',
						),
					),
					'toggle_slug' 		=> 'content1_button', 
				),
				'c2_button' => array(
					'label'          => et_builder_i18n( 'Button' ),
					'css'            => array(
						'main'         => "{$this->main_css_element} .ddb-content-two .ddb-c2-button",
						'alignment'    => "{$this->main_css_element} .ddb-content-two .et_pb_button_module_wrapper",
					),
					'use_alignment'  => true,
					'box_shadow'     => array(
						'css' => array(
							'main' => '%%order_class%%_popup .ddb-c2-button',
						),
					),
					'margin_padding' => array(
						'css' => array(
							'important' => 'all',
						),
					),
					'toggle_slug' 		=> 'content2_button', 
				),
			),
			'fonts'          => array(
				'c1_label' => array(
					'label'        => esc_html__( 'Label', 'et_builder' ),
					'css'          => array(
						'main'  => "{$this->main_css_element} .ddb-label-one",
						'hover'  => "{$this->main_css_element} .ddb-label-one:hover, {$this->main_css_element} .ddb-content-toggle:not(.checked) .ddb-label-one",
					),
					'header_level' => array(
						'default' => 'h4',
					),
					'tab_slug'    	=> 'advanced',
					'toggle_slug'  	=> 'labels',
					'sub_toggle'	=> 'label1',
				),
				'c2_label' => array(
					'label'        => esc_html__( 'Label', 'et_builder' ),
					'css'          => array(
						'main'  => "{$this->main_css_element} .ddb-label-two",
						'hover' => "{$this->main_css_element} .ddb-label-two:hover, {$this->main_css_element} .ddb-content-toggle.checked .ddb-label-two",
					),
					'header_level' => array(
						'default' => 'h4',
					),
					'tab_slug'     	=> 'advanced',
					'toggle_slug'  	=> 'labels',
					'sub_toggle'	=> 'label2',
				),
				'c1_title' => array(
					'label'        	=> et_builder_i18n( 'Title' ),
					'css'          	=> array(
						'main'  => "{$this->main_css_element} .ddb-content-one .ddb-c1-title",
					),
					'header_level' => array(
						'default' => 'h4',
					),
					'text_shadow' 	=> array( 'show_if' => array( 'item_content1' => 'custom' ) ),
					'toggle_slug'  	=> 'content1_title',
				),
				'c2_title' => array(
					'label'        	=> et_builder_i18n( 'Title' ),
					'css'          	=> array(
						'main'  => "{$this->main_css_element} .ddb-content-two .ddb-c2-title",
					),
					'header_level' => array(
						'default' => 'h4',
					),
					'text_shadow' 	=> array( 'show_if' => array( 'item_content2' => 'custom' ) ),
					'toggle_slug'  	=> 'content2_title',
				),
				'c1_body'   => array(
					'label'         => et_builder_i18n( 'Body' ),
					'css'           => array(
						'main' 	=> "{$this->main_css_element} .ddb-content-one .ddb-c1-body",
					),
					'font_size'     => array(
						'default' => absint( et_get_option( 'body_font_size', '14' ) ) . 'px',
					),
					'line_height' 	=> array(
						'default' => floatval( et_get_option( 'body_font_height', '1.7' ) ) . 'em',
					),
					'text_shadow' 	=> array( 'show_if' => array( 'item_content1' => 'custom' ) ),
					'toggle_slug' 	=> 'content1_body',
					'sub_toggle' 	=> 'p', 
				),
				'c1_body_link'     	=> array(
					'label'       	=> et_builder_i18n( 'Link' ),
					'css'         	=> array(
						'main'  => "{$this->main_css_element} .ddb-content-one .ddb-c1-body a",
					),
					'text_shadow' 	=> array( 'show_if' => array( 'item_content1' => 'custom' ) ),
					'toggle_slug' 	=> 'content1_body',
					'sub_toggle'  	=> 'a',
				),
				'c1_body_ul'       	=> array(
					'label'       	=> esc_html__( 'Unordered List', 'et_builder' ),
					'css'         	=> array(
						'main'        => "{$this->main_css_element} .ddb-content-one .ddb-c1-body ul li",
						'item_indent' => "{$this->main_css_element} .ddb-content-one .ddb-c1-body ul",
					),
					'text_shadow' 	=> array( 'show_if' => array( 'item_content1' => 'custom' ) ),
					'toggle_slug' 	=> 'content1_body',
					'sub_toggle'  	=> 'ul',
				),
				'c1_body_ol'       	=> array(
					'label'       	=> esc_html__( 'Ordered List', 'et_builder' ),
					'css'         	=> array(
						'main'        => "{$this->main_css_element} .ddb-content-one .ddb-c1-body ol li",
						'item_indent' => "{$this->main_css_element} .ddb-content-one .ddb-c1-body ol",
					),
					'text_shadow' 	=> array( 'show_if' => array( 'item_content1' => 'custom' ) ),
					'toggle_slug' 	=> 'content1_body',
					'sub_toggle'  	=> 'ol',
				),
				'c1_body_quote'  	=> array(
					'label'       	=> esc_html__( 'Blockquote', 'et_builder' ),
					'css'         	=> array(
						'main'  => "{$this->main_css_element} .ddb-content-one .ddb-c1-body blockquote",
					),
					'text_shadow' 	=> array( 'show_if' => array( 'item_content1' => 'custom' ) ),
					'toggle_slug' 	=> 'content1_body',
					'sub_toggle'  	=> 'quote',
				),
				'c2_body'   => array(
					'label'         => et_builder_i18n( 'Body' ),
					'css'           => array(
						'main' => "{$this->main_css_element} .ddb-content-two .ddb-c2-body",
					),
					'font_size'      => array(
						'default' => absint( et_get_option( 'body_font_size', '14' ) ) . 'px',
					),
					'line_height' => array(
						'default' => floatval( et_get_option( 'body_font_height', '1.7' ) ) . 'em',
					),
					'text_shadow' 	=> array( 'show_if' => array( 'item_content2' => 'custom' ) ),
					'toggle_slug' 	=> 'content2_body',
					'sub_toggle' 	=> 'p', 
				),
				'c2_body_link'     	=> array(
					'label'       	=> et_builder_i18n( 'Link' ),
					'css'         	=> array(
						'main'  => "{$this->main_css_element} .ddb-content-two .ddb-c2-body a",
					),
					'text_shadow' 	=> array( 'show_if' => array( 'item_content2' => 'custom' ) ),
					'toggle_slug' 	=> 'content2_body',
					'sub_toggle'  	=> 'a',
				),
				'c2_body_ul'       	=> array(
					'label'       	=> esc_html__( 'Unordered List', 'et_builder' ),
					'css'         	=> array(
						'main'        => "{$this->main_css_element} .ddb-content-two .ddb-c2-body ul li",
						'item_indent' => "{$this->main_css_element} .ddb-content-two .ddb-c2-body ul",
					),
					'text_shadow' 	=> array( 'show_if' => array( 'item_content2' => 'custom' ) ),
					'toggle_slug' 	=> 'content2_body',
					'sub_toggle'  	=> 'ul',
				),
				'c2_body_ol'       	=> array(
					'label'       	=> esc_html__( 'Ordered List', 'et_builder' ),
					'css'         	=> array(
						'main'        => "{$this->main_css_element} .ddb-content-two .ddb-c2-body ol li",
						'item_indent' => "{$this->main_css_element} .ddb-content-two .ddb-c2-body ol",
					),
					'text_shadow' => array( 'show_if' => array( 'item_content2' => 'custom' ) ),
					'toggle_slug' => 'content2_body',
					'sub_toggle'  => 'ol',
				),
				'c2_body_quote'    => array(
					'label'       	=> esc_html__( 'Blockquote', 'et_builder' ),
					'css'         	=> array(
						'main'  => "{$this->main_css_element} .ddb-content-two .ddb-c2-body blockquote",
					),
					'text_shadow' 	=> array( 'show_if' => array( 'item_content2' => 'custom' ) ),
					'toggle_slug' 	=> 'content2_body',
					'sub_toggle'  	=> 'quote',
				),
			),
			'image_icon'     => array(
				'image_icon' => array(
					'label'           	=> esc_html__( 'Image/Icon', 'et_builder' ),
					'css'             	=> array(
						'main'    => '%%order_class%% .ddb-content-one .ddb-c1-image-icon',
					),
					'toggle_slug'     	=> 'content1_icon',
				),
				'image_icon_2' => array(
					'label'           	=> esc_html__( 'Image/Icon', 'et_builder' ),
					'css'             	=> array(
						'main'    => '%%order_class%% .ddb-content-two .ddb-c2-image-icon',
					),
					'toggle_slug'     	=> 'content2_icon',
				),
				'content_1' => array(
					'label'           	=> esc_html__( 'Content One', 'dd_builder' ),
					'css'             	=> array(
						'main'    => '%%order_class%% .ddb-content-one > div',
					),
					'toggle_slug'  	=> 'content1',
				),
				'content_2' => array(
					'label'           	=> esc_html__( 'Content Two', 'dd_builder' ),
					'css'             	=> array(
						'main'    => '%%order_class%% .ddb-content-two > div',
					),
					'toggle_slug'  	=> 'content2',
				),
			),
			'link_options' => false,
		);

		$this->custom_css_fields = array(
			'content1_css' => array(
				'label'    => esc_html__( 'Content One', 'dd_builder' ),
				'selector' => '%%order_class%% .ddb-content-one > div',
			),
			'c1_icon_css' => array(
				'label'    	=> sprintf( '%1$s %2$s', esc_html__( 'Content One', 'dd_builder' ), et_builder_i18n( 'Image/Icon' ) ),
				'selector' 	=> '%%order_class%% .ddb-content-one .ddb-c1-image-icon',
				'show_if'  	=> array( 'item_content1' => 'custom', 'c1_cc_icon_image' => array( 'image', 'icon' ) ),
			),
			'c1_title_css' => array(
				'label'    	=> sprintf( '%1$s %2$s', esc_html__( 'Content One', 'dd_builder' ), et_builder_i18n( 'Title' ) ),
				'selector' 	=> '%%order_class%% .ddb-content-one .ddb-c1-title',
				'show_if' 	=> array('item_content1' => 'custom'),
			),
			'c1_body_css' => array(
				'label'    	=> sprintf( '%1$s %2$s', esc_html__( 'Content One', 'dd_builder' ), et_builder_i18n( 'Body' ) ),
				'selector' 	=> '%%order_class%% .ddb-content-one .ddb-c1-body',
				'show_if' 	=> array('item_content1' => 'custom'),
			),
			'content2_css' => array(
				'label'    => esc_html__( 'Content Two', 'dd_builder' ),
				'selector' => '%%order_class%% .ddb-content-two > div',
			),
			'c2_icon_css' => array(
				'label'    	=> sprintf( '%1$s %2$s', esc_html__( 'Content Two', 'dd_builder' ), et_builder_i18n( 'Image/Icon' ) ),
				'selector' 	=> '%%order_class%% .ddb-content-two .ddb-c2-image-icon',
				'show_if'  	=> array( 'item_content2' => 'custom', 'c2_cc_icon_image' => array( 'image', 'icon' ) ),
			),
			'c2_title_css' => array(
				'label'    	=> sprintf( '%1$s %2$s', esc_html__( 'Content Two', 'dd_builder' ), et_builder_i18n( 'Title' ) ),
				'selector' 	=> '%%order_class%% .ddb-content-two .ddb-c2-title',
				'show_if' 	=> array('item_content2' => 'custom'),
			),
			'c2_body_css' => array(
				'label'    	=> sprintf( '%1$s %2$s', esc_html__( 'Content Two', 'dd_builder' ), et_builder_i18n( 'Body' ) ),
				'selector' 	=> '%%order_class%% .ddb-content-two .ddb-c2-body',
				'show_if' 	=> array('item_content2' => 'custom'),
			),
		);
	}

	public function get_fields() { 
		$helper = new DonDiviBuilderFields();         
        $fields = array(
            'label1' => array(
                'label'       		=> esc_html__( 'Label', 'et_builder' ),
                'type'        		=> 'text',				
                'hover'				=> 'tabs',
                'toggle_slug' 		=> 'content1',
                'dynamic_content' 	=> 'text',	
            ),
			'item_content1' 	=> array(
				'label'        	=> et_builder_i18n( 'Content' ),
				'type'         	=> 'select',
				'options'       => array(
					'custom' 	=> esc_html__( 'Custom', 'et_builder' ),
					'layout'  	=> esc_html__( 'Divi Layout', 'dd_builder' ),
				),
				'default'		=> 'custom',
				'toggle_slug'   => 'content1',
			),
			'layout_id' => array(
				'label'           	=> esc_html__( 'Divi Layout', 'dd_builder' ),
				'description'     	=> esc_html__( 'Here you can choose the Divi Library saved layout.', 'dd_builder' ),
				'type'            	=> 'select',
				'options'			=> $helper->get_all_layouts(),
				'searchable'       	=> true,
				'displayRecent'    	=> false,
				'show_if'			=> array('item_content1' => 'layout'),
				'toggle_slug'     	=> 'content1',				
			),
			'__layout1'	=> array(
				'type'                => 'computed',
				'computed_callback'   => array( 'DonDiviBuilderHelper', 'render_divi_layout' ),
				'computed_depends_on' => array(
					'layout_id',
				),
				'computed_minimum' => array(
					'layout_id',
				),
			),
            'label2' => array(
                'label'       		=> esc_html__( 'Label', 'et_builder' ),
                'type'        		=> 'text',				
                'hover'				=> 'tabs',
                'toggle_slug' 		=> 'content2',
                'dynamic_content' 	=> 'text',	
            ),
			'item_content2' 	=> array(
				'label'        	=> et_builder_i18n( 'Content' ),
				'type'         	=> 'select',
				'options'       => array(
					'custom' 	=> esc_html__( 'Custom', 'et_builder' ),
					'layout'  	=> esc_html__( 'Divi Layout', 'dd_builder' ),
				),
				'default'		=> 'custom',
				'toggle_slug'   => 'content2',
			),
			'divi_layout' => array(
				'label'           	=> esc_html__( 'Divi Layout', 'dd_builder' ),
				'description'     	=> esc_html__( 'Here you can choose the Divi Library saved layout.', 'dd_builder' ),
				'type'            	=> 'select',
				'options'			=> $helper->get_all_layouts(),
				'searchable'       	=> true,
				'displayRecent'    	=> false,
				'show_if'			=> array('item_content2' => 'layout'),
				'toggle_slug'     	=> 'content2',				
			),
			'__layout2'	=> array(
				'type'                => 'computed',
				'computed_callback'   => array( 'DonDiviBuilderHelper', 'render_divi_layout' ),
				'computed_depends_on' => array(
					'divi_layout',
				),
				'computed_minimum' => array(
					'divi_layout',
				),
			),
            'alignment' => array(
				'label'           	=> esc_html__( 'Alignment', 'et_builder' ),
				'type'            	=> 'text_align',
				'options'         	=> et_builder_get_text_orientation_options(),
				'options_icon'    	=> 'module_align',
				'default'			=> 'center',
				'mobile_options'	=> true,
				'tab_slug'        	=> 'advanced',
				'toggle_slug'     	=> 'main_content',
			),	
			'toggle_height' => array(
				'label'           	=> esc_html__( 'Height', 'et_builder' ),
				'type'            	=> 'range',
				'default'			=> '30px',
				'fixed_unit'		=> 'px',
				'mobile_options'  	=> true,
				'sticky'			=> true,
				'tab_slug'       	=> 'advanced',
				'toggle_slug'     	=> 'main_content',
			),
            'toggle_background_color'   => array(
				'label'         	=> esc_html__( 'Background Color', 'et_builder' ),
				'type'          	=> 'color-alpha',
				'custom_color'  	=> true,
				'default'		 	=> '#dfdfdf',
				'hover'          	=> 'tabs',
				'mobile_options' 	=> true,
				'sticky'         	=> true,
				'tab_slug'       	=> 'advanced',
				'toggle_slug'    	=> 'main_content',
			),
			'active_background_color'   => array(
				'label'          	=> esc_html__( 'Active Background Color', 'dd_builder' ),
				'type'           	=> 'color-alpha',
				'custom_color'   	=> true,
				'default'			=> et_builder_accent_color(),
				'tab_slug'       	=> 'advanced',
				'toggle_slug'    	=> 'main_content',
				'hover'          	=> 'tabs',
				'mobile_options' 	=> true,
				'sticky'         	=> true,
			),
            'slider_background_color'   => array(
				'label'         	=> esc_html__( 'Slider Background Color', 'dd_builder' ),
				'type'          	=> 'color-alpha',
				'custom_color'  	=> true,
				'default'		 	=> '#ffffff',
				'hover'          	=> 'tabs',
				'mobile_options' 	=> true,
				'sticky'         	=> true,
				'tab_slug'       	=> 'advanced',
				'toggle_slug'    	=> 'main_content',
			),
			'c1_background_color'   => array(
				'label'         	=> sprintf( '%1$s %2$s', esc_html__( 'Content One', 'dd_builder' ), esc_html__( 'Background Color', 'et_builder' ) ),
				'type'          	=> 'color-alpha',
				'custom_color'  	=> true,
				'hover'          	=> 'tabs',
				'mobile_options' 	=> true,
				'sticky'         	=> true,
				'tab_slug'       	=> 'advanced',
				'toggle_slug'    	=> 'content1',
			),
			'c2_background_color'   => array(
				'label'         	=> sprintf( '%1$s %2$s', esc_html__( 'Content Two', 'dd_builder' ), esc_html__( 'Background Color', 'et_builder' ) ),
				'type'          	=> 'color-alpha',
				'custom_color'  	=> true,
				'hover'          	=> 'tabs',
				'mobile_options' 	=> true,
				'sticky'         	=> true,
				'tab_slug'       	=> 'advanced',
				'toggle_slug'    	=> 'content2',
			),
			'ct_gap' 		=> array(
				'label'           	=> esc_html__( 'Labels Offset', 'dd_builder' ),
				'type'            	=> 'range',
				'default'         	=> '1em', 
				'default_unit'		=> 'px',
				'mobile_options'  	=> true,
				'tab_slug'       	=> 'advanced',
				'toggle_slug'     	=> 'margin_padding',			
			),
			'ct_margin' 		=> array(
				'label'           	=> esc_html__( 'Content Offset', 'dd_builder' ),
				'type'            	=> 'range',
				'default'         	=> '20px', 
				'default_unit'		=> 'px',
				'mobile_options'  	=> true,
				'tab_slug'       	=> 'advanced',
				'toggle_slug'     	=> 'margin_padding',			
			),
        );
		$cc1_settings = array(
			'content_slug' 	=> 'content1',
			'link_slug'		=> 'content1',
			'icon'			=> true,
			'icon_slug'		=> 'content1_icon',
			'button'		=> true,
			'show_if_not' 	=> array('item_content1' => 'layout' ),
			'prefix'		=> 'c1',
		);
		$cc2_settings = array(
			'content_slug' 	=> 'content2',
			'link_slug'		=> 'content2',
			'icon'			=> true,
			'icon_slug'		=> 'content2_icon',
			'button'		=> true,
			'show_if_not' 	=> array('item_content2' => 'layout' ),
			'prefix'		=> 'c2',
		);
        return array_merge( 
			$fields,
			$helper->get_font_fields( 'c1_body_ul', 'c1_body_ol', 'c1_body_quote', 'content1_body'),
			$helper->get_font_fields( 'c2_body_ul', 'c2_body_ol', 'c2_body_quote', 'content2_body'),
			$helper->get_custom_content_fields( $cc1_settings ),
			$helper->get_custom_content_fields( $cc2_settings ),
			$helper->get_effect_fields( 'content1_effects', false, 'none', 'fade', '1000ms', false, 'c1' ),
			$helper->get_effect_fields( 'content2_effects', false, 'none', 'fade', '1000ms', false, 'c2' )
		);                  
    }

	public function multi_view_filter_value( $raw_value, $args ) {

		$name = isset( $args['name'] ) ? $args['name'] : '';

		if ( $raw_value && ( 'c1_cc_icon' === $name || 'c2_cc_icon' === $name ) ) {
			return et_pb_get_extended_font_icon_value( $raw_value, true );
		}

		if ( $raw_value && in_array( $name, array( 'c1_content', 'c2_content' ), true ) ) {
			$raw_value = str_replace( array( '%22', '%92', '%91', '%93' ), array( '"', '\\', '&#91;', '&#93;' ), $raw_value );

			// Cleaning up invalid starting <\p> tag.
			$cleaned_value = preg_replace( '/(^<\/p>)(.*)/ius', '$2', $raw_value );

			// Cleaning up invalid ending <p> tag.
			$cleaned_value = preg_replace( '/(.*)(<p>$)/ius', '$1', $cleaned_value );

			// Override the raw value.
			if ( $raw_value !== $cleaned_value ) {
				$raw_value = trim( $cleaned_value, "\n" );

				if ( 'raw_content' !== $name ) {
					$raw_value = force_balance_tags( $raw_value );
				}
			}
		}
		return $raw_value;
	}

    public function render( $attrs, $content, $render_slug ) {

		wp_enqueue_script( 'ddb-toggle' );

		$this->generate_styles(
			array(
				'base_attr_name' => 'alignment',
				'selector'       => '%%order_class%% .ddb-content-toggle',
				'css_property'   => 'justify-content',
				'render_slug'    => $render_slug,
			)
		);
		$this->generate_styles(
			array(
				'base_attr_name' => 'ct_margin',
				'selector'       => '%%order_class%% .ddb-content-toggle',
				'css_property'   => 'margin-bottom',
				'render_slug'    => $render_slug,
			)
		);
		$this->generate_styles(
			array(
				'base_attr_name' => 'ct_gap',
				'selector'       => '%%order_class%% .ddb-content-toggle',
				'css_property'   => 'gap',
				'render_slug'    => $render_slug,
			)
		);
		$this->generate_styles(
			array(
				'base_attr_name' => 'toggle_height',
				'selector'       => '%%order_class%% .ddb-toggle-field',
				'css_property'   => 'font-size',
				'render_slug'    => $render_slug,
			)
		);
		$this->generate_styles(
			array(
				'base_attr_name' => 'toggle_background_color',
				'selector'       => '%%order_class%% .ddb-toggle-slider',
				'css_property'   => 'background-color',
				'render_slug'    => $render_slug,
			)
		);
		$this->generate_styles(
			array(
				'base_attr_name' => 'active_background_color',
				'selector'       => '%%order_class%% input:checked + .ddb-toggle-slider',
				'css_property'   => 'background-color',
				'render_slug'    => $render_slug,
			)
		);
		$this->generate_styles(
			array(
				'base_attr_name' => 'slider_background_color',
				'selector'       => '%%order_class%% .ddb-toggle-slider:before',
				'css_property'   => 'background-color',
				'render_slug'    => $render_slug,
			)
		);
		$this->generate_styles(
			array(
				'base_attr_name' => 'c1_background_color',
				'selector'       => '%%order_class%% .ddb-content-one > div',
				'css_property'   => 'background-color',
				'render_slug'    => $render_slug,
			)
		);
		$this->generate_styles(
			array(
				'base_attr_name' => 'c2_background_color',
				'selector'       => '%%order_class%% .ddb-content-two > div',
				'css_property'   => 'background-color',
				'render_slug'    => $render_slug,
			)
		);
	
		$helper 		= DonDiviBuilderHelper::get();
		$multi_view		= et_pb_multi_view_options( $this );
		$label_1 = $helper->render_title( $this, 'label1', 'c1_label', 'h4', 'ddb-label-one ddb-btn ddb-p-0' );
		$label_2 = $helper->render_title( $this, 'label2', 'c2_label', 'h4', 'ddb-label-two ddb-btn ddb-p-0' );

		$c1 = '';
		$c1_attrs = array( 'class' => 'ddb-content-one' );
		$helper->set_effect_attrs( $c1_attrs, $this->props, array( 'prefix' => 'c1') ); 
		if ($this->props['item_content1'] !== 'layout') {
			$c1 = sprintf('<div class="ddb-custom-c1 ddb-f ddb-bss ddb-p-xl">%s</div>', $helper->render_custom_content( $this, array( 'prefix' => 'c1', 'slug' => 'c1', 'selector' => '%%order_class%% .ddb-content-one' ) ) );	
		} else {
			$c1 = sprintf('<div class="ddb-layout-content">%s</div>', $helper->render_divi_layout( array('internal' => false, 'layout_id' => $this->props['layout_id']) ));
		} 
		$content_1 = $multi_view->render_element(
			array(
				'tag'     => 'div',
				'content' => $c1,
				'attrs'   => $c1_attrs,
			)
		);

		$c2 = '';
		$c2_attrs = array( 'class' => 'ddb-content-two ddb-none' );
		$helper->set_effect_attrs( $c2_attrs, $this->props, array( 'prefix' => 'c2') );  
		if ($this->props['item_content2'] !== 'layout') {
			$c2 = sprintf('<div class="ddb-custom-c2 ddb-f ddb-bss ddb-p-xl">%s</div>', $helper->render_custom_content( $this, array( 'prefix' => 'c2', 'slug' => 'c2', 'selector' => '%%order_class%% .ddb-content-two' ) ) );	
		} else {
			$c2 = $helper->render_divi_layout( array('internal' => false, 'layout_id' => $this->props['divi_layout']) );
		} 
		$content_2 = $multi_view->render_element(
			array(
				'tag'     => 'div',
				'content' => $c2,
				'attrs'   => $c2_attrs,
			)
		);

		$this->add_classname( $this->get_text_orientation_classname() );

		return sprintf('<div class="ddb-content-toggle ddb-f ddb-f-c"> 
			<label for="%1$s">%2$s</label>              
			<label class="ddb-toggle-field ddb-rel"><input id="%1$s" type="checkbox" style="display:none"/><span class="ddb-toggle-slider ddb-btn ddb-abs ddb-tl"></span></label>
			<label for="%1$s">%3$s</label>  
        </div>%4$s%5$s', $this->get_module_order_class($this->slug) . '_input', $label_1, $label_2, $content_1, $content_2);
    }
}

new DDBUILDER_Content_Toggle_Module;