PluginProbe
Elementor Website Builder – more than just a page builder / 3.21.0-beta2
Elementor Website Builder – more than just a page builder v3.21.0-beta2
4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 All 456 releases
← All changes | modules/nested-tabs/widgets/nested-tabs.php +199 -171 4.1.5 → 3.21.0-beta2 View file →
@@ -16,17 +16,13 @@
16 16 use Elementor\Plugin;
17 17 use Elementor\Repeater;
18 18
19 19 if ( ! defined( 'ABSPATH' ) ) {
20 - exit; // Exit if accessed directly.
20 + exit; // Exit if accessed directly
21 21 }
22 22
23 23 class NestedTabs extends Widget_Nested_Base {
24 24
25 - private $tab_item_settings = [];
26 - private $optimized_markup = null;
27 - private $widget_container_selector = '';
28 -
29 25 public function get_name() {
30 26 return 'nested-tabs';
31 27 }
32 28
@@ -41,29 +37,13 @@
41 37 public function get_keywords() {
42 38 return [ 'nested', 'tabs', 'accordion', 'toggle' ];
43 39 }
44 40
45 - public function get_style_depends(): array {
46 - return [ 'widget-nested-tabs' ];
47 - }
48 -
49 - public function has_widget_inner_wrapper(): bool {
50 - return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
51 - }
52 -
53 - public function show_in_panel(): bool {
54 - return Plugin::$instance->experiments->is_feature_active( 'nested-elements', true );
55 - }
56 -
57 41 protected function tab_content_container( int $index ) {
58 42 return [
59 43 'elType' => 'container',
60 44 'settings' => [
61 - '_title' => sprintf(
62 - /* translators: %d: Tab index. */
63 - __( 'Tab #%d', 'elementor' ),
64 - $index
65 - ),
45 + '_title' => sprintf( __( 'Tab #%s', 'elementor' ), $index ),
66 46 'content_width' => 'full',
67 47 ],
68 48 ];
69 49 }
@@ -80,9 +60,8 @@
80 60 return 'tab_title';
81 61 }
82 62
83 63 protected function get_default_children_title() {
84 - /* translators: %d: Tab index. */
85 64 return esc_html__( 'Tab #%d', 'elementor' );
86 65 }
87 66
88 67 protected function get_default_children_placeholder_selector() {
@@ -93,21 +72,16 @@
93 72 return 'elementor-widget-n-tabs';
94 73 }
95 74
96 75 protected function register_controls() {
97 - if ( null === $this->optimized_markup ) {
98 - $this->optimized_markup = Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ) && ! $this->has_widget_inner_wrapper();
99 - $this->widget_container_selector = $this->optimized_markup ? '' : ' > .elementor-widget-container';
100 - }
101 -
102 76 $start = is_rtl() ? 'right' : 'left';
103 77 $end = is_rtl() ? 'left' : 'right';
104 78 $start_logical = is_rtl() ? 'end' : 'start';
105 79 $end_logical = is_rtl() ? 'start' : 'end';
106 - $heading_selector_non_touch_device = "{{WRAPPER}}.elementor-widget-n-tabs{$this->widget_container_selector} > .e-n-tabs[data-touch-mode='false'] > .e-n-tabs-heading";
107 - $heading_selector_touch_device = "{{WRAPPER}}.elementor-widget-n-tabs{$this->widget_container_selector} > .e-n-tabs[data-touch-mode='true'] > .e-n-tabs-heading";
108 - $heading_selector = "{{WRAPPER}}.elementor-widget-n-tabs{$this->widget_container_selector} > .e-n-tabs > .e-n-tabs-heading";
109 - $content_selector = ":where( {{WRAPPER}}.elementor-widget-n-tabs{$this->widget_container_selector} > .e-n-tabs > .e-n-tabs-content ) > .e-con";
80 + $heading_selector_non_touch_device = '{{WRAPPER}} > .elementor-widget-container > .e-n-tabs[data-touch-mode="false"] > .e-n-tabs-heading';
81 + $heading_selector_touch_device = '{{WRAPPER}} > .elementor-widget-container > .e-n-tabs[data-touch-mode="true"] > .e-n-tabs-heading';
82 + $heading_selector = '{{WRAPPER}} > .elementor-widget-container > .e-n-tabs > .e-n-tabs-heading';
83 + $content_selector = ':where( {{WRAPPER}} > .elementor-widget-container > .e-n-tabs > .e-n-tabs-content ) > .e-con';
110 84
111 85 $this->start_controls_section( 'section_tabs', [
112 86 'label' => esc_html__( 'Tabs', 'elementor' ),
113 87 ] );
@@ -183,9 +157,9 @@
183 157 'tab_title' => esc_html__( 'Tab #3', 'elementor' ),
184 158 ],
185 159 ],
186 160 'title_field' => '{{{ tab_title }}}',
187 - 'button_text' => esc_html__( 'Add Tab', 'elementor' ),
161 + 'button_text' => 'Add Tab',
188 162 ] );
189 163
190 164 $styling_block_start = '--n-tabs-direction: column; --n-tabs-heading-direction: row; --n-tabs-heading-width: initial; --n-tabs-title-flex-basis: content; --n-tabs-title-flex-shrink: 0;';
191 165 $styling_block_end = '--n-tabs-direction: column-reverse; --n-tabs-heading-direction: row; --n-tabs-heading-width: initial; --n-tabs-title-flex-basis: content; --n-tabs-title-flex-shrink: 0';
@@ -227,9 +201,8 @@
227 201 ],
228 202 'selectors' => [
229 203 '{{WRAPPER}}' => '{{VALUE}}',
230 204 ],
231 - 'control_type' => 'content',
232 205 ] );
233 206
234 207 $this->add_responsive_control( 'tabs_justify_horizontal', [
235 208 'label' => esc_html__( 'Justify', 'elementor' ),
@@ -504,9 +477,9 @@
504 477 [
505 478 'name' => 'tabs_title_background_color',
506 479 'types' => [ 'classic', 'gradient' ],
507 480 'exclude' => [ 'image' ],
508 - 'selector' => "{{WRAPPER}}{$this->widget_container_selector} > .e-n-tabs > .e-n-tabs-heading > .e-n-tab-title[aria-selected='false']:not( :hover )",
481 + 'selector' => '{{WRAPPER}} > .elementor-widget-container > .e-n-tabs > .e-n-tabs-heading > .e-n-tab-title[aria-selected="false"]:not( :hover )',
509 482 'fields_options' => [
510 483 'color' => [
511 484 'label' => esc_html__( 'Background Color', 'elementor' ),
512 485 'selectors' => [
@@ -536,8 +509,9 @@
536 509 $this->add_group_control(
537 510 Group_Control_Box_Shadow::get_type(),
538 511 [
539 512 'name' => 'tabs_title_box_shadow',
513 + 'label' => esc_html__( 'Shadow', 'elementor' ),
540 514 'separator' => 'after',
541 515 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"false\"]:not( :hover )",
542 516 ]
543 517 );
@@ -594,8 +568,9 @@
594 568 $this->add_group_control(
595 569 Group_Control_Box_Shadow::get_type(),
596 570 [
597 571 'name' => 'tabs_title_box_shadow_hover',
572 + 'label' => esc_html__( 'Shadow', 'elementor' ),
598 573 'separator' => 'after',
599 574 'selector' => "{$heading_selector_non_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
600 575 ]
601 576 );
@@ -678,8 +653,9 @@
678 653 $this->add_group_control(
679 654 Group_Control_Box_Shadow::get_type(),
680 655 [
681 656 'name' => 'tabs_title_box_shadow_active',
657 + 'label' => esc_html__( 'Shadow', 'elementor' ),
682 658 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"true\"], {$heading_selector_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
683 659 ]
684 660 );
685 661
@@ -758,8 +734,13 @@
758 734 Group_Control_Text_Shadow::get_type(),
759 735 [
760 736 'name' => 'title_text_shadow',
761 737 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"false\"]:not( :hover )",
738 + 'fields_options' => [
739 + 'text_shadow_type' => [
740 + 'label' => esc_html__( 'Shadow', 'elementor' ),
741 + ],
742 + ],
762 743 ]
763 744 );
764 745
765 746 $this->add_group_control(
@@ -766,8 +747,13 @@
766 747 Group_Control_Text_Stroke::get_type(),
767 748 [
768 749 'name' => 'title_text_stroke',
769 750 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"false\"]:not( :hover ) :is( span, a, i )",
751 + 'fields_options' => [
752 + 'text_stroke_type' => [
753 + 'label' => esc_html__( 'Stroke', 'elementor' ),
754 + ],
755 + ],
770 756 ]
771 757 );
772 758
773 759 $this->end_controls_tab();
@@ -794,8 +780,14 @@
794 780 Group_Control_Text_Shadow::get_type(),
795 781 [
796 782 'name' => 'title_text_shadow_hover',
797 783 'selector' => "{$heading_selector_non_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
784 + 'fields_options' => [
785 + 'text_shadow_type' => [
786 + 'label' => esc_html__( 'Shadow', 'elementor' ),
787 + ],
788 + ],
789 +
798 790 ]
799 791 );
800 792
801 793 $this->add_group_control(
@@ -802,8 +794,13 @@
802 794 Group_Control_Text_Stroke::get_type(),
803 795 [
804 796 'name' => 'title_text_stroke_hover',
805 797 'selector' => "{$heading_selector_non_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover :is( span, a, i )",
798 + 'fields_options' => [
799 + 'text_stroke_type' => [
800 + 'label' => esc_html__( 'Stroke', 'elementor' ),
801 + ],
802 + ],
806 803 ]
807 804 );
808 805
809 806 $this->end_controls_tab();
@@ -830,8 +827,13 @@
830 827 Group_Control_Text_Shadow::get_type(),
831 828 [
832 829 'name' => 'title_text_shadow_active',
833 830 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"true\"], {$heading_selector_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover",
831 + 'fields_options' => [
832 + 'text_shadow_type' => [
833 + 'label' => esc_html__( 'Shadow', 'elementor' ),
834 + ],
835 + ],
834 836 ]
835 837 );
836 838
837 839 $this->add_group_control(
@@ -838,8 +840,13 @@
838 840 Group_Control_Text_Stroke::get_type(),
839 841 [
840 842 'name' => 'title_text_stroke_active',
841 843 'selector' => "{$heading_selector} > .e-n-tab-title[aria-selected=\"true\"] :is( span, a, i ), {$heading_selector_touch_device} > .e-n-tab-title[aria-selected=\"false\"]:hover :is( span, a, i )",
844 + 'fields_options' => [
845 + 'text_stroke_type' => [
846 + 'label' => esc_html__( 'Stroke', 'elementor' ),
847 + ],
848 + ],
842 849 ]
843 850 );
844 851
845 852 $this->end_controls_tab();
@@ -1064,9 +1071,9 @@
1064 1071
1065 1072 $this->end_controls_section();
1066 1073 }
1067 1074
1068 - protected function render_tab_titles_html( $item_settings ): void {
1075 + protected function render_tab_titles_html( $item_settings ): string {
1069 1076 $setting_key = $this->get_repeater_setting_key( 'tab_title', 'tabs', $item_settings['index'] );
1070 1077 $title = $item_settings['item']['tab_title'];
1071 1078 $css_classes = [ 'e-n-tab-title' ];
1072 1079
@@ -1075,9 +1082,8 @@
1075 1082 }
1076 1083
1077 1084 $this->add_render_attribute( $setting_key, [
1078 1085 'id' => $item_settings['tab_id'],
1079 - 'data-tab-title-id' => $item_settings['tab_title_id'],
1080 1086 'class' => $css_classes,
1081 1087 'aria-selected' => 1 === $item_settings['tab_count'] ? 'true' : 'false',
1082 1088 'data-tab-index' => $item_settings['tab_count'],
1083 1089 'role' => 'tab',
@@ -1084,41 +1090,39 @@
1084 1090 'tabindex' => 1 === $item_settings['tab_count'] ? '0' : '-1',
1085 1091 'aria-controls' => $item_settings['container_id'],
1086 1092 'style' => '--n-tabs-title-order: ' . $item_settings['tab_count'] . ';',
1087 1093 ] );
1088 - ?>
1089 - <button <?php $this->print_render_attribute_string( $setting_key ); ?>>
1090 - <?php $this->maybe_render_tab_icons_html( $item_settings ); ?>
1091 - <span <?php $this->print_render_attribute_string( 'tab-title-text' ); ?>>
1092 - <?php echo wp_kses_post( $title ); ?>
1093 - </span>
1094 - </button>
1095 - <?php
1096 - }
1097 1094
1098 - protected function maybe_render_tab_icons_html( $item_settings ): void {
1099 - $icon_settings = $item_settings['item']['tab_icon'];
1095 + $render_attributes = $this->get_render_attribute_string( $setting_key );
1096 + $text_class = $this->get_render_attribute_string( 'tab-title-text' );
1097 + $icon_class = $this->get_render_attribute_string( 'tab-icon' );
1100 1098
1101 - if ( empty( $icon_settings['value'] ) ) {
1102 - return;
1099 + $icon_html = Icons_Manager::try_get_icon_html( $item_settings['item']['tab_icon'], [ 'aria-hidden' => 'true' ] );
1100 + $icon_active_html = $icon_html;
1101 +
1102 + if ( $this->is_active_icon_exist( $item_settings['item'] ) ) {
1103 + $icon_active_html = Icons_Manager::try_get_icon_html( $item_settings['item']['tab_icon_active'], [ 'aria-hidden' => 'true' ] );
1103 1104 }
1104 1105
1105 - $active_icon_settings = $this->is_active_icon_exist( $item_settings['item'] )
1106 - ? $item_settings['item']['tab_icon_active']
1107 - : $icon_settings;
1106 + ob_start();
1108 1107 ?>
1109 - <span <?php $this->print_render_attribute_string( 'tab-icon' ); ?>>
1110 - <?php Icons_Manager::render_icon( $icon_settings, [ 'aria-hidden' => 'true' ] ); ?>
1111 - <?php Icons_Manager::render_icon( $active_icon_settings, [ 'aria-hidden' => 'true' ] ); ?>
1112 - </span>
1108 + <button <?php echo $render_attributes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
1109 + <span <?php echo $icon_class; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
1110 + <?php echo $icon_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1111 + <?php echo $icon_active_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1112 + </span>
1113 + <span <?php echo $text_class; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
1114 + <?php echo wp_kses_post( $title ); ?>
1115 + </span>
1116 + </button>
1113 1117 <?php
1118 + return ob_get_clean();
1114 1119 }
1115 1120
1116 - protected function render_tab_containers_html( $settings ): void {
1117 - foreach ( $settings['tabs'] as $index => $item ) {
1118 - $item_settings = $this->tab_item_settings[ $index ];
1119 - $this->print_child( $item_settings['index'], $item_settings );
1120 - }
1121 + protected function render_tab_containers_html( $item_settings ): string {
1122 + ob_start();
1123 + $this->print_child( $item_settings['index'], $item_settings );
1124 + return ob_get_clean();
1121 1125 }
1122 1126
1123 1127
1124 1128 /**
@@ -1123,9 +1127,9 @@
1123 1127
1124 1128 /**
1125 1129 * Print the content area.
1126 1130 *
1127 - * @param int $index
1131 + * @param int $index
1128 1132 * @param array $item_settings
1129 1133 */
1130 1134 public function print_child( $index, $item_settings = [] ) {
1131 1135 $children = $this->get_children();
@@ -1144,11 +1148,9 @@
1144 1148 return $should_render;
1145 1149 };
1146 1150
1147 1151 add_filter( 'elementor/frontend/container/should_render', $add_attribute_to_container, 10, 3 );
1148 - if ( isset( $children[ $index ] ) ) {
1149 - $children[ $index ]->print_element();
1150 - }
1152 + $children[ $index ]->print_element();
1151 1153 remove_filter( 'elementor/frontend/container/should_render', $add_attribute_to_container );
1152 1154 }
1153 1155
1154 1156 protected function add_attributes_to_container( $container, $item_settings ) {
@@ -1163,9 +1165,9 @@
1163 1165 }
1164 1166
1165 1167 protected function render() {
1166 1168 $settings = $this->get_settings_for_display();
1167 - $widget_number = $this->get_id_int();
1169 + $widget_number = substr( $this->get_id_int(), 0, 3 );
1168 1170
1169 1171 if ( ! empty( $settings['link'] ) ) {
1170 1172 $this->add_link_attributes( 'elementor-tabs', $settings['link'] );
1171 1173 }
@@ -1178,38 +1180,39 @@
1178 1180
1179 1181 $this->add_render_attribute( 'tab-title-text', 'class', 'e-n-tab-title-text' );
1180 1182 $this->add_render_attribute( 'tab-icon', 'class', 'e-n-tab-icon' );
1181 1183 $this->add_render_attribute( 'tab-icon-active', 'class', [ 'e-n-tab-icon' ] );
1184 +
1185 + $tab_titles_html = '';
1186 + $tab_containers_html = '';
1187 +
1188 + foreach ( $settings['tabs'] as $index => $item ) {
1189 + $tab_count = $index + 1;
1190 +
1191 + $tab_id = empty( $item['element_id'] )
1192 + ? 'e-n-tabs-title-' . $widget_number . $tab_count
1193 + : $item['element_id'];
1194 +
1195 + $item_settings = [
1196 + 'index' => $index,
1197 + 'tab_count' => $tab_count,
1198 + 'tab_id' => $tab_id,
1199 + 'container_id' => 'e-n-tab-content-' . $widget_number . $tab_count,
1200 + 'widget_number' => $widget_number,
1201 + 'item' => $item,
1202 + 'settings' => $settings,
1203 + ];
1204 +
1205 + $tab_titles_html .= $this->render_tab_titles_html( $item_settings );
1206 + $tab_containers_html .= $this->render_tab_containers_html( $item_settings );
1207 + }
1182 1208 ?>
1183 1209 <div <?php $this->print_render_attribute_string( 'elementor-tabs' ); ?>>
1184 1210 <div class="e-n-tabs-heading" role="tablist">
1185 - <?php
1186 - foreach ( $settings['tabs'] as $index => $item ) {
1187 - $tab_count = $index + 1;
1188 - $tab_title_id = 'e-n-tab-title-' . $widget_number . $tab_count;
1189 - $tab_id = empty( $item['element_id'] )
1190 - ? $tab_title_id
1191 - : $item['element_id'];
1192 -
1193 - $item_settings = [
1194 - 'index' => $index,
1195 - 'tab_count' => $tab_count,
1196 - 'tab_id' => $tab_id,
1197 - 'tab_title_id' => $tab_title_id,
1198 - 'container_id' => 'e-n-tab-content-' . $widget_number . $tab_count,
1199 - 'widget_number' => $widget_number,
1200 - 'item' => $item,
1201 - 'settings' => $settings,
1202 - ];
1203 -
1204 - $this->tab_item_settings[] = $item_settings;
1205 -
1206 - $this->render_tab_titles_html( $item_settings );
1207 - }
1208 - ?>
1211 + <?php echo $tab_titles_html;// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1209 1212 </div>
1210 1213 <div class="e-n-tabs-content">
1211 - <?php $this->render_tab_containers_html( $settings ); ?>
1214 + <?php echo $tab_containers_html;// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1212 1215 </div>
1213 1216 </div>
1214 1217 <?php
1215 1218 }
@@ -1214,111 +1217,136 @@
1214 1217 <?php
1215 1218 }
1216 1219
1217 1220 protected function get_initial_config(): array {
1218 - return array_merge( parent::get_initial_config(), [
1219 - 'support_improved_repeaters' => true,
1220 - 'target_container' => [ '.e-n-tabs-heading' ],
1221 - 'node' => 'button',
1222 - ] );
1221 + if ( Plugin::$instance->experiments->is_feature_active( 'e_nested_atomic_repeaters' ) ) {
1222 + return array_merge( parent::get_initial_config(), [
1223 + 'support_improved_repeaters' => true,
1224 + 'target_container' => [ '.e-n-tabs-heading' ],
1225 + 'node' => 'button',
1226 + ] );
1227 + }
1228 +
1229 + return parent::get_initial_config();
1223 1230 }
1224 1231
1225 1232 protected function content_template_single_repeater_item() {
1226 1233 ?>
1227 1234 <#
1228 - const tabIndex = view.collection.length,
1229 - elementUid = view.getIDInt().toString(),
1230 - item = data,
1231 - hoverAnimationSetting = view?.container?.settings?.attributes?.hover_animation;
1232 - hoverAnimationClass = hoverAnimationSetting
1233 - ? `elementor-animation-${ hoverAnimationSetting }`
1234 - : '';
1235 - #>
1236 - <?php $this->content_template_single_item( '{{ tabIndex }}', '{{ item }}', '{{ elementUid }}', '{{ hoverAnimationClass }}' );
1237 - }
1235 + const tabCount = view.collection.length + 1,
1236 + elementUid = view.getIDInt().toString().substring( 0, 3 ) + tabCount,
1237 + tabIcon = elementor.helpers.renderIcon( view, data.tab_icon, { 'aria-hidden': true }, 'i' , 'object' );
1238 1238
1239 - protected function content_template() {
1240 - ?>
1241 - <# const elementUid = view.getIDInt().toString(); #>
1242 - <div class="e-n-tabs" data-widget-number="{{ elementUid }}" aria-label="<?php echo esc_html__( 'Tabs. Open items with Enter or Space, close with Escape and navigate using the Arrow keys.', 'elementor' ); ?>">
1243 - <# if ( settings['tabs'] ) { #>
1244 - <div class="e-n-tabs-heading" role="tablist">
1245 - <# _.each( settings['tabs'], function( item, index ) {
1246 - const tabIndex = index,
1247 - hoverAnimationSetting = settings['hover_animation'],
1248 - hoverAnimationClass = hoverAnimationSetting
1249 - ? `elementor-animation-${ hoverAnimationSetting }`
1250 - : '';
1251 - #>
1252 - <?php $this->content_template_single_item( '{{ tabIndex }}', '{{ item }}', '{{ elementUid }}', '{{ hoverAnimationClass }}' ); ?>
1253 - <# } ); #>
1254 - </div>
1255 - <div class="e-n-tabs-content"></div>
1256 - <# } #>
1257 - </div>
1258 - <?php
1259 - }
1239 + let tabActiveIcon = tabIcon,
1240 + tabId = 'e-n-tab-title-' + elementUid;
1260 1241
1261 - private function content_template_single_item( $tab_index, $item, $element_uid, $hover_animation_class ) {
1262 - ?>
1263 - <#
1264 - const tabCount = tabIndex + 1,
1265 - tabTitleId = 'e-n-tab-title-' + elementUid + tabCount,
1266 - tabId = item.element_id
1267 - ? item.element_id
1268 - : tabTitleId,
1269 - tabUid = elementUid + tabCount,
1270 - tabIcon = elementor.helpers.renderIcon( view, item.tab_icon, { 'aria-hidden': true }, 'i' , 'object' ),
1271 - activeTabIcon = item.tab_icon_active.value
1272 - ? elementor.helpers.renderIcon( view, item.tab_icon_active, { 'aria-hidden': true }, 'i' , 'object' )
1273 - : tabIcon,
1274 - escapedHoverAnimationClass = _.escape( hoverAnimationClass );
1242 + if ( '' !== data.tab_icon_active.value ) {
1243 + tabActiveIcon = elementor.helpers.renderIcon( view, data.tab_icon_active, { 'aria-hidden': true }, 'i' , 'object' );
1244 + }
1275 1245
1276 - view.addRenderAttribute( 'tab-title', {
1277 - 'id': tabId,
1278 - 'data-tab-title-id': tabTitleId,
1279 - 'class': [ 'e-n-tab-title',escapedHoverAnimationClass ],
1246 + const tabWrapperKey = {
1247 + 'id': 'e-n-tab-title-' + elementUid,
1248 + 'class': [ 'e-n-tab-title' ],
1280 1249 'data-tab-index': tabCount,
1281 1250 'role': 'tab',
1282 1251 'aria-selected': 1 === tabCount ? 'true' : 'false',
1283 1252 'tabindex': 1 === tabCount ? '0' : '-1',
1284 - 'aria-controls': 'e-n-tab-content-' + tabUid,
1253 + 'aria-controls': 'e-n-tab-content-' + elementUid,
1285 1254 'style': '--n-tabs-title-order: ' + tabCount + ';',
1286 - }, null, true );
1255 + };
1287 1256
1288 - view.addRenderAttribute( 'tab-title-text', {
1289 - 'class': [ 'e-n-tab-title-text' ],
1257 + const tabIconKey = {
1258 + 'class': [ 'e-n-tab-icon' ],
1290 1259 'data-binding-type': 'repeater-item',
1291 1260 'data-binding-repeater-name': 'tabs',
1292 - 'data-binding-setting': [ 'tab_title', 'element_id' ],
1261 + 'data-binding-setting': [ data.tab_icon.value, data.tab_icon_active.value ],
1293 1262 'data-binding-index': tabCount,
1294 - 'data-binding-config': JSON.stringify({
1295 - 'element_id': {
1296 - attr: 'id',
1297 - selector: 'button',
1298 - editType: 'attribute',
1299 - },
1300 - 'tab_title': {
1301 - editType: 'text',
1302 - },
1303 - }),
1304 - }, null, true );
1263 + };
1305 1264
1306 - view.addRenderAttribute( 'tab-icon', {
1307 - 'class': [ 'e-n-tab-icon' ],
1265 + const tabTitleKey = {
1266 + 'class': [ 'e-n-tab-title-text' ],
1308 1267 'data-binding-type': 'repeater-item',
1309 1268 'data-binding-repeater-name': 'tabs',
1269 + 'data-binding-setting': [ 'tab_title' ],
1310 1270 'data-binding-index': tabCount,
1311 - }, null, true );
1271 + };
1272 +
1273 + view.addRenderAttribute( 'button-container', tabWrapperKey, null, true );
1274 + view.addRenderAttribute( 'tab-title-container', tabTitleKey, null, true );
1275 + view.addRenderAttribute( 'tab-icon-key-container', tabIconKey, null, true );
1312 1276 #>
1313 1277
1314 - <button {{{ view.getRenderAttributeString( 'tab-title' ) }}}>
1315 - <# if ( !! item.tab_icon.value ) { #>
1316 - <span {{{ view.getRenderAttributeString( 'tab-icon' ) }}}>{{{ tabIcon.value }}}{{{ activeTabIcon.value }}}</span>
1278 + <button {{{ view.getRenderAttributeString( 'button-container' ) }}}>
1279 + <span {{{ view.getRenderAttributeString( 'tab-icon-key-container' ) }}}>
1280 + {{{ tabIcon.value }}}{{{ tabActiveIcon.value }}}
1281 + </span>
1282 + <span {{{ view.getRenderAttributeString( 'tab-title-container' ) }}}>{{{ data.tab_title }}}</span>
1283 + </button>
1284 + <?php
1285 + }
1286 +
1287 + protected function content_template() {
1288 + ?>
1289 + <# const elementUid = view.getIDInt().toString().substr( 0, 3 ); #>
1290 + <div class="e-n-tabs" data-widget-number="{{ elementUid }}" aria-label="<?php echo esc_html__( 'Tabs. Open items with Enter or Space, close with Escape and navigate using the Arrow keys.', 'elementor' ); ?>">
1291 + <# if ( settings['tabs'] ) { #>
1292 + <div class="e-n-tabs-heading" role="tablist">
1293 + <# _.each( settings['tabs'], function( item, index ) {
1294 + const tabCount = index + 1,
1295 + tabUid = elementUid + tabCount,
1296 + tabWrapperKey = tabUid,
1297 + tabTitleKey = 'tab-title-' + tabUid,
1298 + tabIconKey = 'tab-icon-' + tabUid,
1299 + tabIcon = elementor.helpers.renderIcon( view, item.tab_icon, { 'aria-hidden': true }, 'i' , 'object' ),
1300 + hoverAnimationClass = settings['hover_animation'] ? `elementor-animation-${ settings['hover_animation'] }` : '';
1301 +
1302 + let tabActiveIcon = tabIcon,
1303 + tabId = 'e-n-tab-title-' + tabUid;
1304 +
1305 + if ( '' !== item.tab_icon_active.value ) {
1306 + tabActiveIcon = elementor.helpers.renderIcon( view, item.tab_icon_active, { 'aria-hidden': true }, 'i' , 'object' );
1307 + }
1308 +
1309 + if ( '' !== item.element_id ) {
1310 + tabId = item.element_id;
1311 + }
1312 +
1313 + view.addRenderAttribute( tabWrapperKey, {
1314 + 'id': tabId,
1315 + 'class': [ 'e-n-tab-title',hoverAnimationClass ],
1316 + 'data-tab-index': tabCount,
1317 + 'role': 'tab',
1318 + 'aria-selected': 1 === tabCount ? 'true' : 'false',
1319 + 'tabindex': 1 === tabCount ? '0' : '-1',
1320 + 'aria-controls': 'e-n-tab-content-' + tabUid,
1321 + 'style': '--n-tabs-title-order: ' + tabCount + ';',
1322 + } );
1323 +
1324 + view.addRenderAttribute( tabTitleKey, {
1325 + 'class': [ 'e-n-tab-title-text' ],
1326 + 'data-binding-type': 'repeater-item',
1327 + 'data-binding-repeater-name': 'tabs',
1328 + 'data-binding-setting': [ 'tab_title' ],
1329 + 'data-binding-index': tabCount,
1330 + } );
1331 +
1332 + view.addRenderAttribute( tabIconKey, {
1333 + 'class': [ 'e-n-tab-icon' ],
1334 + 'data-binding-type': 'repeater-item',
1335 + 'data-binding-repeater-name': 'tabs',
1336 + 'data-binding-setting': [ 'tab_icon.value', 'tab_icon_active.value' ],
1337 + 'data-binding-index': tabCount,
1338 + } );
1339 + #>
1340 + <button {{{ view.getRenderAttributeString( tabWrapperKey ) }}}>
1341 + <span {{{ view.getRenderAttributeString( tabIconKey ) }}}>{{{ tabIcon.value }}}{{{ tabActiveIcon.value }}}</span>
1342 + <span {{{ view.getRenderAttributeString( tabTitleKey ) }}}>{{{ item.tab_title }}}</span>
1343 + </button>
1344 + <# } ); #>
1345 + </div>
1346 + <div class="e-n-tabs-content"></div>
1317 1347 <# } #>
1318 -
1319 - <span {{{ view.getRenderAttributeString( 'tab-title-text' ) }}}>{{{ item.tab_title }}}</span>
1320 - </button>
1348 + </div>
1321 1349 <?php
1322 1350 }
1323 1351
1324 1352 /**