PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / trunk
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more vtrunk
4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / assets / js / feature-notices.js
embedpress / assets / js Last commit date
chunks 1 week ago vendor 8 months ago admin.build.js 1 week ago admin.js 3 months ago analytics-tracker.js 4 weeks ago analytics.build.js 1 week ago blocks.build.js 1 week ago carousel.js 1 year ago custom-player.build.js 1 week ago documents-viewer-script.js 3 months ago ep-pdf-lightbox.js 3 months ago ep-view-count.js 1 week ago ep-yt-queue.js 4 weeks ago feature-notices.js 7 months ago front.js 4 weeks ago frontend.build.js 3 months ago gallery-justify.js 1 week ago gutneberg-script.js 2 months ago index.html 7 years ago initCarousel.js 2 years ago initplyr.js 2 months ago instafeed.js 4 weeks ago instagram-shortcode-generator.js 1 month ago lazy-load.js 6 months ago license.js 3 months ago meetup-timezone.js 3 months ago onboarding.build.js 1 week ago pdf-gallery-elementor-editor.js 3 months ago pdf-gallery.js 3 months ago preview.js 8 months ago settings.js 3 months ago sponsored.js 9 months ago
feature-notices.js
232 lines
1 /**
2 * EmbedPress Feature Tooltip
3 * Handles tooltip/popover display and interactions
4 *
5 * @package EmbedPress
6 * @since 4.1.0
7 */
8
9 (function($) {
10 'use strict';
11
12 // Wait for DOM ready
13 $(document).ready(function() {
14
15 const $tooltip = $('#embedpress-feature-tooltip');
16 const $menuItem = $('#toplevel_page_embedpress');
17 const $menuBadge = $('.embedpress-menu-badge');
18
19 if (!$tooltip.length) {
20 return;
21 }
22
23 // Position and show tooltip after delay (3-5 seconds)
24 setTimeout(function() {
25 positionTooltip();
26 showTooltip();
27 }, 2000); // 4 seconds delay
28
29 // Show tooltip when clicking menu badge
30 $menuBadge.on('click', function(e) {
31 e.preventDefault();
32 e.stopPropagation();
33 showTooltip();
34 });
35
36 // Close button - permanently dismiss
37 $tooltip.on('click', '.embedpress-feature-tooltip__close', function(e) {
38 e.preventDefault();
39 handleDismiss();
40 });
41
42 // Skip button - permanently dismiss
43 $tooltip.on('click', '.embedpress-feature-tooltip__skip', function(e) {
44 e.preventDefault();
45 handleSkip();
46 });
47
48 // Primary button click - permanently dismiss
49 $tooltip.on('click', '.embedpress-feature-tooltip__button', function(e) {
50 // Let the link work, but also dismiss the notice
51 handleView();
52 });
53
54 // Dismiss when clicking outside
55 // $(document).on('click', function(e) {
56 // if ($tooltip.is(':visible') &&
57 // !$tooltip.is(e.target) &&
58 // $tooltip.has(e.target).length === 0 &&
59 // !$menuBadge.is(e.target)) {
60 // hideTooltip();
61 // }
62 // });
63
64 // Reposition on window resize
65 $(window).on('resize', debounce(function() {
66 if ($tooltip.is(':visible')) {
67 positionTooltip();
68 }
69 }, 250));
70
71 /**
72 * Show tooltip
73 */
74 function showTooltip() {
75 // Change from visibility:hidden to visible and fade in
76 $tooltip.css({
77 'visibility': 'visible',
78 'opacity': '1'
79 });
80 }
81
82 /**
83 * Hide tooltip
84 */
85 function hideTooltip() {
86 $tooltip.addClass('embedpress-feature-tooltip--dismissing');
87 setTimeout(function() {
88 $tooltip.hide().removeClass('embedpress-feature-tooltip--dismissing');
89 }, 300);
90 }
91
92 /**
93 * Position tooltip (now it's inside menu item, so just adjust vertical alignment)
94 */
95 function positionTooltip() {
96 if (!$menuItem.length) {
97 return;
98 }
99
100 const menuHeight = $menuItem.outerHeight();
101 const windowWidth = $(window).width();
102
103 // Mobile: center on screen
104 if (windowWidth <= 782) {
105 $tooltip.css({
106 position: 'fixed',
107 left: '50%',
108 top: '50%',
109 transform: 'translate(-50%, -50%)',
110 margin: 0
111 });
112 return;
113 }
114
115 // Desktop: align arrow with menu center
116 // Arrow is at 24px from top, so offset tooltip top to align arrow with menu center
117 const topOffset = (menuHeight / 2) - 35;
118
119 $tooltip.css({
120 top: topOffset + 'px'
121 });
122 }
123
124 /**
125 * Handle skip action
126 */
127 function handleSkip() {
128 const noticeId = $tooltip.data('notice-id');
129
130 if (!noticeId) {
131 hideTooltip();
132 return;
133 }
134
135 $.ajax({
136 url: embedpressFeatureNotices.ajaxurl,
137 type: 'POST',
138 data: {
139 action: 'embedpress_skip_feature_notice',
140 notice_id: noticeId,
141 nonce: embedpressFeatureNotices.nonce
142 },
143 success: function(response) {
144 if (response.success) {
145 hideTooltip();
146 $menuBadge.fadeOut(300);
147 }
148 },
149 error: function() {
150 hideTooltip();
151 }
152 });
153 }
154
155 /**
156 * Handle dismiss action (permanent)
157 */
158 function handleDismiss() {
159 const noticeId = $tooltip.data('notice-id');
160
161 if (!noticeId) {
162 hideTooltip();
163 return;
164 }
165
166 $.ajax({
167 url: embedpressFeatureNotices.ajaxurl,
168 type: 'POST',
169 data: {
170 action: 'embedpress_dismiss_feature_notice',
171 notice_id: noticeId,
172 nonce: embedpressFeatureNotices.nonce
173 },
174 success: function(response) {
175 if (response.success) {
176 hideTooltip();
177 $menuBadge.fadeOut(300);
178 }
179 },
180 error: function() {
181 hideTooltip();
182 }
183 });
184 }
185
186 /**
187 * Handle view action (clicking primary button)
188 */
189 function handleView() {
190 const noticeId = $tooltip.data('notice-id');
191
192 if (!noticeId) {
193 return;
194 }
195
196 // Send AJAX to permanently dismiss
197 $.ajax({
198 url: embedpressFeatureNotices.ajaxurl,
199 type: 'POST',
200 data: {
201 action: 'embedpress_view_feature_notice',
202 notice_id: noticeId,
203 nonce: embedpressFeatureNotices.nonce
204 },
205 success: function(response) {
206 if (response.success) {
207 // Don't hide tooltip - let the link navigate
208 // Just mark as dismissed in background
209 $menuBadge.fadeOut(300);
210 }
211 }
212 });
213 }
214
215 /**
216 * Debounce function
217 */
218 function debounce(func, wait) {
219 let timeout;
220 return function() {
221 const context = this;
222 const args = arguments;
223 clearTimeout(timeout);
224 timeout = setTimeout(function() {
225 func.apply(context, args);
226 }, wait);
227 };
228 }
229 });
230
231 })(jQuery);
232