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 |