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