PluginProbe ʕ •ᴥ•ʔ
Spider Elements – Premium Elementor Widgets & Addons Library / trunk
Spider Elements – Premium Elementor Widgets & Addons Library vtrunk
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 / assets / js / elementor-widgets.js
spider-elements / assets / js Last commit date
admin.js 5 months ago elementor-widgets.js 7 months ago
elementor-widgets.js
731 lines
1 ;(function ($, elementor) {
2 "use strict";
3
4 const $window = $(elementor);
5
6 const spiderElements = {
7 onInit: function () {
8 const E_FRONT = elementorFrontend;
9 const widgetHandlersMap = {
10 "docy_tabs.default": spiderElements.tabs,
11 "docy_testimonial.default": spiderElements.testimonial,
12 "docly_alerts_box.default": spiderElements.alertBox,
13 "spel_videos_playlist.default": spiderElements.videoPlaylist,
14 "docy_team_carousel.default": spiderElements.teamslider,
15 "docy_video_popup.default": spiderElements.videoPopup,
16 "spel_accordion.default": spiderElements.accordions,
17 "docly_cheatsheet.default": spiderElements.cheatsheet,
18 "docy_blog_grid.default": spiderElements.blogGrid,
19 };
20
21 $.each(widgetHandlersMap, function (widgetName, callback) {
22 E_FRONT.hooks.addAction(
23 "frontend/element_ready/" + widgetName,
24 callback
25 );
26 });
27 },
28
29 //======================== Blog Grid =========================== //
30 blogGrid: function ($scope) {
31
32
33 let blogGrid = $scope.find(".category-slider-one");
34 let dataRtlblog = blogGrid.data("rtl");
35 if (blogGrid.length > 0) {
36 blogGrid.slick({
37 rtl: dataRtlblog,
38 dots: false,
39 arrows: true,
40 lazyLoad: 'ondemand',
41 prevArrow: $('.prev_d'),
42 nextArrow: $('.next_d'),
43 centerPadding: '0px',
44 slidesToShow: 4,
45 slidesToScroll: 1,
46 autoplay: true,
47 autoplaySpeed: 3000,
48 responsive: [
49 {
50 breakpoint: 992,
51 settings: {
52 slidesToShow: 3
53 }
54 },
55 {
56 breakpoint: 768,
57 settings: {
58 slidesToShow: 2
59 }
60 },
61 {
62 breakpoint: 576,
63 settings: {
64 slidesToShow: 1
65 }
66 }
67 ]
68 });
69 }
70
71 },
72
73
74 /*============ cheatsheet js ==============*/
75 cheatsheet: function ($scope) {
76 let cheatsht = $scope.find(".card-header button");
77 cheatsht.on("click", function (event) {
78 event.preventDefault(); // Prevent default behavior
79 var $this = $(this);
80 var $parent = $this.parents();
81 var $collapses = $parent.find("> .collapse").first();
82 $(this).toggleClass("active");
83 $collapses.slideToggle(300);
84 return false;
85 });
86
87 // Check if elementor is in edit mode
88 if (window.elementor && window.elementor.hasOwnProperty('frontend') && window.elementorFrontend.isEditMode()) {
89 // Check if serial number toggle is enabled
90 let enableSerial = $scope.find('[data-setting="enable_serial_numbers"]').val() === 'yes';
91 let enableNumberCircle = $scope.find('[data-setting="enable_number_circle"]').val() === 'yes';
92
93 if (enableSerial || enableNumberCircle) {
94 // Update serial numbers dynamically based on index
95 setTimeout(function() {
96 $scope.find('.elementor-repeater-fields').each(function(index) {
97 // Dynamically apply serial numbers using the index value
98 if (enableSerial) {
99 $(this).find('.cheatsheet_num').text('#' + (index + 1));
100 }
101 if (enableNumberCircle) {
102 $(this).find('.number-circle').text('#' + (index + 1));
103 }
104 });
105 }, 100);
106
107 // Update serial numbers when new items are added
108 window.elementor.on('click', '.elementor-repeater-add', function() {
109 setTimeout(function() {
110 $scope.find('.elementor-repeater-fields').each(function(index) {
111 if (enableSerial) {
112 $(this).find('.cheatsheet_num').text('#' + (index + 1));
113 }
114 if (enableNumberCircle) {
115 $(this).find('.number-circle').text('#' + (index + 1));
116 }
117 });
118 }, 100);
119 });
120 }
121 }
122 },
123
124 //=============== Accordion ===============//
125 accordions: function ($scope) {
126 let cardHeader = $scope.find(".accordion_inner > .card-header");
127
128 cardHeader.on("click", function () {
129 let $this = $(this);
130 let $parent = $this.parent();
131 let $collapse = $parent.find("> .collapse").first();
132
133 $collapse.slideToggle(300);
134 $parent.siblings().find("> .collapse").hide(300);
135
136 if ($parent.hasClass("collapsed")) {
137 $parent.removeClass("collapsed");
138 } else {
139 cardHeader.parent().removeClass("collapsed");
140 $parent.addClass("collapsed");
141 }
142
143 return false;
144 });
145 },
146
147 //============================== Video Popup =============================//
148 videoPopup: function ($scope) {
149 let fancy = $scope.find(".fancybox");
150 if (fancy.length) {
151 fancy.fancybox({
152 arrows: true,
153 buttons: [
154 "zoom",
155 "slideShow",
156 "thumbs",
157 "close",
158 ],
159 animationEffect: "zoom-in-out",
160 transitionEffect: "zoom-in-out",
161 });
162 }
163
164 // Layout 03
165 let textElement = document.querySelector(".btn-circle .text p");
166 if (textElement) {
167 textElement.innerHTML = textElement.innerText // Split the text into characters and apply rotation to each character
168 .split("")
169 .map(
170 (char, i) =>
171 `<span style="transform:rotate(${i * 9.5}deg)">${char}</span>`
172 )
173 .join("");
174 }
175 }, //End Video Popup
176
177 //============================== Team Slider =============================//
178 teamslider: function ($scope) {
179
180 let teamSlider = $scope.find(".expert-slider-one");
181 let dataRtlTeam1 = teamSlider.data("rtl");
182 if (teamSlider.length) {
183 teamSlider.slick({
184 rtl: dataRtlTeam1,
185 arrows: true,
186 lazyLoad: "ondemand",
187 prevArrow: $(".prev_a"),
188 nextArrow: $(".next_a"),
189 centerPadding: "0px",
190 slidesToShow: 4,
191 slidesToScroll: 1,
192 autoplay: true,
193 autoplaySpeed: 3000,
194 responsive: [
195 {
196 breakpoint: 1200,
197 settings: {
198 slidesToShow: 3,
199 },
200 },
201 {
202 breakpoint: 768,
203 settings: {
204 slidesToShow: 2,
205 },
206 },
207 {
208 breakpoint: 480,
209 settings: {
210 slidesToShow: 1,
211 },
212 },
213 ],
214 });
215 }
216
217 let teamSlider2 = $scope.find(".expert-slider-two");
218 let dataRtlTeam2 = teamSlider2.data("rtl");
219 if (teamSlider2.length) {
220 teamSlider2.slick({
221 rtl: dataRtlTeam2,
222 dots: true,
223 arrows: false,
224 lazyLoad: "ondemand",
225 centerPadding: "0px",
226 slidesToShow: 4,
227 slidesToScroll: 2,
228 autoplay: false,
229 autoplaySpeed: 3000,
230 responsive: [
231 {
232 breakpoint: 1200,
233 settings: {
234 slidesToShow: 3,
235 },
236 },
237 {
238 breakpoint: 992,
239 settings: {
240 slidesToShow: 2,
241 },
242 },
243 {
244 breakpoint: 576,
245 settings: {
246 slidesToShow: 1,
247 },
248 },
249 ],
250 });
251 }
252 }, //End Team Slider
253
254 //============================== Video Playlist =============================//
255 videoPlaylist: function ($scope) {
256 let video = $scope.find("#video_0");
257 setTimeout(function () {
258 $(".video_slider_area").addClass("loaded").css("height", "auto");
259 }, 3000);
260
261 video.addClass("show").addClass("active");
262 let containers = document.getElementsByClassName("artplayer-app");
263 if (containers.length > 0) {
264 for (var i = 0; i < containers.length; i++) {
265 new Artplayer({
266 container: containers[i],
267 url: containers[i].getAttribute("data-src"),
268 title: "Your Name",
269 pip: true,
270 screenshot: true,
271 flip: true,
272 fullscreen: true,
273 fullscreenWeb: true,
274 height: "500px",
275 });
276 }
277 }
278 },
279
280 //======================== Alert Box =========================== //
281 alertBox: function ($scope) {
282 $(".message_alert button.close").click(function () {
283 let btnId = $(this).attr("data-id");
284 $(".message_alert[data-id=" + btnId + "]").fadeOut();
285 });
286 },
287
288 //======================== Testimonial =========================== //
289 testimonial: function ($scope) {
290 let testimonialSlider = $scope.find(".doc_testimonial_slider");
291 let dataRtldoc = testimonialSlider.data("rtl");
292 let imageSlider = $scope.find(".doc_img_slider");
293 let dataRtlimg = imageSlider.data("rtl");
294
295 // Testi
296 if (testimonialSlider.length > 0) {
297 testimonialSlider.slick({
298 autoplay: true,
299 slidesToShow: 1,
300 slidesToScroll: 1,
301 rtl: dataRtlimg,
302 autoplaySpeed: 2000,
303 speed: 2000,
304 dots: true,
305 arrows: false,
306 asNavFor: imageSlider, //.doc_img_slider class
307 });
308 imageSlider.slick({
309 rtl: dataRtldoc,
310 slidesToShow: 1,
311 slidesToScroll: 1,
312 asNavFor: testimonialSlider, //.doc_testimonial_slider class
313 arrows: false,
314 fade: true,
315 focusOnSelect: true,
316 });
317 }
318
319 //==== testimonial Style 2
320 let feedbackSlider = $scope.find(".doc_feedback_slider");
321 let dataRtlfdb = feedbackSlider.data("rtl");
322 if (feedbackSlider.length > 0) {
323 feedbackSlider.slick({
324 rtl: dataRtlfdb,
325 autoplay: true,
326 slidesToShow: 1,
327 slidesToScroll: 1,
328 autoplaySpeed: 2000,
329 speed: 1000,
330 dots: false,
331 arrows: true,
332 prevArrow: ".prev",
333 nextArrow: ".next",
334 });
335 }
336
337 //==== Testimonial Style 3
338 let testimonialSliderInner = $scope.find(".testimonial-slider-inner");
339 if (testimonialSliderInner.length > 0) {
340 var Testimonial = new Swiper(".testimonial-slider-inner", {
341 slidesPerView: 1,
342 spaceBetween: 10,
343 loop: true,
344 navigation: {
345 nextEl: ".swiper-button-next",
346 prevEl: ".swiper-button-prev",
347 },
348 });
349 }
350
351 //=== Testimonial Style 4
352 let testimonialSlide4 = $scope.find(".testimonial-slide-4");
353 if (testimonialSlide4.length > 0) {
354 var swiper4 = new Swiper(".testimonial-slide-4", {
355 spaceBetween: 10,
356 loop: true,
357 navigation: false,
358 breakpoints: {
359 768: {
360 navigation: {
361 nextEl: ".swiper-button-next",
362 prevEl: ".swiper-button-prev",
363 },
364 },
365 },
366 });
367 }
368
369 //=== Testimonial Style 5
370 let testimonialSliderActive = $scope.find(".testimonial-slider-active");
371 if (testimonialSliderActive.length > 0) {
372 var swiper5 = new Swiper(".testimonial-slider-active", {
373 slidesPerView: 1,
374 spaceBetween: 24,
375 grabCursor: true,
376 loop: true,
377 speed: 500,
378 navigation: {
379 nextEl: ".swiper-button-next",
380 prevEl: ".swiper-button-prev",
381 },
382 breakpoints: {
383 576: {
384 slidesPerView: 2,
385 },
386 1200: {
387 slidesPerView: 4,
388 },
389 },
390 });
391 }
392
393 //== Testimonial Style 6
394 let testimonial6 = $scope.find(".feedback-slider-one");
395 let dataRtl6 = testimonial6.data("rtl");
396 if (testimonial6.length > 0) {
397 testimonial6.each(function () {
398 $(this).slick({
399 rtl: dataRtl6,
400 dots: false,
401 arrows: true,
402 lazyLoad: "ondemand",
403 prevArrow: $(this).parent().find(".prev_f"),
404 nextArrow: $(this).parent().find(".next_f"),
405 centerPadding: "0px",
406 slidesToShow: 2,
407 slidesToScroll: 1,
408 autoplay: true,
409 autoplaySpeed: 3000000,
410 responsive: [
411 {
412 breakpoint: 768,
413 settings: {
414 slidesToShow: 1,
415 },
416 },
417 ],
418 });
419 });
420 }
421
422 // feedback-slider-two slider js
423 let testimonial8 = $scope.find(".feedback-slider-two");
424 let dataRtl8 = testimonial8.data("rtl");
425 if (testimonial8.length) {
426 testimonial8.slick({
427 rtl: dataRtl8,
428 dots: true,
429 arrows: false,
430 lazyLoad: "ondemand",
431 centerPadding: "0px",
432 slidesToShow: 3,
433 slidesToScroll: 1,
434 autoplay: true,
435 autoplaySpeed: 300000,
436 responsive: [
437 {
438 breakpoint: 768,
439 settings: {
440 slidesToShow: 2,
441 },
442 },
443 {
444 breakpoint: 576,
445 settings: {
446 slidesToShow: 1,
447 },
448 },
449 ],
450 });
451 }
452
453 //=== Testimonial Style 10
454 let testimonial10_a = $scope.find(".feedback-slider-three-a");
455 let dataRtl10a = testimonial10_a.data("rtl");
456 let testimonial10_b = $scope.find(".feedback-slider-three-b");
457 let dataRtl10b = testimonial10_b.data("rtl");
458
459 if (testimonial10_a.length > 0) {
460 testimonial10_a.slick({
461 rtl: dataRtl10b,
462 dots: false,
463 arrows: true,
464 prevArrow: $('.prev_d'),
465 nextArrow: $('.next_d'),
466 lazyLoad: 'ondemand',
467 centerPadding: '0px',
468 slidesToShow: 1,
469 slidesToScroll: 1,
470 autoplay: true,
471 fade: true,
472 autoplaySpeed: 300000,
473 asNavFor: '.feedback-slider-three-b',
474 });
475 }
476
477 if (testimonial10_b.length > 0 ) {
478 testimonial10_b.slick({
479 rtl: dataRtl10a,
480 dots: true,
481 arrows: false,
482 lazyLoad: 'ondemand',
483 centerPadding: '0px',
484 slidesToShow: 3,
485 slidesToScroll: 1,
486 autoplay: true,
487 autoplaySpeed: 300000,
488 asNavFor: '.feedback-slider-three-a',
489 responsive: [
490 {
491 breakpoint: 992,
492 settings: {
493 slidesToShow: 2
494 }
495 },
496 {
497 breakpoint: 576,
498 settings: {
499 slidesToShow: 1
500 }
501 }
502 ]
503 });
504 }
505 },
506
507 //======================== Tabs =========================== //
508 tabs: function ($scope) {
509
510 // Tab Elements
511 let tabContainer = $scope.find(".spel-tab-menu");
512 let tabBtn = tabContainer.find("li button");
513 let tabContent = $scope.find(".tab-content .tab-box");
514 let nextBtn = $scope.find(".tab_arrow_btn.next");
515 let prevBtn = $scope.find(".tab_arrow_btn.previous");
516
517 let isAutoPlay = tabContainer.data("autoplay") === "yes";
518 let autoPlayInterval; // Declare an autoplay interval
519 let currentIndex = tabBtn.index(tabBtn.filter(".active")); // Track current active tab
520
521 console.log(isAutoPlay)
522
523 function changeActiveTab(newIndex) {
524 // Update active classes
525 tabBtn.removeClass("active");
526 tabContent.removeClass("show active");
527
528 let newTab = tabBtn.eq(newIndex);
529 let newContent = tabContent.eq(newIndex);
530
531 newTab.addClass("active");
532 newContent.addClass("show active");
533
534 // Update the current index for autoplay
535 currentIndex = newIndex;
536
537 // Scroll to the new active tab
538 scrollToTab(newTab);
539 }
540
541 function scrollToTab($activeTab) {
542 let containerWidth = tabContainer.width();
543 let scrollLeft = tabContainer.scrollLeft();
544 let tabLeft = $activeTab.position().left + scrollLeft;
545 let tabRight = tabLeft + $activeTab.outerWidth();
546
547 if (tabLeft < scrollLeft) {
548 tabContainer.animate({ scrollLeft: tabLeft }, 300);
549 } else if (tabRight > scrollLeft + containerWidth) {
550 tabContainer.animate({ scrollLeft: tabRight - containerWidth }, 300);
551 }
552 }
553
554 function startAutoplay() {
555 stopAutoplay(); // Ensure no duplicate intervals
556 autoPlayInterval = setInterval(() => {
557 let nextIndex = (currentIndex + 1) % tabBtn.length;
558 changeActiveTab(nextIndex);
559 }, 10000); // Set autoplay interval to 10 seconds
560 }
561
562 function stopAutoplay() {
563 clearInterval(autoPlayInterval);
564 }
565
566 // Handle manual tab switching
567 tabBtn.on("click", function (e) {
568 e.preventDefault();
569 let clickedIndex = tabBtn.index($(this));
570 changeActiveTab(clickedIndex);
571
572 if (isAutoPlay) {
573 stopAutoplay(); // Stop current autoplay
574 startAutoplay(); // Restart autoplay from the new tab
575 }
576 });
577
578 // Handle Next Button
579 nextBtn.on("click", function () {
580 let newIndex = (currentIndex + 1) % tabBtn.length;
581 changeActiveTab(newIndex);
582
583 if (isAutoPlay) {
584 stopAutoplay();
585 startAutoplay();
586 }
587 });
588
589 // Handle Previous Button
590 prevBtn.on("click", function () {
591 let newIndex = (currentIndex - 1 + tabBtn.length) % tabBtn.length;
592 changeActiveTab(newIndex);
593
594 if (isAutoPlay) {
595 stopAutoplay();
596 startAutoplay();
597 }
598 });
599
600 // Pause autoplay on hover over tab titles
601 tabBtn.on("mouseenter", function () {
602 if (isAutoPlay) {
603 stopAutoplay();
604 }
605 });
606
607 tabBtn.on("mouseleave", function () {
608 if (isAutoPlay) {
609 startAutoplay();
610 }
611 });
612
613 // Autoplay logic
614 if (isAutoPlay) {
615 startAutoplay();
616
617 // Pause autoplay on hover over tab titles
618 tabBtn.hover(
619 function () {
620 stopAutoplay();
621 },
622 function () {
623 startAutoplay();
624 }
625 );
626 }
627
628 // Center the active tab on load
629 let initialActiveTab = tabBtn.filter(".active");
630 if (initialActiveTab.length) {
631 scrollToTab(initialActiveTab);
632 }
633
634
635 // Tab Arrow Icons show/hide automatic when item is more than container
636 let tabSliderContainers = $scope.find(".tabs_sliders");
637 tabSliderContainers.each(function () {
638 let tabWrapWidth = $(this).outerWidth();
639 let totalWidth = 0;
640
641 let slideBtnLeft = $(this).find("#scroll_left_btn");
642 let slideBtnRight = $(this).find("#scroll_right_btn");
643 let navWrap = $(this).find(".slide_nav_tabs");
644 let navWrapItem = navWrap.children("li");
645
646 navWrapItem.each(function () {
647 totalWidth += $(this).outerWidth();
648 });
649
650 // Set initial scroll position to zero
651 navWrap.scrollLeft(0);
652
653 if (totalWidth > tabWrapWidth) {
654 slideBtnLeft.removeClass("inactive-left-arrow");
655 slideBtnRight.removeClass("inactive-right-arrow");
656 } else {
657 slideBtnLeft.addClass("inactive-left-arrow");
658 slideBtnRight.addClass("inactive-right-arrow");
659 }
660
661 function updateScrollerButtons() {
662 let scrollLeft = navWrap.scrollLeft();
663 let scrollWidth = navWrap[0].scrollWidth;
664 let navWidth = navWrap.outerWidth();
665
666 if (scrollLeft <= 0) {
667 slideBtnLeft.addClass("inactive-left-arrow");
668 } else {
669 slideBtnLeft.removeClass("inactive-left-arrow");
670 }
671
672 if (scrollLeft + navWidth >= scrollWidth - 1) {
673 slideBtnRight.addClass("inactive-right-arrow");
674 } else {
675 slideBtnRight.removeClass("inactive-right-arrow");
676 }
677 }
678
679 slideBtnRight.on("click", function () {
680 navWrap.animate({ scrollLeft: "+=200px" }, 300, function() {
681 updateScrollerButtons();
682 });
683 });
684
685 slideBtnLeft.on("click", function () {
686 navWrap.animate({ scrollLeft: "-=200px" }, 300, function() {
687 updateScrollerButtons();
688 });
689 });
690
691
692 // Center the active tab on a load
693 let activeTab = navWrap.find(".nav-item .nav-link.active");
694 if (activeTab.length > 0 ) {
695 let activeTabPosition = activeTab.position().left;
696 let activeTabWidth = activeTab.outerWidth();
697 let navWrapCenter = navWrap.outerWidth() / 2;
698
699 navWrap.scrollLeft(activeTabPosition - navWrapCenter + (activeTabWidth / 2));
700 updateScrollerButtons();
701 }
702
703 });
704
705 //=== Sticky Tab
706 let stickyTab = $scope.find(".sticky_tab");
707 let windowWidth = $(window).width();
708
709 if (stickyTab.length > 0) {
710 if (windowWidth > 576) {
711 let stickyTabHeight = stickyTab.height() + 100;
712 let stickyTabOffset = stickyTab.offset().top + stickyTabHeight;
713
714 $(window).on("scroll", function () {
715 let scrollTop = $(window).scrollTop();
716 if (scrollTop >= stickyTabOffset) {
717 stickyTab.addClass("tab_fixed");
718 } else {
719 stickyTab.removeClass("tab_fixed");
720 }
721 });
722 }
723 }
724 }
725
726
727 };
728
729 $window.on("elementor/frontend/init", spiderElements.onInit);
730 })(jQuery, window);
731