display-conditions.php
2 weeks ago
equal-height.php
2 weeks ago
floating-effects.php
2 weeks ago
liquid-glass.php
2 weeks ago
shape-divider.php
2 weeks ago
shapes.php
2 weeks ago
tooltips.php
3 days ago
wrapper-link.php
2 weeks ago
tooltips.php
1302 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class: Tooltips |
| 4 | * Name: Tooltips |
| 5 | * Slug: tooltips |
| 6 | */ |
| 7 | |
| 8 | namespace PremiumAddons\Addons; |
| 9 | |
| 10 | // Elementor Classes. |
| 11 | use Elementor\Utils; |
| 12 | use Elementor\Repeater; |
| 13 | use Elementor\Icons_Manager; |
| 14 | use Elementor\Control_Media; |
| 15 | use Elementor\Controls_Manager; |
| 16 | use Elementor\Group_Control_Border; |
| 17 | use Elementor\Group_Control_Box_Shadow; |
| 18 | use Elementor\Group_Control_Typography; |
| 19 | use Elementor\Group_Control_Text_Shadow; |
| 20 | |
| 21 | // Premium Addons Classes. |
| 22 | use PremiumAddons\Admin\Includes\Admin_Helper; |
| 23 | use PremiumAddons\Includes\Helper_Functions; |
| 24 | use PremiumAddons\Includes\Controls\Premium_Background; |
| 25 | |
| 26 | if ( ! defined( 'ABSPATH' ) ) { |
| 27 | exit; // If this file is called directly, abort. |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Class Tooltips |
| 32 | * |
| 33 | * @since 4.11.58 |
| 34 | * @access public |
| 35 | * @package PremiumAddons\Addons |
| 36 | */ |
| 37 | class Tooltips { |
| 38 | |
| 39 | /** |
| 40 | * Load Script |
| 41 | * |
| 42 | * @var bool|null |
| 43 | */ |
| 44 | private static $load_script = null; |
| 45 | |
| 46 | /** |
| 47 | * Class object |
| 48 | * |
| 49 | * @var self|null |
| 50 | */ |
| 51 | private static $instance = null; |
| 52 | |
| 53 | /** |
| 54 | * Class Constructor Function. |
| 55 | */ |
| 56 | public function __construct() { |
| 57 | |
| 58 | // Enqueue the required JS file. |
| 59 | add_action( 'elementor/preview/enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
| 60 | add_action( 'elementor/preview/enqueue_styles', array( $this, 'enqueue_styles' ) ); |
| 61 | |
| 62 | // Creates Premium Global Tooltips tab at the end of layout/content tab. |
| 63 | add_action( 'elementor/element/section/section_layout/after_section_end', array( $this, 'register_controls' ), 10 ); |
| 64 | add_action( 'elementor/element/column/section_advanced/after_section_end', array( $this, 'register_controls' ), 10 ); |
| 65 | add_action( 'elementor/element/common/_section_style/after_section_end', array( $this, 'register_controls' ), 10 ); |
| 66 | |
| 67 | // Editor Hooks. |
| 68 | add_action( 'elementor/section/print_template', array( $this, 'print_template' ), 10, 2 ); |
| 69 | add_action( 'elementor/column/print_template', array( $this, 'print_template' ), 10, 2 ); |
| 70 | add_action( 'elementor/widget/print_template', array( $this, 'print_template' ), 10, 2 ); |
| 71 | |
| 72 | // Frontend Hooks. |
| 73 | add_action( 'elementor/frontend/section/before_render', array( $this, 'before_render' ) ); |
| 74 | add_action( 'elementor/frontend/column/before_render', array( $this, 'before_render' ) ); |
| 75 | add_action( 'elementor/widget/before_render_content', array( $this, 'before_render' ), 10, 1 ); |
| 76 | |
| 77 | add_action( 'elementor/frontend/before_render', array( $this, 'check_script_enqueue' ) ); |
| 78 | |
| 79 | add_action( 'elementor/element/container/section_layout/after_section_end', array( $this, 'register_controls' ), 10 ); |
| 80 | add_action( 'elementor/container/print_template', array( $this, 'print_template' ), 10, 2 ); |
| 81 | add_action( 'elementor/frontend/container/before_render', array( $this, 'before_render' ) ); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Enqueue scripts. |
| 86 | * |
| 87 | * Registers required dependencies for the extension and enqueues them. |
| 88 | * |
| 89 | * @since 1.6.5 |
| 90 | * @access public |
| 91 | */ |
| 92 | public function enqueue_scripts() { |
| 93 | |
| 94 | if ( ! wp_script_is( 'lottie-js', 'enqueued' ) ) { |
| 95 | wp_enqueue_script( 'lottie-js' ); |
| 96 | } |
| 97 | |
| 98 | if ( ! wp_script_is( 'pa-tweenmax', 'enqueued' ) ) { |
| 99 | wp_enqueue_script( 'pa-tweenmax' ); |
| 100 | } |
| 101 | |
| 102 | if ( ! wp_script_is( 'tooltipster-bundle', 'enqueued' ) ) { |
| 103 | wp_enqueue_script( 'tooltipster-bundle' ); |
| 104 | } |
| 105 | |
| 106 | if ( ! wp_script_is( 'pa-gTooltips', 'enqueued' ) ) { |
| 107 | wp_enqueue_script( 'pa-gTooltips' ); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Enqueue styles. |
| 113 | * |
| 114 | * Registers required dependencies for the extension and enqueues them. |
| 115 | * |
| 116 | * @since 2.6.5 |
| 117 | * @access public |
| 118 | */ |
| 119 | public function enqueue_styles() { |
| 120 | |
| 121 | if ( ! wp_style_is( 'tooltipster', 'enqueued' ) ) { |
| 122 | wp_enqueue_style( 'tooltipster' ); |
| 123 | } |
| 124 | |
| 125 | if ( ! wp_style_is( 'pa-gTooltips', 'enqueued' ) ) { |
| 126 | wp_enqueue_style( 'pa-gTooltips' ); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Register Global Tooltip controls. |
| 132 | * |
| 133 | * @since 1.0.0 |
| 134 | * @access public |
| 135 | * @param object $element for current element. |
| 136 | */ |
| 137 | public function register_controls( $element ) { |
| 138 | |
| 139 | $tab = ! in_array( $element->get_name(), array( 'common', 'common-optimized' ), true ) ? Controls_Manager::TAB_LAYOUT : Controls_Manager::TAB_CONTENT; |
| 140 | |
| 141 | $element->start_controls_section( |
| 142 | 'section_premium_global_tooltip', |
| 143 | array( |
| 144 | 'label' => sprintf( '<i class="pa-extension-icon pa-dash-icon"></i> %s', __( 'Global Tooltip', 'premium-addons-for-elementor' ) ), |
| 145 | 'tab' => $tab, |
| 146 | ) |
| 147 | ); |
| 148 | |
| 149 | $element->add_control( |
| 150 | 'premium_tooltip_update', |
| 151 | array( |
| 152 | 'label' => '<div class="elementor-update-preview" style="background-color: #fff;"><div class="elementor-update-preview-title">Update changes to page</div><div class="elementor-update-preview-button-wrapper"><button class="elementor-update-preview-button elementor-button elementor-button-success">Apply</button></div></div>', |
| 153 | 'type' => Controls_Manager::RAW_HTML, |
| 154 | ) |
| 155 | ); |
| 156 | |
| 157 | $element->add_control( |
| 158 | 'premium_tooltip_switcher', |
| 159 | array( |
| 160 | 'label' => __( 'Enable Global Tooltip', 'premium-addons-for-elementor' ), |
| 161 | 'type' => Controls_Manager::SWITCHER, |
| 162 | 'render_type' => 'template', |
| 163 | 'return_value' => 'yes', |
| 164 | 'prefix_class' => 'premium-global-tooltips-', |
| 165 | ) |
| 166 | ); |
| 167 | |
| 168 | $element->add_control( |
| 169 | 'pa_tooltip_target', |
| 170 | array( |
| 171 | 'label' => __( 'CSS Selector', 'premium-addons-for-elementor' ), |
| 172 | 'type' => Controls_Manager::TEXT, |
| 173 | 'dynamic' => array( |
| 174 | 'active' => true, |
| 175 | ), |
| 176 | 'condition' => array( |
| 177 | 'premium_tooltip_switcher' => 'yes', |
| 178 | ), |
| 179 | ) |
| 180 | ); |
| 181 | |
| 182 | $element->add_control( |
| 183 | 'premium_tooltip_notice', |
| 184 | array( |
| 185 | 'raw' => __( '<strong>Please Note!:</strong><ul><li> It\'s not recommended to use <b>Premium Global Tooltips</b> on a parent and a child elements at the same time.</li></ul>', 'premium-addons-for-elementor' ), |
| 186 | 'type' => Controls_Manager::RAW_HTML, |
| 187 | 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info', |
| 188 | 'condition' => array( |
| 189 | 'premium_tooltip_switcher' => 'yes', |
| 190 | ), |
| 191 | ) |
| 192 | ); |
| 193 | |
| 194 | $element->start_controls_tabs( |
| 195 | 'premium_tooltip_tabs' |
| 196 | ); |
| 197 | |
| 198 | $this->add_tooltips_controls( $element ); |
| 199 | |
| 200 | $this->add_tooltips_style_controls( $element ); |
| 201 | |
| 202 | $this->add_tooltips_settings_controls( $element ); |
| 203 | |
| 204 | $element->end_controls_tabs(); |
| 205 | |
| 206 | $element->end_controls_section(); |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * Add tooltips content controls. |
| 211 | * |
| 212 | * @access private |
| 213 | * @since 4.10.4 |
| 214 | * |
| 215 | * @param object $element for current element. |
| 216 | */ |
| 217 | private function add_tooltips_controls( $element ) { |
| 218 | |
| 219 | $papro_activated = Helper_Functions::check_papro_version(); |
| 220 | |
| 221 | $element->start_controls_tab( |
| 222 | 'premium_tooltip_content_tab', |
| 223 | array( |
| 224 | 'label' => __( 'Content', 'premium-addons-for-elementor' ), |
| 225 | 'condition' => array( |
| 226 | 'premium_tooltip_switcher' => 'yes', |
| 227 | ), |
| 228 | ) |
| 229 | ); |
| 230 | |
| 231 | $element->add_control( |
| 232 | 'premium_tooltip_type', |
| 233 | array( |
| 234 | 'label' => __( 'Content', 'premium-addons-for-elementor' ), |
| 235 | 'type' => Controls_Manager::SELECT, |
| 236 | 'render_type' => 'template', |
| 237 | 'options' => array( |
| 238 | 'text' => __( 'Text', 'premium-addons-for-elementor' ), |
| 239 | 'lottie' => __( 'Lottie', 'premium-addons-for-elementor' ), |
| 240 | 'gallery' => apply_filters( 'pa_pro_label', __( 'Gallery (PRO)', 'premium-addons-for-elementor' ) ), |
| 241 | 'template' => apply_filters( 'pa_pro_label', __( 'Elementor Template (PRO)', 'premium-addons-for-elementor' ) ), |
| 242 | ), |
| 243 | 'default' => 'text', |
| 244 | 'condition' => array( |
| 245 | 'premium_tooltip_switcher' => 'yes', |
| 246 | ), |
| 247 | ) |
| 248 | ); |
| 249 | |
| 250 | $element->add_control( |
| 251 | 'premium_tooltip_text', |
| 252 | array( |
| 253 | 'label' => __( 'Content Text', 'premium-addons-for-elementor' ), |
| 254 | 'type' => Controls_Manager::TEXTAREA, |
| 255 | 'render_type' => 'template', |
| 256 | 'default' => __( 'Hi, I\'m a global tooltip.', 'premium-addons-for-elementor' ), |
| 257 | 'placeholder' => __( 'Hi, I\'m a global tooltip', 'premium-addons-for-elementor' ), |
| 258 | 'dynamic' => array( |
| 259 | 'active' => true, |
| 260 | ), |
| 261 | 'condition' => array( |
| 262 | 'premium_tooltip_switcher' => 'yes', |
| 263 | 'premium_tooltip_type' => 'text', |
| 264 | ), |
| 265 | ) |
| 266 | ); |
| 267 | |
| 268 | $element->add_control( |
| 269 | 'premium_tooltip_icon_switcher', |
| 270 | array( |
| 271 | 'label' => __( 'Add Icon', 'premium-addons-for-elementor' ), |
| 272 | 'type' => Controls_Manager::SWITCHER, |
| 273 | 'return_value' => 'yes', |
| 274 | 'prefix_class' => 'premium-global-tooltip-', |
| 275 | 'render_type' => 'template', |
| 276 | 'condition' => array( |
| 277 | 'premium_tooltip_switcher' => 'yes', |
| 278 | 'premium_tooltip_type' => 'text', |
| 279 | ), |
| 280 | ) |
| 281 | ); |
| 282 | |
| 283 | $element->add_control( |
| 284 | 'premium_tooltip_icon', |
| 285 | array( |
| 286 | 'label' => __( 'Icon', 'premium-addons-for-elementor' ), |
| 287 | 'type' => Controls_Manager::ICONS, |
| 288 | 'default' => array( |
| 289 | 'value' => 'fas fa-star', |
| 290 | 'library' => 'fa-solid', |
| 291 | ), |
| 292 | 'return_value' => 'yes', |
| 293 | 'render_type' => 'template', |
| 294 | 'condition' => array( |
| 295 | 'premium_tooltip_switcher' => 'yes', |
| 296 | 'premium_tooltip_type' => 'text', |
| 297 | 'premium_tooltip_icon_switcher' => 'yes', |
| 298 | ), |
| 299 | ) |
| 300 | ); |
| 301 | |
| 302 | $element->add_control( |
| 303 | 'premium_tooltip_lottie_url', |
| 304 | array( |
| 305 | 'label' => __( 'Animation JSON URL', 'premium-addons-for-elementor' ), |
| 306 | 'type' => Controls_Manager::TEXT, |
| 307 | 'dynamic' => array( 'active' => true ), |
| 308 | 'description' => 'Get JSON code URL from <a href="https://lottiefiles.com/" target="_blank">here</a>', |
| 309 | 'label_block' => true, |
| 310 | 'render_type' => 'template', |
| 311 | 'condition' => array( |
| 312 | 'premium_tooltip_switcher' => 'yes', |
| 313 | 'premium_tooltip_type' => 'lottie', |
| 314 | ), |
| 315 | ) |
| 316 | ); |
| 317 | |
| 318 | $element->add_control( |
| 319 | 'premium_tooltip_lottie_loop', |
| 320 | array( |
| 321 | 'label' => __( 'Loop', 'premium-addons-for-elementor' ), |
| 322 | 'type' => Controls_Manager::SWITCHER, |
| 323 | 'return_value' => 'true', |
| 324 | 'default' => 'true', |
| 325 | 'render_type' => 'template', |
| 326 | 'condition' => array( |
| 327 | 'premium_tooltip_switcher' => 'yes', |
| 328 | 'premium_tooltip_type' => 'lottie', |
| 329 | ), |
| 330 | ) |
| 331 | ); |
| 332 | |
| 333 | $element->add_control( |
| 334 | 'premium_tooltip_lottie_reverse', |
| 335 | array( |
| 336 | 'label' => __( 'Reverse', 'premium-addons-for-elementor' ), |
| 337 | 'type' => Controls_Manager::SWITCHER, |
| 338 | 'return_value' => 'true', |
| 339 | 'render_type' => 'template', |
| 340 | 'condition' => array( |
| 341 | 'premium_tooltip_switcher' => 'yes', |
| 342 | 'premium_tooltip_type' => 'lottie', |
| 343 | ), |
| 344 | ) |
| 345 | ); |
| 346 | |
| 347 | if ( ! $papro_activated ) { |
| 348 | $get_pro = Helper_Functions::get_campaign_link( 'https://premiumaddons.com/pro', 'tooltips-addon', 'wp-editor', 'get-pro' ); |
| 349 | |
| 350 | $element->add_control( |
| 351 | 'pro_notice', |
| 352 | array( |
| 353 | 'type' => Controls_Manager::RAW_HTML, |
| 354 | 'raw' => __( 'This option is available in Premium Addons Pro. ', 'premium-addons-for-elementor' ) . '<a href="' . esc_url( $get_pro ) . '" target="_blank">' . __( 'Upgrade now!', 'premium-addons-for-elementor' ) . '</a>', |
| 355 | 'content_classes' => 'papro-upgrade-notice', |
| 356 | 'condition' => array( |
| 357 | 'premium_tooltip_switcher' => 'yes', |
| 358 | 'premium_tooltip_type' => array( 'gallery', 'template' ), |
| 359 | ), |
| 360 | ) |
| 361 | ); |
| 362 | |
| 363 | } else { |
| 364 | do_action( 'pa_tooltips_type_controls', $element ); |
| 365 | } |
| 366 | |
| 367 | $element->add_control( |
| 368 | 'hide_tooltip_on', |
| 369 | array( |
| 370 | 'label' => __( 'Hide Tooltip On', 'premium-addons-for-elementor' ), |
| 371 | 'type' => Controls_Manager::SELECT2, |
| 372 | 'options' => Helper_Functions::get_all_breakpoints(), |
| 373 | 'separator' => 'before', |
| 374 | 'render' => 'template', |
| 375 | 'multiple' => true, |
| 376 | 'label_block' => true, |
| 377 | 'default' => array(), |
| 378 | 'condition' => array( |
| 379 | 'premium_tooltip_switcher' => 'yes', |
| 380 | ), |
| 381 | ) |
| 382 | ); |
| 383 | |
| 384 | $element->add_control( |
| 385 | 'pa_tooltip_tutorial', |
| 386 | array( |
| 387 | 'type' => Controls_Manager::RAW_HTML, |
| 388 | 'raw' => sprintf( '<a href="%s" target="_blank">%s</a>', 'https://www.youtube.com/watch?v=Ng4o0XojexI', __( 'Check the video tutorial »', 'premium-addons-for-elementor' ) ), |
| 389 | 'content_classes' => 'editor-pa-doc', |
| 390 | 'condition' => array( |
| 391 | 'premium_tooltip_switcher' => 'yes', |
| 392 | ), |
| 393 | ) |
| 394 | ); |
| 395 | |
| 396 | $element->end_controls_tab(); |
| 397 | } |
| 398 | |
| 399 | /** |
| 400 | * Add tooltips style controls. |
| 401 | * |
| 402 | * @access private |
| 403 | * @since 4.10.4 |
| 404 | * |
| 405 | * @param object $element for current element. |
| 406 | */ |
| 407 | private function add_tooltips_style_controls( $element ) { |
| 408 | |
| 409 | /** Start Style Tab. */ |
| 410 | $element->start_controls_tab( |
| 411 | 'premium_tooltip_style_tab', |
| 412 | array( |
| 413 | 'label' => __( 'Style', 'premium-addons-for-elementor' ), |
| 414 | 'condition' => array( |
| 415 | 'premium_tooltip_switcher' => 'yes', |
| 416 | ), |
| 417 | ) |
| 418 | ); |
| 419 | |
| 420 | /** Content Style */ |
| 421 | $element->add_control( |
| 422 | 'premium_tooltip_content_heading', |
| 423 | array( |
| 424 | 'label' => __( 'Content', 'premium-addons-for-elementor' ), |
| 425 | 'type' => Controls_Manager::HEADING, |
| 426 | 'separator' => 'before', |
| 427 | 'condition' => array( |
| 428 | 'premium_tooltip_switcher' => 'yes', |
| 429 | 'premium_tooltip_type!' => 'template', |
| 430 | ), |
| 431 | ) |
| 432 | ); |
| 433 | |
| 434 | /**Text Style */ |
| 435 | $element->add_control( |
| 436 | 'premium_tooltip_text_color', |
| 437 | array( |
| 438 | 'label' => __( 'Text Color', 'premium-addons-for-elementor' ), |
| 439 | 'type' => Controls_Manager::COLOR, |
| 440 | 'selectors' => array( |
| 441 | '.tooltipster-sidetip .tooltipster-box.tooltipster-box-{{ID}} .premium-tooltip-content-wrapper-{{ID}} .premium-tootltip-text' => 'color: {{VALUE}};', |
| 442 | ), |
| 443 | 'condition' => array( |
| 444 | 'premium_tooltip_switcher' => 'yes', |
| 445 | 'premium_tooltip_type' => 'text', |
| 446 | ), |
| 447 | ) |
| 448 | ); |
| 449 | |
| 450 | $element->add_group_control( |
| 451 | Group_Control_Typography::get_type(), |
| 452 | array( |
| 453 | 'name' => 'premium_tooltip_text_typo', |
| 454 | 'selector' => '.tooltipster-box.tooltipster-box-{{ID}} .premium-tooltip-content-wrapper-{{ID}} .premium-tootltip-text', |
| 455 | 'fields_options' => array( |
| 456 | 'line_height' => array( |
| 457 | 'responsive' => false, |
| 458 | ), |
| 459 | 'letter_spacing' => array( |
| 460 | 'responsive' => false, |
| 461 | ), |
| 462 | 'word_spacing' => array( |
| 463 | 'responsive' => false, |
| 464 | ), |
| 465 | ), |
| 466 | 'condition' => array( |
| 467 | 'premium_tooltip_switcher' => 'yes', |
| 468 | 'premium_tooltip_type' => 'text', |
| 469 | ), |
| 470 | ) |
| 471 | ); |
| 472 | |
| 473 | $element->add_group_control( |
| 474 | Group_Control_Text_Shadow::get_type(), |
| 475 | array( |
| 476 | 'name' => 'premium_tooltip_text_shadow', |
| 477 | 'selector' => '.tooltipster-box.tooltipster-box-{{ID}} .premium-tootltip-text', |
| 478 | 'condition' => array( |
| 479 | 'premium_tooltip_switcher' => 'yes', |
| 480 | 'premium_tooltip_type' => 'text', |
| 481 | ), |
| 482 | ) |
| 483 | ); |
| 484 | |
| 485 | /**Icon Style */ |
| 486 | $element->add_control( |
| 487 | 'premium_tooltip_icon_heading', |
| 488 | array( |
| 489 | 'label' => __( 'Icon', 'premium-addons-for-elementor' ), |
| 490 | 'type' => Controls_Manager::HEADING, |
| 491 | 'separator' => 'before', |
| 492 | 'condition' => array( |
| 493 | 'premium_tooltip_switcher' => 'yes', |
| 494 | 'premium_tooltip_type' => 'text', |
| 495 | 'premium_tooltip_icon_switcher' => 'yes', |
| 496 | ), |
| 497 | ) |
| 498 | ); |
| 499 | |
| 500 | $element->add_control( |
| 501 | 'premium_tooltip_icon_color', |
| 502 | array( |
| 503 | 'label' => __( 'Icon Color', 'premium-addons-for-elementor' ), |
| 504 | 'type' => Controls_Manager::COLOR, |
| 505 | 'selectors' => array( |
| 506 | '.tooltipster-sidetip .tooltipster-box.tooltipster-box-{{ID}} .premium-tootltip-icon i' => 'color: {{VALUE}};', |
| 507 | '.tooltipster-sidetip .tooltipster-box.tooltipster-box-{{ID}} .premium-tootltip-icon svg, .tooltipster-sidetip .tooltipster-box.tooltipster-box-{{ID}} .premium-tootltip-icon svg *' => 'fill: {{VALUE}};', |
| 508 | ), |
| 509 | 'condition' => array( |
| 510 | 'premium_tooltip_switcher' => 'yes', |
| 511 | 'premium_tooltip_type' => 'text', |
| 512 | 'premium_tooltip_icon_switcher' => 'yes', |
| 513 | |
| 514 | ), |
| 515 | ) |
| 516 | ); |
| 517 | |
| 518 | $element->add_control( |
| 519 | 'premium_tooltip_icon_size', |
| 520 | array( |
| 521 | 'label' => __( 'Icon Size', 'premium-addons-for-elementor' ), |
| 522 | 'type' => Controls_Manager::SLIDER, |
| 523 | 'range' => array( |
| 524 | 'px' => array( |
| 525 | 'min' => 0, |
| 526 | 'max' => 2000, |
| 527 | 'step' => 1, |
| 528 | ), |
| 529 | ), |
| 530 | 'selectors' => array( |
| 531 | '.tooltipster-sidetip .tooltipster-box.tooltipster-box-{{ID}} .premium-tootltip-icon i' => 'font-size: {{SIZE}}px;', |
| 532 | '.tooltipster-sidetip .tooltipster-box.tooltipster-box-{{ID}} .premium-tootltip-icon svg' => 'width: {{SIZE}}px; height:{{SIZE}}px', |
| 533 | ), |
| 534 | 'condition' => array( |
| 535 | 'premium_tooltip_switcher' => 'yes', |
| 536 | 'premium_tooltip_type' => 'text', |
| 537 | 'premium_tooltip_icon_switcher' => 'yes', |
| 538 | ), |
| 539 | ) |
| 540 | ); |
| 541 | |
| 542 | $element->add_group_control( |
| 543 | Group_Control_Text_Shadow::get_type(), |
| 544 | array( |
| 545 | 'name' => 'premium_tooltip_icon_shadow', |
| 546 | 'selector' => '.tooltipster-box.tooltipster-box-{{ID}} .premium-tootltip-icon', |
| 547 | 'condition' => array( |
| 548 | 'premium_tooltip_switcher' => 'yes', |
| 549 | 'premium_tooltip_icon_switcher' => 'yes', |
| 550 | 'premium_tooltip_type' => 'text', |
| 551 | 'premium_tooltip_icon[library]!' => 'svg', |
| 552 | ), |
| 553 | ) |
| 554 | ); |
| 555 | |
| 556 | /** Gallery Style */ |
| 557 | $element->add_responsive_control( |
| 558 | 'premium_tooltip_img_size', |
| 559 | array( |
| 560 | 'label' => __( 'Size (PX)', 'premium-addons-for-elementor' ), |
| 561 | 'type' => Controls_Manager::SLIDER, |
| 562 | 'range' => array( |
| 563 | 'px' => array( |
| 564 | 'min' => 0, |
| 565 | 'max' => 2000, |
| 566 | 'step' => 1, |
| 567 | ), |
| 568 | ), |
| 569 | 'default' => array( |
| 570 | 'unit' => 'px', |
| 571 | 'size' => 100, |
| 572 | ), |
| 573 | 'selectors' => array( |
| 574 | '.tooltipster-sidetip .tooltipster-box.tooltipster-box-{{ID}} .premium-tooltip-gallery, |
| 575 | .tooltipster-sidetip .tooltipster-box.tooltipster-box-{{ID}} .premium-tooltip-content-wrapper-{{ID}}, |
| 576 | .tooltipster-sidetip .tooltipster-box.tooltipster-box-{{ID}} .premium-tooltip-lottie ' => 'width: {{SIZE}}px; height:{{SIZE}}px', |
| 577 | ), |
| 578 | 'condition' => array( |
| 579 | 'premium_tooltip_switcher' => 'yes', |
| 580 | 'premium_tooltip_type' => array( 'gallery', 'lottie' ), |
| 581 | ), |
| 582 | ) |
| 583 | ); |
| 584 | |
| 585 | $element->add_control( |
| 586 | 'premium_tooltip_img_fit', |
| 587 | array( |
| 588 | 'label' => __( 'Image Fit', 'premium-addons-for-elementor' ), |
| 589 | 'type' => Controls_Manager::SELECT, |
| 590 | 'options' => array( |
| 591 | 'cover' => __( 'Cover', 'premium-addons-for-elementor' ), |
| 592 | 'fill' => __( 'Fill', 'premium-addons-for-elementor' ), |
| 593 | 'contain' => __( 'Contain', 'premium-addons-for-elementor' ), |
| 594 | ), |
| 595 | 'default' => 'cover', |
| 596 | 'selectors' => array( |
| 597 | '.tooltipster-sidetip .tooltipster-box.tooltipster-box-{{ID}} .premium-tooltip-gallery img' => 'object-fit: {{VALUE}};', |
| 598 | ), |
| 599 | 'condition' => array( |
| 600 | 'premium_tooltip_switcher' => 'yes', |
| 601 | 'premium_tooltip_type' => 'gallery', |
| 602 | ), |
| 603 | ) |
| 604 | ); |
| 605 | |
| 606 | /**Start Container Style */ |
| 607 | $element->add_control( |
| 608 | 'premium_tooltip_container_heading', |
| 609 | array( |
| 610 | 'label' => __( 'Container', 'premium-addons-for-elementor' ), |
| 611 | 'type' => Controls_Manager::HEADING, |
| 612 | 'separator' => 'before', |
| 613 | 'condition' => array( |
| 614 | 'premium_tooltip_switcher' => 'yes', |
| 615 | ), |
| 616 | ) |
| 617 | ); |
| 618 | |
| 619 | $element->add_group_control( |
| 620 | Premium_Background::get_type(), |
| 621 | array( |
| 622 | 'name' => 'premium_tooltip_container_bg', |
| 623 | 'types' => array( 'classic', 'gradient' ), |
| 624 | 'condition' => array( |
| 625 | 'premium_tooltip_switcher' => 'yes', |
| 626 | ), |
| 627 | 'selector' => '.tooltipster-box.tooltipster-box-{{ID}}', |
| 628 | ) |
| 629 | ); |
| 630 | |
| 631 | $element->add_group_control( |
| 632 | Group_Control_Border::get_type(), |
| 633 | array( |
| 634 | 'name' => 'premium_tooltip_container_border', |
| 635 | 'selector' => '.tooltipster-box.tooltipster-box-{{ID}}', |
| 636 | ) |
| 637 | ); |
| 638 | |
| 639 | $element->add_control( |
| 640 | 'premium_tooltip_container_border_radius', |
| 641 | array( |
| 642 | 'label' => __( 'Border Radius', 'premium-addons-for-elementor' ), |
| 643 | 'type' => Controls_Manager::SLIDER, |
| 644 | 'size_units' => array( 'px', 'em', '%' ), |
| 645 | 'selectors' => array( |
| 646 | '.tooltipster-box.tooltipster-box-{{ID}}' => 'border-radius: {{SIZE}}{{UNIT}}', |
| 647 | ), |
| 648 | ) |
| 649 | ); |
| 650 | |
| 651 | $element->add_group_control( |
| 652 | Group_Control_Box_Shadow::get_type(), |
| 653 | array( |
| 654 | 'name' => 'premium_tooltip_container_box_shadow', |
| 655 | 'selector' => '.tooltipster-sidetip .tooltipster-box.tooltipster-box-{{ID}}', |
| 656 | ) |
| 657 | ); |
| 658 | |
| 659 | $element->add_responsive_control( |
| 660 | 'premium_tooltip_container_padding', |
| 661 | array( |
| 662 | 'label' => __( 'Padding', 'premium-addons-for-elementor' ), |
| 663 | 'type' => Controls_Manager::DIMENSIONS, |
| 664 | 'size_units' => array( 'px', 'em', '%' ), |
| 665 | 'selectors' => array( |
| 666 | '.tooltipster-sidetip div.tooltipster-box-{{ID}} ' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 667 | ), |
| 668 | ) |
| 669 | ); |
| 670 | |
| 671 | /** Arrow Style */ |
| 672 | $element->add_control( |
| 673 | 'premium_tooltip_arrow_heading', |
| 674 | array( |
| 675 | 'label' => __( 'Arrow', 'premium-addons-for-elementor' ), |
| 676 | 'type' => Controls_Manager::HEADING, |
| 677 | 'separator' => 'before', |
| 678 | 'condition' => array( |
| 679 | 'premium_tooltip_switcher' => 'yes', |
| 680 | 'premium_tooltip_arrow' => 'yes', |
| 681 | ), |
| 682 | ) |
| 683 | ); |
| 684 | |
| 685 | $element->add_control( |
| 686 | 'premium_tooltip_arrow_color', |
| 687 | array( |
| 688 | 'label' => __( 'Arrow Color', 'premium-addons-for-elementor' ), |
| 689 | 'type' => Controls_Manager::COLOR, |
| 690 | 'selectors' => array( |
| 691 | '.premium-tooltipster-base.tooltipster-top .tooltipster-arrow-{{ID}} .tooltipster-arrow-background' => 'border-top-color: {{VALUE}};', |
| 692 | '.premium-tooltipster-base.tooltipster-bottom .tooltipster-arrow-{{ID}} .tooltipster-arrow-background' => 'border-bottom-color: {{VALUE}};', |
| 693 | '.premium-tooltipster-base.tooltipster-right .tooltipster-arrow-{{ID}} .tooltipster-arrow-background' => 'border-right-color: {{VALUE}};', |
| 694 | '.premium-tooltipster-base.tooltipster-left .tooltipster-arrow-{{ID}} .tooltipster-arrow-background' => 'border-left-color: {{VALUE}};', |
| 695 | ), |
| 696 | 'condition' => array( |
| 697 | 'premium_tooltip_switcher' => 'yes', |
| 698 | 'premium_tooltip_arrow' => 'yes', |
| 699 | ), |
| 700 | ) |
| 701 | ); |
| 702 | |
| 703 | $element->end_controls_tab(); |
| 704 | } |
| 705 | |
| 706 | /** |
| 707 | * Add tooltips style controls. |
| 708 | * |
| 709 | * @access private |
| 710 | * @since 4.10.4 |
| 711 | * |
| 712 | * @param object $element for current element. |
| 713 | */ |
| 714 | private function add_tooltips_settings_controls( $element ) { |
| 715 | |
| 716 | $element->start_controls_tab( |
| 717 | 'premium_tooltip_settings_tab', |
| 718 | array( |
| 719 | 'label' => __( 'Settings', 'premium-addons-for-elementor' ), |
| 720 | 'condition' => array( |
| 721 | 'premium_tooltip_switcher' => 'yes', |
| 722 | ), |
| 723 | ) |
| 724 | ); |
| 725 | |
| 726 | $element->add_control( |
| 727 | 'premium_tooltip_mouse_follow', |
| 728 | array( |
| 729 | 'label' => apply_filters( 'pa_pro_label', __( 'Mouse Follow (PRO)', 'premium-addons-for-elementor' ) ), |
| 730 | 'type' => Controls_Manager::SWITCHER, |
| 731 | 'render_type' => 'template', |
| 732 | 'condition' => array( |
| 733 | 'premium_tooltip_switcher' => 'yes', |
| 734 | ), |
| 735 | ) |
| 736 | ); |
| 737 | |
| 738 | $element->add_control( |
| 739 | 'premium_tooltip_arrow', |
| 740 | array( |
| 741 | 'label' => __( 'Show Arrow', 'premium-addons-for-elementor' ), |
| 742 | 'type' => Controls_Manager::SWITCHER, |
| 743 | 'label_on' => __( 'Show', 'premium-addons-for-elementor' ), |
| 744 | 'label_off' => __( 'Hide', 'premium-addons-for-elementor' ), |
| 745 | 'render_type' => 'template', |
| 746 | 'condition' => array( |
| 747 | 'premium_tooltip_switcher' => 'yes', |
| 748 | ), |
| 749 | ) |
| 750 | ); |
| 751 | |
| 752 | $element->add_control( |
| 753 | 'premium_tooltip_trigger', |
| 754 | array( |
| 755 | 'label' => __( 'Trigger', 'premium-addons-for-elementor' ), |
| 756 | 'type' => Controls_Manager::SELECT, |
| 757 | 'options' => array( |
| 758 | 'click' => __( 'Click', 'premium-addons-for-elementor' ), |
| 759 | 'hover' => __( 'Hover', 'premium-addons-for-elementor' ), |
| 760 | 'viewport' => __( 'On Viewport', 'premium-addons-for-elementor' ), |
| 761 | ), |
| 762 | 'default' => 'hover', |
| 763 | 'render_type' => 'template', |
| 764 | 'condition' => array( |
| 765 | 'premium_tooltip_switcher' => 'yes', |
| 766 | ), |
| 767 | ) |
| 768 | ); |
| 769 | |
| 770 | $element->add_control( |
| 771 | 'premium_tooltip_position', |
| 772 | array( |
| 773 | 'label' => __( 'Positon', 'premium-addons-for-elementor' ), |
| 774 | 'type' => Controls_Manager::TEXT, |
| 775 | 'description' => __( 'Sets the side of the tooltip. The value may one of the following: \'top\', \'bottom\', \'left\', \'right\'. It may also be an array containing one or more of these values. When using an array, the order of values is taken into account as order of fallbacks and the absence of a side disables it', 'premium-addons-for-elementor' ), |
| 776 | 'default' => 'top,bottom', |
| 777 | 'label_block' => true, |
| 778 | 'render_type' => 'template', |
| 779 | 'condition' => array( |
| 780 | 'premium_tooltip_switcher' => 'yes', |
| 781 | ), |
| 782 | ) |
| 783 | ); |
| 784 | |
| 785 | $element->add_control( |
| 786 | 'premium_tooltip_distance_position', |
| 787 | array( |
| 788 | 'label' => __( 'Spacing', 'premium-addons-for-elementor' ), |
| 789 | 'type' => Controls_Manager::NUMBER, |
| 790 | 'title' => __( 'The distance between the origin and the tooltip in pixels, default is 6', 'premium-addons-for-elementor' ), |
| 791 | 'default' => 6, |
| 792 | 'render_type' => 'template', |
| 793 | 'condition' => array( |
| 794 | 'premium_tooltip_switcher' => 'yes', |
| 795 | ), |
| 796 | ) |
| 797 | ); |
| 798 | |
| 799 | $element->add_responsive_control( |
| 800 | 'premium_tooltip_min_width', |
| 801 | array( |
| 802 | 'label' => __( 'Min Width', 'premium-addons-for-elementor' ), |
| 803 | 'type' => Controls_Manager::SLIDER, |
| 804 | 'render_type' => 'template', |
| 805 | 'devices' => array( 'desktop', 'tablet', 'mobile' ), |
| 806 | 'range' => array( |
| 807 | 'px' => array( |
| 808 | 'min' => 0, |
| 809 | 'max' => 800, |
| 810 | ), |
| 811 | ), |
| 812 | 'description' => __( 'Set a minimum width for the tooltip in pixels, default: 0 (auto width)', 'premium-addons-for-elementor' ), |
| 813 | 'condition' => array( |
| 814 | 'premium_tooltip_switcher' => 'yes', |
| 815 | ), |
| 816 | ) |
| 817 | ); |
| 818 | |
| 819 | $element->add_responsive_control( |
| 820 | 'premium_tooltip_max_width', |
| 821 | array( |
| 822 | 'label' => __( 'Max Width', 'premium-addons-for-elementor' ), |
| 823 | 'type' => Controls_Manager::SLIDER, |
| 824 | 'render_type' => 'template', |
| 825 | 'range' => array( |
| 826 | 'px' => array( |
| 827 | 'min' => 0, |
| 828 | 'max' => 800, |
| 829 | ), |
| 830 | ), |
| 831 | 'description' => __( 'Set a maximum width for the tooltip in pixels', 'premium-addons-for-elementor' ), |
| 832 | 'condition' => array( |
| 833 | 'premium_tooltip_switcher' => 'yes', |
| 834 | ), |
| 835 | ) |
| 836 | ); |
| 837 | |
| 838 | $element->add_responsive_control( |
| 839 | 'premium_tooltip_height', |
| 840 | array( |
| 841 | 'label' => __( 'Height', 'premium-addons-for-elementor' ), |
| 842 | 'type' => Controls_Manager::SLIDER, |
| 843 | 'size_units' => array( 'px', 'em', '%' ), |
| 844 | 'render_type' => 'template', |
| 845 | 'range' => array( |
| 846 | 'px' => array( |
| 847 | 'min' => 0, |
| 848 | 'max' => 500, |
| 849 | ), |
| 850 | 'em' => array( |
| 851 | 'min' => 0, |
| 852 | 'max' => 20, |
| 853 | ), |
| 854 | ), |
| 855 | 'label_block' => true, |
| 856 | 'selectors' => array( |
| 857 | '.tooltipster-box.tooltipster-box-{{ID}} .tooltipster-content .premium-tooltip-content-wrapper-{{ID}} ' => 'height: {{SIZE}}{{UNIT}};', |
| 858 | ), |
| 859 | 'condition' => array( |
| 860 | 'premium_tooltip_switcher' => 'yes', |
| 861 | ), |
| 862 | ) |
| 863 | ); |
| 864 | |
| 865 | $element->add_control( |
| 866 | 'premium_tooltip_anime', |
| 867 | array( |
| 868 | 'label' => __( 'Animation', 'premium-addons-for-elementor' ), |
| 869 | 'type' => Controls_Manager::SELECT, |
| 870 | 'options' => array( |
| 871 | 'fade' => __( 'Fade', 'premium-addons-for-elementor' ), |
| 872 | 'grow' => __( 'Grow', 'premium-addons-for-elementor' ), |
| 873 | 'swing' => __( 'Swing', 'premium-addons-for-elementor' ), |
| 874 | 'slide' => __( 'Slide', 'premium-addons-for-elementor' ), |
| 875 | 'fall' => __( 'Fall', 'premium-addons-for-elementor' ), |
| 876 | ), |
| 877 | 'default' => 'fade', |
| 878 | 'render_type' => 'template', |
| 879 | 'label_block' => true, |
| 880 | 'condition' => array( |
| 881 | 'premium_tooltip_switcher' => 'yes', |
| 882 | ), |
| 883 | ) |
| 884 | ); |
| 885 | |
| 886 | $element->add_control( |
| 887 | 'premium_tooltip_anime_dur', |
| 888 | array( |
| 889 | 'label' => __( 'Animation Duration', 'premium-addons-for-elementor' ), |
| 890 | 'type' => Controls_Manager::NUMBER, |
| 891 | 'title' => __( 'Set the animation duration in milliseconds, default is 350', 'premium-addons-for-elementor' ), |
| 892 | 'default' => 350, |
| 893 | 'render_type' => 'template', |
| 894 | 'condition' => array( |
| 895 | 'premium_tooltip_switcher' => 'yes', |
| 896 | ), |
| 897 | ) |
| 898 | ); |
| 899 | |
| 900 | $element->add_control( |
| 901 | 'premium_tooltip_delay', |
| 902 | array( |
| 903 | 'label' => __( 'Delay', 'premium-addons-for-elementor' ), |
| 904 | 'type' => Controls_Manager::NUMBER, |
| 905 | 'title' => __( 'Set the animation delay in milliseconds, default is 10', 'premium-addons-for-elementor' ), |
| 906 | 'default' => 10, |
| 907 | 'render_type' => 'template', |
| 908 | 'condition' => array( |
| 909 | 'premium_tooltip_switcher' => 'yes', |
| 910 | ), |
| 911 | ) |
| 912 | ); |
| 913 | |
| 914 | $element->add_control( |
| 915 | 'pa_tooltip_zindex', |
| 916 | array( |
| 917 | 'label' => __( 'Z-Index', 'premium-addons-for-elementor' ), |
| 918 | 'type' => Controls_Manager::NUMBER, |
| 919 | 'description' => __( 'Set the z-index of the tooltip. Default is 9999999', 'premium-addons-for-elementor' ), |
| 920 | 'render_type' => 'template', |
| 921 | 'condition' => array( |
| 922 | 'premium_tooltip_switcher' => 'yes', |
| 923 | ), |
| 924 | ) |
| 925 | ); |
| 926 | |
| 927 | $element->end_controls_tab(); |
| 928 | } |
| 929 | |
| 930 | /** |
| 931 | * Render Global badge output in the editor. |
| 932 | * |
| 933 | * Written as a Backbone JavaScript template and used to generate the live preview. |
| 934 | * |
| 935 | * @since 2.2.8 |
| 936 | * @access public |
| 937 | * |
| 938 | * @param string $template for current template. |
| 939 | * @param object $element for current element. |
| 940 | */ |
| 941 | public function print_template( $template, $element ) { |
| 942 | |
| 943 | if ( ! $template && 'widget' === $element->get_type() ) { |
| 944 | return; |
| 945 | } |
| 946 | |
| 947 | $old_template = $template; |
| 948 | ob_start(); |
| 949 | ?> |
| 950 | <# |
| 951 | var isEnabled = 'yes' === settings.premium_tooltip_switcher ? true : false; |
| 952 | |
| 953 | if ( isEnabled ) { |
| 954 | |
| 955 | var type = settings.premium_tooltip_type, |
| 956 | tooltipContent = {}; |
| 957 | |
| 958 | view.addRenderAttribute( 'gTooltipshtml', { |
| 959 | id: 'tooltip_content-' + view.getID(), |
| 960 | class: 'premium-global-tooltip-content premium-tooltip-content-wrapper-' + view.getID(), |
| 961 | }); |
| 962 | |
| 963 | view.addRenderAttribute( 'gTooltipTemp', { |
| 964 | class: 'premium-gtooltips-temp premium-global-tooltips-wrapper-temp-' + view.getID(), |
| 965 | style: 'display: none' |
| 966 | }); |
| 967 | |
| 968 | if ( 'template' === type ) { |
| 969 | var templateTitle = '' === settings.premium_tooltip_template ? settings.live_temp_content : settings.premium_tooltip_template; |
| 970 | |
| 971 | view.addRenderAttribute( 'gTooltipshtml', { |
| 972 | 'data-template-id': templateTitle, |
| 973 | }); |
| 974 | } |
| 975 | |
| 976 | #> |
| 977 | <div {{{ view.getRenderAttributeString( 'gTooltipTemp' ) }}} > |
| 978 | <div {{{ view.getRenderAttributeString( 'gTooltipshtml' ) }}}> |
| 979 | <# |
| 980 | switch ( type ) { |
| 981 | case 'text': |
| 982 | #> |
| 983 | <span class="premium-tootltip-text"> |
| 984 | |
| 985 | {{{ elementor.helpers.sanitize( settings.premium_tooltip_text ) }}} |
| 986 | <# |
| 987 | if ( 'yes' === settings.premium_tooltip_icon_switcher ) { |
| 988 | var tooltipIconHTML = elementor.helpers.renderIcon( view, settings.premium_tooltip_icon, { 'aria-hidden': true }, 'i' , 'object'); |
| 989 | |
| 990 | view.addRenderAttribute( 'gTooltipsIconHolder', { |
| 991 | class: 'premium-tootltip-icon', |
| 992 | }); |
| 993 | #> |
| 994 | <span {{{ view.getRenderAttributeString( 'gTooltipsIconHolder' ) }}} > {{{tooltipIconHTML.value}}}</span> |
| 995 | <# |
| 996 | } |
| 997 | #> |
| 998 | </span> |
| 999 | <# |
| 1000 | break; |
| 1001 | |
| 1002 | case 'gallery': |
| 1003 | var gallery = settings.premium_tooltip_gallery; |
| 1004 | |
| 1005 | if( ! gallery[0] ) |
| 1006 | break; |
| 1007 | |
| 1008 | tooltipContent = gallery; |
| 1009 | view.addRenderAttribute( 'gTooltipsGallery', { |
| 1010 | src: gallery[0]['url'], |
| 1011 | }); |
| 1012 | #> |
| 1013 | <span class="premium-tooltip-gallery"><img {{{ view.getRenderAttributeString( 'gTooltipsGallery' ) }}}></span> |
| 1014 | <# |
| 1015 | break; |
| 1016 | |
| 1017 | case 'lottie': |
| 1018 | view.addRenderAttribute( 'gTooltipsLottie', { |
| 1019 | class: 'premium-lottie-animation premium-tooltip-lottie', |
| 1020 | 'data-lottie-url': settings.premium_tooltip_lottie_url, |
| 1021 | 'data-lottie-loop': settings.premium_tooltip_lottie_loop, |
| 1022 | 'data-lottie-reverse': settings.premium_tooltip_lottie_reverse, |
| 1023 | }); |
| 1024 | #> |
| 1025 | <div {{{ view.getRenderAttributeString( 'gTooltipsLottie' ) }}} ></div> |
| 1026 | <# |
| 1027 | break; |
| 1028 | } |
| 1029 | #> |
| 1030 | </div> |
| 1031 | </div> |
| 1032 | <# |
| 1033 | |
| 1034 | var maxWidth = { |
| 1035 | desktop: '' !== settings.premium_tooltip_max_width.size ? settings.premium_tooltip_max_width.size : null, |
| 1036 | mobile: '' !== settings.premium_tooltip_max_width_mobile.size ? settings.premium_tooltip_max_width_mobile.size : null, |
| 1037 | tablet: '' !== settings.premium_tooltip_max_width_tablet.size ? settings.premium_tooltip_max_width_tablet.size : null, |
| 1038 | }, |
| 1039 | minWidth = { |
| 1040 | desktop: '' !== settings.premium_tooltip_min_width.size ? settings.premium_tooltip_min_width.size : 0, |
| 1041 | mobile: '' !== settings.premium_tooltip_min_width_mobile.size ? settings.premium_tooltip_min_width_mobile.size : 0, |
| 1042 | tablet: '' !== settings.premium_tooltip_min_width_tablet.size ? settings.premium_tooltip_min_width_tablet.size : 0, |
| 1043 | }, |
| 1044 | tooltip_settings = { |
| 1045 | type: type, |
| 1046 | content: tooltipContent, |
| 1047 | minWidth: minWidth, |
| 1048 | maxWidth: maxWidth, |
| 1049 | zindex: settings.pa_tooltip_zindex, |
| 1050 | target: settings.pa_tooltip_target, |
| 1051 | anime: settings.premium_tooltip_anime, |
| 1052 | trigger: settings.premium_tooltip_trigger, |
| 1053 | side: settings.premium_tooltip_position, |
| 1054 | arrow: 'yes' === settings.premium_tooltip_arrow ? true : false, |
| 1055 | distance: '' !== settings.premium_tooltip_distance_position ? settings.premium_tooltip_distance_position : 6, |
| 1056 | duration: '' !== settings.premium_tooltip_anime_dur ? settings.premium_tooltip_anime_dur : 350, |
| 1057 | delay: '' !== settings.premium_tooltip_anime_delay ? settings.premium_tooltip_anime_delay : 10, |
| 1058 | hideOn: settings.hide_tooltip_on, |
| 1059 | }; |
| 1060 | |
| 1061 | if( settings.pa_tooltip_class ) { |
| 1062 | |
| 1063 | tooltip_settings.uniqueClass = settings.pa_tooltip_class; |
| 1064 | tooltip_settings.follow_mouse = '' != settings.pa_tooltip_class && 'yes' === settings.premium_tooltip_mouse_follow; |
| 1065 | |
| 1066 | if ( '' != settings.pa_tooltip_class ) { |
| 1067 | tooltip_settings.isTourStarter = 'yes' === settings.is_tour_starter; |
| 1068 | } |
| 1069 | |
| 1070 | } else { |
| 1071 | |
| 1072 | tooltip_settings.follow_mouse = 'yes' === settings.premium_tooltip_mouse_follow; |
| 1073 | } |
| 1074 | |
| 1075 | if ( '' !== settings.pa_tooltip_class ) { |
| 1076 | tooltip_settings.isTourStarter = 'yes' === settings.is_tour_starter; |
| 1077 | } |
| 1078 | |
| 1079 | view.addRenderAttribute( 'gTooltips', { |
| 1080 | 'id': 'premium-global-tooltips-' + view.getID(), |
| 1081 | 'class': 'premium-global-tooltips-wrapper', |
| 1082 | 'data-tooltip_settings': JSON.stringify( tooltip_settings ) |
| 1083 | }); |
| 1084 | #> |
| 1085 | <div {{{ view.getRenderAttributeString( 'gTooltips' ) }}}></div> |
| 1086 | <# |
| 1087 | } |
| 1088 | #> |
| 1089 | |
| 1090 | <?php |
| 1091 | |
| 1092 | $slider_content = ob_get_contents(); |
| 1093 | ob_end_clean(); |
| 1094 | $template = $slider_content . $old_template; |
| 1095 | return $template; |
| 1096 | } |
| 1097 | |
| 1098 | /** |
| 1099 | * Render Global Tooltip output on the frontend. |
| 1100 | * |
| 1101 | * Written in PHP and used to generate the final HTML. |
| 1102 | * |
| 1103 | * @since 1.0.0 |
| 1104 | * @access public |
| 1105 | * @param object $element for current element. |
| 1106 | */ |
| 1107 | public function before_render( $element ) { |
| 1108 | |
| 1109 | $element_type = $element->get_type(); |
| 1110 | |
| 1111 | $elem_id = $element->get_id(); |
| 1112 | |
| 1113 | $id = apply_filters( 'pa_tooltips_dynamic', false ) ? wp_rand( 0, 1000 ) : $elem_id; |
| 1114 | |
| 1115 | $settings = $element->get_settings_for_display(); |
| 1116 | |
| 1117 | $papro_activated = Helper_Functions::check_papro_version(); |
| 1118 | |
| 1119 | $tooltips_enabled = $element->get_settings_for_display( 'premium_tooltip_switcher' ); |
| 1120 | |
| 1121 | if ( 'yes' === $tooltips_enabled ) { |
| 1122 | |
| 1123 | if ( ! $papro_activated && ( 'gallery' === $settings['premium_tooltip_type'] || 'template' === $settings['premium_tooltip_type'] || 'yes' === $settings['premium_tooltip_mouse_follow'] ) ) { |
| 1124 | return; |
| 1125 | } |
| 1126 | |
| 1127 | $type = $settings['premium_tooltip_type']; |
| 1128 | $content = ''; |
| 1129 | |
| 1130 | ?> |
| 1131 | <div class="premium-gtooltips-temp premium-global-tooltips-wrapper-temp-<?php echo esc_attr( $id ); ?>" style="display: none;"> |
| 1132 | <div id="tooltip_content-<?php echo esc_attr( $id ); ?>" class="premium-global-tooltip-content premium-tooltip-content-wrapper-<?php echo esc_attr( $id ); ?>"> |
| 1133 | <?php |
| 1134 | switch ( $type ) { |
| 1135 | |
| 1136 | case 'text': |
| 1137 | ?> |
| 1138 | <span class="premium-tootltip-text"> |
| 1139 | <?php |
| 1140 | echo wp_kses_post( $settings['premium_tooltip_text'] ); |
| 1141 | |
| 1142 | if ( 'yes' === $settings['premium_tooltip_icon_switcher'] ) { |
| 1143 | $icon = $settings['premium_tooltip_icon']; |
| 1144 | ?> |
| 1145 | <span class="premium-tootltip-icon"> |
| 1146 | <?php |
| 1147 | Icons_Manager::render_icon( |
| 1148 | $icon, |
| 1149 | array( |
| 1150 | 'aria-hidden' => 'true', |
| 1151 | ) |
| 1152 | ); |
| 1153 | ?> |
| 1154 | </span> |
| 1155 | <?php |
| 1156 | } |
| 1157 | ?> |
| 1158 | </span> |
| 1159 | <?php |
| 1160 | break; |
| 1161 | |
| 1162 | case 'gallery': |
| 1163 | $gallery = $settings['premium_tooltip_gallery']; |
| 1164 | $content = $gallery; |
| 1165 | ?> |
| 1166 | <span class="premium-tooltip-gallery"><img src="<?php echo esc_url( $gallery[0]['url'] ); ?>"></span> |
| 1167 | <?php |
| 1168 | break; |
| 1169 | |
| 1170 | case 'lottie': |
| 1171 | $lottie = array( |
| 1172 | 'url' => $settings['premium_tooltip_lottie_url'], |
| 1173 | 'loop' => $settings['premium_tooltip_lottie_loop'], |
| 1174 | 'reverse' => $settings['premium_tooltip_lottie_reverse'], |
| 1175 | ); |
| 1176 | |
| 1177 | ?> |
| 1178 | <div class="premium-lottie-animation premium-tooltip-lottie" data-lottie-url="<?php echo esc_url( $lottie['url'] ); ?>" data-lottie-loop="<?php echo esc_attr( $lottie['loop'] ); ?>" data-lottie-reverse="<?php echo esc_attr( $lottie['reverse'] ); ?>"></div> |
| 1179 | <?php |
| 1180 | break; |
| 1181 | |
| 1182 | default: |
| 1183 | $content = empty( $settings['premium_tooltip_template'] ) ? $settings['live_temp_content'] : $settings['premium_tooltip_template']; |
| 1184 | echo Helper_Functions::render_elementor_template( $content ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1185 | } |
| 1186 | ?> |
| 1187 | </div> |
| 1188 | </div> |
| 1189 | <?php |
| 1190 | |
| 1191 | $min_width = array( |
| 1192 | 'desktop' => ! empty( $settings['premium_tooltip_min_width']['size'] ) ? $settings['premium_tooltip_min_width']['size'] : 0, |
| 1193 | 'mobile' => ! empty( $settings['premium_tooltip_min_width_mobile']['size'] ) ? $settings['premium_tooltip_min_width_mobile']['size'] : 0, |
| 1194 | 'tablet' => ! empty( $settings['premium_tooltip_min_width_tablet']['size'] ) ? $settings['premium_tooltip_min_width_tablet']['size'] : 0, |
| 1195 | ); |
| 1196 | |
| 1197 | $max_width = array( |
| 1198 | 'desktop' => ! empty( $settings['premium_tooltip_max_width']['size'] ) ? $settings['premium_tooltip_max_width']['size'] : null, |
| 1199 | 'mobile' => ! empty( $settings['premium_tooltip_max_width_mobile']['size'] ) ? $settings['premium_tooltip_max_width_mobile']['size'] : null, |
| 1200 | 'tablet' => ! empty( $settings['premium_tooltip_max_width_tablet']['size'] ) ? $settings['premium_tooltip_max_width_tablet']['size'] : null, |
| 1201 | ); |
| 1202 | |
| 1203 | $tooltip_settings = array( // escape it all |
| 1204 | 'type' => $type, |
| 1205 | 'content' => $content, // needs escaping |
| 1206 | 'minWidth' => $min_width, |
| 1207 | 'maxWidth' => $max_width, |
| 1208 | 'zindex' => $settings['pa_tooltip_zindex'], |
| 1209 | 'target' => $settings['pa_tooltip_target'], |
| 1210 | 'anime' => $settings['premium_tooltip_anime'], |
| 1211 | 'trigger' => $settings['premium_tooltip_trigger'], |
| 1212 | 'side' => $settings['premium_tooltip_position'], |
| 1213 | 'arrow' => 'yes' === $settings['premium_tooltip_arrow'], |
| 1214 | 'distance' => ! empty( $settings['premium_tooltip_distance_position'] ) ? $settings['premium_tooltip_distance_position'] : 6, |
| 1215 | 'duration' => ! empty( $settings['premium_tooltip_anime_dur'] ) ? $settings['premium_tooltip_anime_dur'] : 350, |
| 1216 | 'delay' => ! empty( $settings['premium_tooltip_anime_delay'] ) ? $settings['premium_tooltip_anime_delay'] : 10, |
| 1217 | 'hideOn' => $settings['hide_tooltip_on'], |
| 1218 | 'elemID' => $elem_id, |
| 1219 | ); |
| 1220 | |
| 1221 | if ( isset( $settings['pa_tooltip_class'] ) ) { |
| 1222 | |
| 1223 | $tooltip_settings['uniqueClass'] = $settings['pa_tooltip_class']; |
| 1224 | $tooltip_settings['follow_mouse'] = empty( $settings['pa_tooltip_class'] ) && 'yes' === $settings['premium_tooltip_mouse_follow']; |
| 1225 | |
| 1226 | if ( ! empty( $settings['pa_tooltip_class'] ) ) { |
| 1227 | $tooltip_settings['isTourStarter'] = 'yes' === $settings['is_tour_starter']; |
| 1228 | } |
| 1229 | } else { |
| 1230 | |
| 1231 | $tooltip_settings['follow_mouse'] = 'yes' === $settings['premium_tooltip_mouse_follow']; |
| 1232 | } |
| 1233 | |
| 1234 | $element->add_render_attribute( '_wrapper', 'data-tooltip-id', $id ); |
| 1235 | |
| 1236 | $element->add_render_attribute( '_wrapper', 'data-tooltip_settings', wp_json_encode( $tooltip_settings ) ); |
| 1237 | |
| 1238 | $element->add_render_attribute( |
| 1239 | 'gTooltips_temps' . $id, |
| 1240 | array( |
| 1241 | 'id' => 'premium-global-tooltips-temp-' . esc_attr( $id ), |
| 1242 | 'data-tooltip_settings' => wp_json_encode( $tooltip_settings ), |
| 1243 | ) |
| 1244 | ); |
| 1245 | |
| 1246 | if ( 'widget' === $element_type && \Elementor\Plugin::instance()->editor->is_edit_mode() ) { |
| 1247 | ?> |
| 1248 | <div <?php $element->print_render_attribute_string( 'gTooltips_temps' . $id ); ?>></div> |
| 1249 | <?php |
| 1250 | } |
| 1251 | } |
| 1252 | } |
| 1253 | |
| 1254 | /** |
| 1255 | * Check Script Enqueue |
| 1256 | * |
| 1257 | * Check if the script files should be loaded. |
| 1258 | * |
| 1259 | * @since 2.6.3 |
| 1260 | * @access public |
| 1261 | * |
| 1262 | * @param object $element for current element. |
| 1263 | */ |
| 1264 | public function check_script_enqueue( $element ) { |
| 1265 | |
| 1266 | if ( self::$load_script ) { |
| 1267 | return; |
| 1268 | } |
| 1269 | |
| 1270 | $settings = $element->get_active_settings(); |
| 1271 | |
| 1272 | if ( ! empty( $settings['premium_tooltip_switcher'] ) ) { |
| 1273 | |
| 1274 | $this->enqueue_styles(); |
| 1275 | $this->enqueue_scripts(); |
| 1276 | |
| 1277 | self::$load_script = true; |
| 1278 | |
| 1279 | remove_action( 'elementor/frontend/before_render', array( $this, 'check_script_enqueue' ) ); |
| 1280 | } |
| 1281 | } |
| 1282 | |
| 1283 | /** |
| 1284 | * Creates and returns an instance of the class |
| 1285 | * |
| 1286 | * @since 4.2.5 |
| 1287 | * @access public |
| 1288 | * |
| 1289 | * @return object |
| 1290 | */ |
| 1291 | public static function get_instance() { |
| 1292 | |
| 1293 | if ( ! isset( self::$instance ) ) { |
| 1294 | |
| 1295 | self::$instance = new self(); |
| 1296 | |
| 1297 | } |
| 1298 | |
| 1299 | return self::$instance; |
| 1300 | } |
| 1301 | } |
| 1302 |