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