PluginProbe ʕ •ᴥ•ʔ
Spider Elements – Premium Elementor Widgets & Addons Library / 1.1.0
Spider Elements – Premium Elementor Widgets & Addons Library v1.1.0
trunk 1.0.0 1.1.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.7.0 1.8.0 1.9.0
spider-elements / widgets / templates / tabs / tab-2.php
spider-elements / widgets / templates / tabs Last commit date
tab-1.php 2 years ago tab-2.php 2 years ago
tab-2.php
183 lines
1 <?php
2 if (!defined('ABSPATH')) {
3 exit; // Exit if accessed directly.
4 }
5 ?>
6 <section class="header_tabs_area">
7 <div class="header_tab_items sticky_tab_item tabs_sliders <?php echo esc_attr($navigation_arrow_class . $sticky_tab_class); ?>">
8 <span class="scroller-btn left"><i class="arrow_carrot-left"></i></span>
9 <ul class="nav nav-tabs slide_nav_tabs ezd-tab-menu <?php echo esc_attr($tab_auto_class); ?>">
10 <?php
11 $i = 0.2;
12 if (is_array($tabs) && !empty($tabs)) {
13 foreach ( $tabs as $index => $item ) {
14 $tab_count = $index + 1;
15 $tab_title_setting_key = $this->get_repeater_setting_key('tab_title', 'tabs', $index);
16 $active = $tab_count == 1 ? 'active' : '';
17 $selected = $tab_count == 1 ? 'true' : 'false';
18 $this->add_render_attribute($tab_title_setting_key, [
19 'class' => [ 'nav-link tab-item-title spe_tab_title', $active ],
20 'data-rel' => 'tab-content-' . $id_int . $tab_count,
21 ]);
22 ?>
23 <li class="nav-item wow fadeInUp" data-wow-delay="<?php echo esc_attr($i); ?>s">
24 <button <?php echo $this->get_render_attribute_string($tab_title_setting_key); ?>>
25 <?php if ($is_auto_play == 'yes') : ?>
26 <div class="tab_progress">
27 <div class="progress-bar"></div>
28 </div>
29 <?php endif; ?>
30 <?php if ($is_auto_numb == 'yes') : ?>
31 <span class="numb"><?php echo esc_html($tab_count) ?></span>
32 <?php endif; ?>
33 <?php \Elementor\Icons_Manager::render_icon($item[ 'icon' ], [ 'aria-hidden' => 'true' ]); ?>
34 <?php echo esc_html($item[ 'tab_title' ]); ?>
35 </button>
36 </li>
37 <?php
38 $i = $i + 0.2;
39 }
40 }
41 ?>
42 </ul>
43 <span class="scroller-btn right" id="right"><i class="arrow_carrot-right"></i></span>
44 </div>
45 <div class="header_tab_content">
46 <div class="tab-content">
47 <?php
48 if (is_array($tabs) && !empty($tabs)) {
49 foreach ( $tabs as $index => $item ) {
50 $tab_count = $index + 1;
51 $active = $tab_count == 1 ? 'show active' : '';
52 $tab_content_setting_key = $this->get_repeater_setting_key('tab_content', 'tabs', $index);
53 $this->add_render_attribute($tab_content_setting_key, [
54 'class' => [ 'tab-pane p-0 tab_style ezd-tab-box', 'fade', $active ],
55 'id' => 'tab-content-' . $id_int . $tab_count,
56 ]);
57 ?>
58 <div <?php echo $this->get_render_attribute_string($tab_content_setting_key); ?>>
59 <?php
60 if ('content' == $item[ 'tabs_content_type' ]) {
61 echo do_shortcode($item[ 'tab_content' ]);
62 } elseif ('template' == $item[ 'tabs_content_type' ]) {
63 if (!empty($item[ 'primary_templates' ])) {
64 echo \Elementor\plugin::$instance->frontend->get_builder_content($item[ 'primary_templates' ], true);
65 }
66 }
67 ?>
68 </div>
69 <?php
70 }
71 }
72
73 if ($is_navigation_arrow == 'yes') { ?>
74 <button class="btn btn-info btn-lg previous"><i class="arrow_carrot-left"></i></button>
75 <button class="btn btn-info btn-lg next"><i class="arrow_carrot-right"></i></button>
76 <?php
77 }
78 ?>
79 </div>
80 </div>
81 </section>
82
83 <script>
84 ;(function ($) {
85 'use strict';
86
87 <?php if ($is_auto_play == 'yes'): ?>
88 $(document).ready(function () {
89 // Function to handle tab change
90 function changeTab(tabJs, index) {
91 // Remove active class from all tabs within the same menu
92 tabJs.closest(".ezd-tab-menu").find("li button").removeClass("active");
93
94 tabJs.addClass("active");
95
96 var target = tabJs.attr("data-rel");
97
98 $("#" + target)
99 .addClass("active")
100 .siblings(".ezd-tab-box")
101 .removeClass("active");
102
103 // Reset progress bar for all tabs except the clicked one
104 $(".progress-bar").not(tabJs.find(".progress-bar")).stop().width(0);
105
106 // Update progress bar for the clicked tab
107 updateProgressBar(tabJs.find(".progress-bar"), 5000);
108 }
109
110 // Function to update progress bar
111 function updateProgressBar(progressBar, duration) {
112 progressBar.stop().width(0).animate({
113 width: "100%",
114 },
115 duration,
116 "linear"
117 );
118 }
119
120 // Tab click event handler
121 var tabJs = $(".ezd-tab-menu li button");
122 var firstTab = tabJs.first();
123 changeTab(firstTab, tabJs.index(firstTab));
124 updateProgressBar(firstTab.find(".progress-bar"), 5000);
125 tabJs.on("click", function (e) {
126 e.preventDefault();
127 changeTab($(this), tabJs.index($(this)));
128 return false;
129 });
130
131 // Auto-cycle tabs with progress bar
132 var currentIndex = 0;
133 var intervalDuration = 5000; // Set the interval duration in milliseconds
134
135 function autoCycleTabs() {
136 var nextIndex = (currentIndex + 1) % tabJs.length;
137 var activeTab = tabJs.eq(nextIndex);
138 changeTab(activeTab, nextIndex);
139 currentIndex = nextIndex;
140 }
141
142 var tabCycle = setInterval(autoCycleTabs, intervalDuration);
143
144 // Handle hover to stop and resume tab cycling and progress bar for all tabs
145 $(".ezd-tab-menu li button").hover(
146 function () {
147 clearInterval(tabCycle);
148 $(".progress-bar").stop();
149 },
150 function () {
151 tabCycle = setInterval(autoCycleTabs, intervalDuration);
152 updateProgressBar($("button.active .progress-bar"), intervalDuration);
153 }
154 );
155
156 // Function to reset progress bar
157 function resetProgressBar(progressBar) {
158 progressBar.stop().width(0);
159 }
160 });
161 <?php else : ?>
162 let tabJs = $(".ezd-tab-menu li button");
163 tabJs.on("click", function (e) {
164 e.preventDefault();
165
166 // Remove active class from all tabs within the same menu
167 $(this).closest(".ezd-tab-menu").find("li button").removeClass("active");
168
169 // Add active class to the clicked tab
170 $(this).addClass("active");
171
172 var target = $(this).attr("data-rel");
173
174 $("#" + target)
175 .addClass("active")
176 .siblings(".ezd-tab-box")
177 .removeClass("active");
178
179 return false;
180 });
181 <?php endif; ?>
182 })(jQuery);
183 </script>