slug = 'ba_video_popup';
$this->vb_support = 'on';
$this->name = esc_html__('Video Modal', 'addons-for-divi');
$this->icon_path = $this->dtl_icon_path('video-modal');
$this->settings_modal_toggles = array(
'general' => array(
'toggles' => array(
'content' => esc_html__('Content', 'addons-for-divi'),
'settings' => esc_html__('Settings', 'addons-for-divi'),
),
),
'advanced' => array(
'toggles' => array(
'image' => esc_html__('Image', 'addons-for-divi'),
'icon' => esc_html__('Icon', 'addons-for-divi'),
'text' => esc_html__('Text', 'addons-for-divi'),
'popup' => esc_html__('Popup', 'addons-for-divi'),
),
),
);
$this->custom_css_fields = array(
'image' => array(
'label' => esc_html__('Image', 'addons-for-divi'),
'selector' => '%%order_class%% .dtq-video-popup .dtq-video-popup-figure img',
),
'icon_wrapper' => array(
'label' => esc_html__('Icon Wrapper', 'addons-for-divi'),
'selector' => '%%order_class%% .dtq-video-popup .dtq-video-popup-icon',
),
'icon' => array(
'label' => esc_html__('Icon', 'addons-for-divi'),
'selector' => '%%order_class%% .dtq-video-popup .dtq-video-popup-icon svg',
),
'text' => array(
'label' => esc_html__('Text', 'addons-for-divi'),
'selector' => '%%order_class%% .dtq-video-popup .dtq-video-popup-text',
),
);
}
public function get_fields()
{
$fields = array(
'use_overlay' => array(
'label' => esc_html__('Use Overlay Image', 'addons-for-divi'),
'description' => esc_html__('Here you can choose whether overlay image should be used.', 'addons-for-divi'),
'type' => 'yes_no_button',
'option_category' => 'configuration',
'options' => array(
'on' => esc_html__('Yes', 'addons-for-divi'),
'off' => esc_html__('No', 'addons-for-divi'),
),
'default' => 'on',
'toggle_slug' => 'content',
),
'image' => array(
'label' => esc_html__('Image', 'addons-for-divi'),
'description' => esc_html__('Here you can define placeholder image for the video.', 'addons-for-divi'),
'type' => 'upload',
'data_type' => 'image',
'default' => DIVI_TORQUE_LITE_ASSETS . 'imgs/placeholder.svg',
'upload_button_text' => esc_attr__('Upload an image', 'addons-for-divi'),
'choose_text' => esc_attr__('Choose an Image', 'addons-for-divi'),
'update_text' => esc_attr__('Set As Image', 'addons-for-divi'),
'toggle_slug' => 'content',
'show_if' => array(
'use_overlay' => 'on',
),
),
'image_alt' => array(
'label' => esc_html__('Image Alt Text', 'addons-for-divi'),
'description' => esc_html__('Here you can define the HTML ALT text for your overlay image.', 'addons-for-divi'),
'type' => 'text',
'toggle_slug' => 'content',
'show_if' => array(
'use_overlay' => 'on',
),
),
'trigger_element' => array(
'label' => esc_html__('Button Element', 'addons-for-divi'),
'description' => esc_html__('Here you can select button element for the video popup.', 'addons-for-divi'),
'type' => 'select',
'toggle_slug' => 'content',
'default' => 'icon',
'options' => array(
'icon' => esc_html__('Icon', 'addons-for-divi'),
'text' => esc_html__('Text', 'addons-for-divi'),
'icon_text' => esc_html__('Icon & Text', 'addons-for-divi'),
),
),
'icon' => array(
'label' => esc_html__('Select Play Icon', 'addons-for-divi'),
'description' => esc_html__('Here you can select different type of play icon from the video.', 'addons-for-divi'),
'type' => 'select',
'toggle_slug' => 'content',
'default' => '1',
'options' => array(
'1' => esc_html__('Icon 1', 'addons-for-divi'),
'2' => esc_html__('Icon 2', 'addons-for-divi'),
'3' => esc_html__('Icon 3', 'addons-for-divi'),
'4' => esc_html__('Icon 4', 'addons-for-divi'),
'5' => esc_html__('Icon 5', 'addons-for-divi'),
'6' => esc_html__('Icon 6', 'addons-for-divi'),
'custom' => esc_html__('Custom Icon', 'addons-for-divi'),
),
'show_if' => array(
'trigger_element' => array('icon', 'icon_text'),
),
),
'custom_play_icon' => array(
'label' => esc_html__('Custom Icon', 'addons-for-divi'),
'description' => esc_html__('Here you can define custom icon for the video.', 'addons-for-divi'),
'type' => 'upload',
'data_type' => 'image',
'upload_button_text' => esc_attr__('Upload an Icon', 'addons-for-divi'),
'choose_text' => esc_attr__('Choose an Icon', 'addons-for-divi'),
'update_text' => esc_attr__('Set As Icon', 'addons-for-divi'),
'toggle_slug' => 'content',
'show_if' => array(
'trigger_element' => 'icon',
'icon' => 'custom',
),
),
'text' => array(
'label' => esc_html__('Trigger Text', 'addons-for-divi'),
'description' => esc_html__('Define the trigger text for your popup.', 'addons-for-divi'),
'type' => 'text',
'toggle_slug' => 'content',
'default' => 'Play',
'show_if' => array(
'trigger_element' => array('text', 'icon_text'),
),
),
'type' => array(
'label' => esc_html__('Video Type', 'addons-for-divi'),
'description' => esc_html__('Define video type for the popup.', 'addons-for-divi'),
'type' => 'select',
'toggle_slug' => 'content',
'default' => 'yt',
'options' => array(
'yt' => esc_html__('Youtube', 'addons-for-divi'),
'vm' => esc_html__('Vimeo', 'addons-for-divi'),
'video' => esc_html__('Custom Upload', 'addons-for-divi'),
),
),
'video_link' => array(
'label' => esc_html__('Video URL', 'addons-for-divi'),
'description' => esc_html__('Here you can define the URL for the video you would like to display.', 'addons-for-divi'),
'type' => 'text',
'toggle_slug' => 'content',
'show_if_not' => array(
'type' => 'video',
),
),
'video' => array(
'label' => esc_html__('Video MP4 File', 'addons-for-divi'),
'type' => 'upload',
'data_type' => 'video',
'upload_button_text' => esc_attr__('Upload a video', 'addons-for-divi'),
'choose_text' => esc_attr__('Choose a Video MP4 File', 'addons-for-divi'),
'update_text' => esc_attr__('Set As Video', 'addons-for-divi'),
'description' => esc_html__('Upload your desired video in .MP4 format, or type in the URL to the video you would like to display', 'addons-for-divi'),
'toggle_slug' => 'content',
'show_if' => array(
'type' => 'video',
),
),
'use_animation' => array(
'label' => esc_html__('Use Animated Icon', 'addons-for-divi'),
'description' => esc_html__('Use animated wave for your icon. For better experience please set icon background color from icon design toggle.', 'addons-for-divi'),
'type' => 'yes_no_button',
'option_category' => 'configuration',
'options' => array(
'on' => esc_html__('Yes', 'addons-for-divi'),
'off' => esc_html__('No', 'addons-for-divi'),
),
'default' => 'off',
'toggle_slug' => 'settings',
),
'wave_bg' => array(
'label' => esc_html__('Animated Wave Color', 'addons-for-divi'),
'description' => esc_html__('Here you can define custom color for the animated wave of your icon.', 'addons-for-divi'),
'type' => 'color-alpha',
'default' => '#ffffff',
'custom_color' => true,
'toggle_slug' => 'settings',
'show_if' => array(
'use_animation' => 'on',
),
),
'icon_alignment' => array(
'label' => esc_html__('Icon/Text Alignment', 'addons-for-divi'),
'description' => esc_html__('Align content to the left, right or center.', 'addons-for-divi'),
'type' => 'text_align',
'option_category' => 'layout',
'options' => et_builder_get_text_orientation_options(array('justified')),
'options_icon' => 'module_align',
'default' => 'center',
'toggle_slug' => 'settings',
'mobile_options' => true,
'show_if' => array(
'use_overlay' => 'off',
),
),
'icon_spacing' => array(
'label' => esc_html__('Spacing Between Icon and Text', 'addons-for-divi'),
'description' => esc_html__('Here you can define spacing between icon and text.', 'addons-for-divi'),
'type' => 'range',
'default' => '20px',
'default_unit' => 'px',
'mobile_options' => true,
'range_settings' => array(
'min' => 0,
'max' => 100,
'step' => 1,
),
'toggle_slug' => 'settings',
'show_if' => array(
'trigger_element' => 'icon_text',
),
),
'img_height' => array(
'label' => esc_html__('Image Height', 'addons-for-divi'),
'description' => esc_html__('Here you can define static height for your image.', 'addons-for-divi'),
'type' => 'range',
'default_unit' => 'px',
'mobile_options' => true,
'range_settings' => array(
'min' => 0,
'max' => 500,
'step' => 1,
),
'tab_slug' => 'advanced',
'toggle_slug' => 'image',
'show_if' => array(
'use_overlay' => 'on',
),
),
'icon_color' => array(
'label' => esc_html__('Color', 'addons-for-divi'),
'description' => esc_html__('Here you can define custom color for your icon . ', 'Torque - divi - addons'),
'type' => 'color-alpha',
'custom_color' => true,
'tab_slug' => 'advanced',
'default' => $this->default_color,
'toggle_slug' => 'icon',
'hover' => 'tabs',
'show_if' => array(
'trigger_element' => array('icon', 'icon_text'),
),
),
'icon_size' => array(
'label' => esc_html__('Size', 'addons-for-divi'),
'description' => esc_html__('Here you can define custom size for your icon.', 'addons-for-divi'),
'type' => 'range',
'default' => '60px',
'default_unit' => 'px',
'hover' => 'tabs',
'mobile_options' => true,
'range_settings' => array(
'min' => 0,
'max' => 200,
'step' => 1,
),
'toggle_slug' => 'icon',
'tab_slug' => 'advanced',
'show_if' => array(
'trigger_element' => array('icon', 'icon_text'),
),
),
'icon_opacity' => array(
'label' => esc_html__('Opacity', 'addons-for-divi'),
'description' => esc_html__('Define the opacity for the icon. Set the value from 0 - 1. The lower value, the more transparent.', 'addons-for-divi'),
'type' => 'range',
'default' => '1',
'unitless' => true,
'range_settings' => array(
'min' => 0,
'max' => 1,
'step' => .02,
),
'toggle_slug' => 'icon',
'tab_slug' => 'advanced',
'hover' => 'tabs',
'show_if' => array(
'trigger_element' => array('icon', 'icon_text'),
),
),
'icon_height' => array(
'label' => esc_html__('Height', 'addons-for-divi'),
'description' => esc_html__('Here you can define static height for your icon.', 'addons-for-divi'),
'type' => 'range',
'default' => 'initial',
'default_unit' => 'px',
'range_settings' => array(
'min' => 0,
'max' => 300,
'step' => 1,
),
'toggle_slug' => 'icon',
'tab_slug' => 'advanced',
'mobile_options' => true,
'show_if' => array(
'trigger_element' => array('icon', 'icon_text'),
),
),
'icon_width' => array(
'label' => esc_html__('Width', 'addons-for-divi'),
'description' => esc_html__('Here you can define static width for your icon.', 'addons-for-divi'),
'type' => 'range',
'default' => 'initial',
'default_unit' => 'px',
'range_settings' => array(
'min' => 0,
'max' => 300,
'step' => 1,
),
'toggle_slug' => 'icon',
'tab_slug' => 'advanced',
'mobile_options' => true,
'show_if' => array(
'trigger_element' => array('icon', 'icon_text'),
),
),
'icon_bg' => array(
'label' => esc_html__('Background', 'addons-for-divi'),
'description' => esc_html__('Here you can define custom background for your icon.', 'addons-for-divi'),
'type' => 'color-alpha',
'custom_color' => true,
'toggle_slug' => 'icon',
'tab_slug' => 'advanced',
'hover' => 'tabs',
'show_if' => array(
'trigger_element' => array('icon', 'icon_text'),
),
),
'icon_radius' => array(
'label' => esc_html__('Border Radius', 'addons-for-divi'),
'description' => esc_html__('Here you can define the radius value for your icon border.', 'addons-for-divi'),
'type' => 'range',
'default' => '0px',
'default_unit' => 'px',
'range_settings' => array(
'min' => 0,
'max' => 400,
'step' => 1,
),
'toggle_slug' => 'icon',
'tab_slug' => 'advanced',
'show_if' => array(
'trigger_element' => array('icon', 'icon_text'),
),
),
// Popup.
'popup_bg' => array(
'label' => esc_html__('Popup Background', 'addons-for-divi'),
'description' => esc_html__('Here you can define custom background color for your popup.', 'addons-for-divi'),
'type' => 'color-alpha',
'custom_color' => true,
'tab_slug' => 'advanced',
'default' => 'rgba(0,0,0,.8)',
'toggle_slug' => 'popup',
),
'close_icon_color' => array(
'label' => esc_html__('Close Icon Color', 'addons-for-divi'),
'description' => esc_html__('Here you can define custom color for your popup close icon.', 'addons-for-divi'),
'type' => 'color-alpha',
'custom_color' => true,
'tab_slug' => 'advanced',
'default' => '#ffffff',
'toggle_slug' => 'popup',
),
);
$text = array(
'use_text_box' => array(
'label' => esc_html__('Use Text Box', 'addons-for-divi'),
'description' => esc_html__('Here you can choose whether overlay image should be used.', 'addons-for-divi'),
'type' => 'yes_no_button',
'option_category' => 'configuration',
'options' => array(
'on' => esc_html__('Yes', 'addons-for-divi'),
'off' => esc_html__('No', 'addons-for-divi'),
),
'default' => 'off',
'toggle_slug' => 'text',
'tab_slug' => 'advanced',
'show_if' => array(
'trigger_element' => array('text', 'icon_text'),
),
),
'text_box_height' => array(
'label' => esc_html__('Text Box Height', 'addons-for-divi'),
'description' => esc_html__('Here you can define static height for your text box.', 'addons-for-divi'),
'type' => 'range',
'default' => '80px',
'default_unit' => 'px',
'range_settings' => array(
'min' => 0,
'max' => 300,
'step' => 1,
),
'toggle_slug' => 'text',
'tab_slug' => 'advanced',
'mobile_options' => true,
'show_if' => array(
'use_text_box' => 'on',
'trigger_element' => array('text', 'icon_text'),
),
),
'text_box_width' => array(
'label' => esc_html__('Text Box Width', 'addons-for-divi'),
'description' => esc_html__('Here you can define static width for your text box.', 'addons-for-divi'),
'type' => 'range',
'default' => '80px',
'default_unit' => 'px',
'range_settings' => array(
'min' => 0,
'max' => 300,
'step' => 1,
),
'toggle_slug' => 'text',
'tab_slug' => 'advanced',
'mobile_options' => true,
'show_if' => array(
'use_text_box' => 'on',
'trigger_element' => array('text', 'icon_text'),
),
),
'text_box_bg' => array(
'label' => esc_html__('Text Box Background', 'addons-for-divi'),
'description' => esc_html__('Here you can define custom background for your text box.', 'addons-for-divi'),
'type' => 'color-alpha',
'custom_color' => true,
'toggle_slug' => 'text',
'default' => $this->default_color,
'tab_slug' => 'advanced',
'hover' => 'tabs',
'show_if' => array(
'use_text_box' => 'on',
'trigger_element' => array('text', 'icon_text'),
),
),
'text_box_radius' => array(
'label' => esc_html__('Text Box Border Radius', 'addons-for-divi'),
'description' => esc_html__('Here you can define the radius value for your text box border.', 'addons-for-divi'),
'type' => 'range',
'default' => '0px',
'default_unit' => 'px',
'range_settings' => array(
'min' => 0,
'max' => 400,
'step' => 1,
),
'toggle_slug' => 'text',
'tab_slug' => 'advanced',
'show_if' => array(
'use_text_box' => 'on',
'trigger_element' => array('text', 'icon_text'),
),
),
);
$img_overlay = $this->custom_background_fields(
'image',
__('Image Overlay', 'addons-for-divi'),
'advanced',
'image',
array('color', 'gradient', 'hover'),
array('use_overlay' => 'on'),
''
);
return array_merge($fields, $img_overlay, $text);
}
public function get_advanced_fields_config()
{
$advanced_fields = array();
$advanced_fields['text'] = array();
$advanced_fields['fonts'] = array();
$advanced_fields['text_shadow'] = array();
$advanced_fields['fonts']['trigger'] = array(
'css' => array(
'main' => '%%order_class%% .dtq-video-popup .dtq-video-popup-text',
'important' => 'all',
),
'tab_slug' => 'advanced',
'toggle_slug' => 'text',
'hide_text_align' => true,
'font_size' => array(
'default' => '16px',
),
);
return $advanced_fields;
}
protected function render_trigger($icon)
{
$svg_icon = '';
$text = '';
if ('text' !== $this->props['trigger_element']) {
$icons = array(
'1' => '',
'2' => '',
'3' => '',
'4' => '',
'5' => '',
'6' => '',
'custom' => sprintf('', $this->props['custom_play_icon']),
);
$svg_icon = sprintf('', $icons[$icon]);
}
if ('icon' !== $this->props['trigger_element']) {
$text = sprintf('%1$s', $this->props['text']);
}
return $svg_icon . $text;
}
public function render($attrs, $content, $render_slug)
{
$inline_modal = '';
$image = $this->props['image'];
$close_icon_color = $this->props['close_icon_color'];
$popup_bg = $this->props['popup_bg'];
$image = $this->props['image'];
$image_alt = $this->props['image_alt'];
$icon = $this->props['icon'];
$video_link = $this->props['video_link'];
$type = $this->props['type'];
$video = $this->props['video'];
$use_overlay = $this->props['use_overlay'];
$img_overlay = '';
$order_class = self::get_module_order_class($render_slug);
$order_number = str_replace('_', '', str_replace($this->slug, '', $order_class));
$data_modal = 'video' === $type ? sprintf('data-mfp-src="#dtq-video-popup-%1$s"', $order_number) : '';
// popup style.
ET_Builder_Element::set_style(
$render_slug,
array(
'selector' => ".dtq-video-popup-{$order_number} .mfp-bg",
'declaration' => sprintf('opacity:1!important;background: %1$s!important;', $popup_bg),
)
);
ET_Builder_Element::set_style(
$render_slug,
array(
'selector' => ".dtq-video-popup-{$order_number} .mfp-iframe-holder .mfp-close",
'declaration' => sprintf('color: %1$s!important;', $close_icon_color),
)
);
$this->apply_css($render_slug);
if ('video' === $type) {
$inline_modal = sprintf(
'