description' => true
),
array(
'type' => 'template',
'template_id' => 'element_template_selection_tab',
'args' => array( 'sc' => $this )
),
array(
'type' => 'tab_container_close',
'nodescription' => true
)
);
}
/**
* Create and register templates for easier maintainance
*
* @since 4.6.4
*/
protected function register_dynamic_templates()
{
$this->register_modal_group_templates();
/**
* Content Tab
* ===========
*/
$c = array(
array(
'name' => __( 'Choose Image','avia_framework' ),
'desc' => __( 'Either upload a new, or choose an existing image from your media library. Once an Image has been selected you can add your Hotspots', 'avia_framework' ),
'id' => 'src',
'type' => 'image',
'title' => __( 'Insert Image', 'avia_framework' ),
'button' => __( 'Insert', 'avia_framework' ),
'std' => AviaBuilder::$path['imagesURL'] . 'placeholder-full.jpg',
'container_class' => 'av-hotspot-container',
'lockable' => true,
'locked' => array( 'src', 'attachment', 'attachment_size' )
),
array(
'name' => __( 'Add/Edit your hotspots.', 'avia_framework' ),
'desc' => __( 'Here you can add, remove and edit the locations, tooltips and appearance for your hotspots.', 'avia_framework' ),
'type' => 'modal_group',
'id' => 'content',
'modal_title' => __( 'Edit Hotspot Tooltip', 'avia_framework' ),
'add_label' => __( 'Add Hotspot', 'avia_framework' ),
'std' => array(),
'editable_item' => true,
'lockable' => true,
'tmpl_set_default' => false,
'special_modal' => array(
'type' => 'hotspot',
'image_container_class' => 'av-hotspot-container'
),
'subelements' => $this->create_modal()
)
);
AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'content_image' ), $c );
/**
* Styling Tab
* ===========
*/
$c = array(
array(
'name' => __( 'Hotspot Styling', 'avia_framework' ),
'desc' => __( 'Select the hotspot styling', 'avia_framework' ),
'id' => 'hotspot_layout',
'type' => 'select',
'std' => 'numbered',
'lockable' => true,
'subtype' => array(
__( 'Numbered Hotspot', 'avia_framework' ) => 'numbered',
__( 'Blank Hotspot', 'avia_framework' ) => 'blank'
)
)
);
$template = array(
array(
'type' => 'template',
'template_id' => 'toggle',
'title' => __( 'Hotspot', 'avia_framework' ),
'content' => $c
),
);
AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_hotspot' ), $template );
$c = array(
array(
'type' => 'template',
'template_id' => 'image_size_select',
'lockable' => true,
'method' => 'fallback_media'
)
);
$template = array(
array(
'type' => 'template',
'template_id' => 'toggle',
'title' => __( 'Image Size', 'avia_framework' ),
'content' => $c
),
);
AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_image_size' ), $template );
/**
* Advanced Tab
* =============
*/
$c = array(
array(
'name' => __( 'Image Fade in Animation', 'avia_framework' ),
'desc' => __( "Add a small animation to the image when the user first scrolls to the image position. This is only to add some 'spice' to the site and only works in modern browsers", 'avia_framework' ),
'id' => 'animation',
'type' => 'select',
'std' => 'no-animation',
'lockable' => true,
'subtype' => array(
__( 'None', 'avia_framework' ) => 'no-animation',
__( 'Simple Fade in', 'avia_framework' ) => 'fade-in',
__( 'Pop up', 'avia_framework' ) => 'pop-up',
__( 'Top to Bottom', 'avia_framework' ) => 'top-to-bottom',
__( 'Bottom to Top', 'avia_framework' ) => 'bottom-to-top',
__( 'Left to Right', 'avia_framework' ) => 'left-to-right',
__( 'Right to Left', 'avia_framework' ) => 'right-to-left'
)
),
array(
'name' => __( 'Show Tooltips', 'avia_framework' ),
'desc' => __( 'Select when to display the tooltips', 'avia_framework' ),
'id' => 'hotspot_tooltip_display',
'type' => 'select',
'std' => '',
'lockable' => true,
'subtype' => array(
__( 'On Mouse Hover', 'avia_framework' ) => '',
__( 'Always', 'avia_framework' ) => 'av-permanent-tooltip',
__( 'Show On Mouse Hover - Hide On Click', 'avia_framework' ) => 'av-close-on-click-tooltip'
)
)
);
$template = array(
array(
'type' => 'template',
'template_id' => 'toggle',
'title' => __( 'Animation', 'avia_framework' ),
'content' => $c
),
);
AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'advanced_animation' ), $template );
$c = array(
array(
'name' => __( 'Hotspot on mobile devices', 'avia_framework' ),
'desc' => __( 'Check if you always want to show the tooltips on mobile phones below the image. Recommended if your tooltips contain a lot of text', 'avia_framework' ),
'id' => 'hotspot_mobile',
'type' => 'checkbox',
'std' => 'true',
'lockable' => true
)
);
AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'advanced_mobile' ), $c );
}
/**
* Creates the modal popup for a single entry
*
* @since 4.6.4
* @return array
*/
protected function create_modal()
{
$elements = array(
array(
'type' => 'tab_container',
'nodescription' => true
),
array(
'type' => 'tab',
'name' => __( 'Content', 'avia_framework' ),
'nodescription' => true
),
array(
'type' => 'template',
'template_id' => $this->popup_key( 'modal_content_text' )
),
array(
'type' => 'tab_close',
'nodescription' => true
),
array(
'type' => 'tab',
'name' => __( 'Styling', 'avia_framework' ),
'nodescription' => true
),
array(
'type' => 'template',
'template_id' => 'toggle_container',
'templates_include' => array(
$this->popup_key( 'modal_styling_tooltip' ),
$this->popup_key( 'modal_styling_colors' )
),
'nodescription' => true
),
array(
'type' => 'tab_close',
'nodescription' => true
),
array(
'type' => 'tab',
'name' => __( 'Advanced', 'avia_framework' ),
'nodescription' => true
),
array(
'type' => 'template',
'template_id' => 'toggle_container',
'templates_include' => array(
$this->popup_key( 'modal_advanced_link' )
),
'nodescription' => true
),
array(
'type' => 'tab_close',
'nodescription' => true
),
array(
'type' => 'template',
'template_id' => 'element_template_selection_tab',
'args' => array(
'sc' => $this,
'modal_group' => true
)
),
array(
'id' => 'hotspot_pos',
'std' => '',
'type' => 'hidden'
),
array(
'type' => 'tab_container_close',
'nodescription' => true
)
);
return $elements;
}
/**
* Register all templates for the modal group popup
*
* @since 4.6.4
*/
protected function register_modal_group_templates()
{
/**
* Content Tab
* ===========
*/
$c = array(
array(
'name' => __( 'Tooltip', 'avia_framework' ),
'desc' => __( 'Enter a short descriptive text that appears if the user places his mouse above the hotspot', 'avia_framework' ) ,
'id' => 'content',
'type' => 'tiny_mce',
'std' => '',
'lockable' => true,
'tmpl_set_default' => false
),
);
AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_content_text' ), $c );
/**
* Styling Tab
* ===========
*/
$c = array(
array(
'name' => __( 'Tooltip Position', 'avia_framework' ),
'desc' => __( 'Select where to display the tooltip in relation to the hotspot', 'avia_framework' ),
'id' => 'tooltip_pos',
'type' => 'select',
'std' => 'av-tt-pos-above av-tt-align-left',
'lockable' => true,
'subtype' => array(
'Above' => array(
__( 'Top Left', 'avia_framework' ) => 'av-tt-pos-above av-tt-align-left',
__( 'Top Right', 'avia_framework' ) => 'av-tt-pos-above av-tt-align-right',
__( 'Top Centered', 'avia_framework' ) => 'av-tt-pos-above av-tt-align-centered',
),
'Below' => array(
__( 'Bottom Left', 'avia_framework' ) => 'av-tt-pos-below av-tt-align-left',
__( 'Bottom Right', 'avia_framework' ) => 'av-tt-pos-below av-tt-align-right',
__( 'Bottom Centered', 'avia_framework' ) => 'av-tt-pos-below av-tt-align-centered',
),
'Left' => array(
__( 'Left Top', 'avia_framework' ) => 'av-tt-pos-left av-tt-align-top',
__( 'Left Bottom', 'avia_framework' ) => 'av-tt-pos-left av-tt-align-bottom',
__( 'Left Centered', 'avia_framework' ) => 'av-tt-pos-left av-tt-align-centered',
),
'Right'=> array(
__( 'Right Top', 'avia_framework' ) => 'av-tt-pos-right av-tt-align-top',
__( 'Right Bottom', 'avia_framework' ) => 'av-tt-pos-right av-tt-align-bottom',
__( 'Right Centered', 'avia_framework' ) => 'av-tt-pos-right av-tt-align-centered',
)
)
),
array(
'name' => __( 'Tooltip Width', 'avia_framework' ),
'desc' => __( 'Select the width of the tooltip. Height is based on the content', 'avia_framework' ),
'id' => 'tooltip_width',
'type' => 'select',
'std' => 'av-tt-default-width',
'lockable' => true,
'subtype' => array(
__( 'Default', 'avia_framework' ) => 'av-tt-default-width',
__( 'Large', 'avia_framework' ) => 'av-tt-large-width',
__( 'Extra Large', 'avia_framework' ) => 'av-tt-xlarge-width',
),
),
array(
'name' => __( 'Tooltip Style', 'avia_framework' ),
'desc' => __( 'Choose the style of your tooltip', 'avia_framework' ) ,
'id' => 'tooltip_style',
'type' => 'select',
'std' => 'main_color',
'lockable' => true,
'subtype' => array(
__( 'Default', 'avia_framework' ) => 'main_color',
__( 'Default with drop shadow', 'avia_framework' ) => 'main_color av-tooltip-shadow',
__( 'Transparent Dark', 'avia_framework' ) => 'transparent_dark'
)
)
);
$template = array(
array(
'type' => 'template',
'template_id' => 'toggle',
'title' => __( 'Tooltip', 'avia_framework' ),
'content' => $c
),
);
AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_styling_tooltip' ), $template );
$c = array(
array(
'name' => __( 'Hotspot Color', 'avia_framework' ),
'desc' => __( 'Set the colors of your hotspot', 'avia_framework' ),
'id' => 'hotspot_color',
'type' => 'select',
'std' => '',
'lockable' => true,
'subtype' => array(
__( 'Default', 'avia_framework' ) => '',
__( 'Custom', 'avia_framework' ) => 'custom',
),
),
array(
'name' => __( 'Custom Background Color', 'avia_framework' ),
'desc' => __( 'Select a custom background color here', 'avia_framework' ),
'id' => 'custom_bg',
'type' => 'colorpicker',
'std' => '#ffffff',
'lockable' => true,
'required' => array( 'hotspot_color', 'equals', 'custom' )
),
array(
'name' => __( 'Custom Font Color', 'avia_framework' ),
'desc' => __( 'Select a custom font color here', 'avia_framework' ),
'id' => 'custom_font',
'type' => 'colorpicker',
'std' => '#888888',
'lockable' => true,
'required' => array( 'hotspot_color', 'equals', 'custom' )
),
array(
'name' => __( 'Custom Pulse Color', 'avia_framework' ),
'desc' => __( 'Select a custom pulse color here', 'avia_framework' ),
'id' => 'custom_pulse',
'type' => 'colorpicker',
'std' => '#ffffff',
'lockable' => true,
'required' => array( 'hotspot_color', 'equals', 'custom' )
)
);
$template = array(
array(
'type' => 'template',
'template_id' => 'toggle',
'title' => __( 'Colors', 'avia_framework' ),
'content' => $c
),
);
AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_styling_colors' ), $template );
/**
* Advanced Tab
* ============
*/
$c = array(
array(
'type' => 'template',
'template_id' => 'linkpicker_toggle',
'name' => __( 'Hotspot Link?', 'avia_framework' ),
'desc' => __( 'Where should your hotspot link to?', 'avia_framework' ),
'target_id' => 'link_target',
'no_toggle' => true,
'lockable' => true,
'subtypes' => array( 'no', 'manually', 'single', 'taxonomy' )
)
);
AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_advanced_link' ), $c );
}
/**
* Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
* Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
* Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
*
*
* @param array $params this array holds the default values for $content and $args.
* @return $params the return array usually holds an innerHtml key that holds item specific markup.
*/
function editor_element( $params )
{
$default = array();
$locked = array();
$attr = $params['args'];
Avia_Element_Templates()->set_locked_attributes( $attr, $this, $this->config['shortcode'], $default, $locked );
$template = $this->update_template_lockable( 'src', "", $locked );
$img = '';
if( ! empty( $attr['attachment'] ) && ! empty( $attr['attachment_size'] ) )
{
$img = wp_get_attachment_image( $attr['attachment'], $attr['attachment_size'] );
}
else if( isset( $attr['src'] ) && is_numeric( $attr['src'] ) )
{
$img = wp_get_attachment_image( $attr['src'], 'large' );
}
else if( ! empty( $attr['src'] ) )
{
$img = "
";
}
$html = AviaPopupTemplates()->get_html_template( 'alb_element_fullwidth_stretch' );
$button = ' ';
$pos = strrpos( $html, '' );
$html = substr( $html, 0, $pos ) . $button . '';
$params['innerHtml'] = '