PluginProbe
wpForo Forum / 3.1.6
wpForo Forum v3.1.6
3.1.6 3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 138 releases
wpforo / admin / assets / js / feature-intro.js

feature-intro.js in wpForo Forum 3.1.6, at admin/assets/js/feature-intro.js

128 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * wpForo Feature Introduction Modal
3 */
4 (function($) {
5 'use strict';
6
7 var currentSlide = 0;
8 var totalSlides = wpforoFeatureIntro.totalSlides || 1;
9 var $overlay, $slides, $dots, $prevBtn, $nextBtn;
10
11 $(document).ready(function() {
12 $overlay = $('#wpforo-feature-intro-overlay');
13 if (!$overlay.length) return;
14
15 $slides = $overlay.find('.wpf-fi-slide');
16 $dots = $overlay.find('.wpf-fi-dot');
17 $prevBtn = $overlay.find('.wpf-fi-prev');
18 $nextBtn = $overlay.find('.wpf-fi-next');
19
20 // Show modal with animation
21 setTimeout(function() {
22 $overlay.addClass('wpf-fi-visible');
23 }, 300);
24
25 updateArrows();
26
27 // Arrow navigation
28 $prevBtn.on('click', function() {
29 goToSlide(currentSlide - 1);
30 });
31
32 $nextBtn.on('click', function() {
33 goToSlide(currentSlide + 1);
34 });
35
36 // Dot navigation
37 $dots.on('click', function() {
38 goToSlide($(this).data('slide'));
39 });
40
41 // Close button
42 $overlay.on('click', '.wpf-fi-close', function(e) {
43 e.preventDefault();
44 dismissIntro();
45 });
46
47 // Maybe Later button
48 $overlay.on('click', '.wpf-fi-dismiss', function(e) {
49 e.preventDefault();
50 dismissIntro();
51 });
52
53 // Connect Now button - dismiss then navigate
54 $overlay.on('click', '.wpf-fi-connect', function(e) {
55 e.preventDefault();
56 var url = $(this).attr('href');
57 dismissIntro(function() {
58 window.location.href = url;
59 });
60 });
61
62 // Click overlay background to close
63 $overlay.on('click', function(e) {
64 if (e.target === this) {
65 dismissIntro();
66 }
67 });
68
69 // Keyboard navigation
70 $(document).on('keydown.wpforo-feature-intro', function(e) {
71 if (e.key === 'Escape') {
72 dismissIntro();
73 }
74 if (e.key === 'ArrowRight') {
75 goToSlide(currentSlide + 1);
76 }
77 if (e.key === 'ArrowLeft') {
78 goToSlide(currentSlide - 1);
79 }
80 });
81 });
82
83 function goToSlide(index) {
84 if (index < 0 || index >= totalSlides || index === currentSlide) return;
85
86 currentSlide = index;
87
88 // Update slides
89 $slides.removeClass('wpf-fi-active');
90 $slides.filter('[data-slide="' + index + '"]').addClass('wpf-fi-active');
91
92 // Update dots
93 $dots.removeClass('wpf-fi-active');
94 $dots.filter('[data-slide="' + index + '"]').addClass('wpf-fi-active');
95
96 // Update arrow visibility
97 updateArrows();
98 }
99
100 function updateArrows() {
101 $prevBtn.toggleClass('wpf-fi-hidden', currentSlide === 0);
102 $nextBtn.toggleClass('wpf-fi-hidden', currentSlide === totalSlides - 1);
103 }
104
105 function dismissIntro(callback) {
106 var optOut = $('#wpf-fi-opt-out').is(':checked') ? '1' : '0';
107
108 // Fade out
109 $overlay.removeClass('wpf-fi-visible');
110
111 // Send AJAX
112 $.post(wpforoFeatureIntro.ajaxUrl, {
113 action: 'wpforo_dismiss_feature_intro',
114 _wpnonce: wpforoFeatureIntro.nonce,
115 version: wpforoFeatureIntro.version,
116 opt_out: optOut
117 }).always(function() {
118 // Remove from DOM after animation
119 setTimeout(function() {
120 $overlay.remove();
121 $(document).off('keydown.wpforo-feature-intro');
122 if (typeof callback === 'function') callback();
123 }, 350);
124 });
125 }
126
127 })(jQuery);
128