(targetRect)
| 5430 | // Legacy popup positioning method - kept for compatibility |
| 5431 | function positionTutorialPopup(targetRect) { |
| 5432 | CarrotDebug.tutorial('🎯 Starting tutorial popup positioning', { |
| 5433 | targetRect: targetRect, |
| 5434 | screenSize: `${window.innerWidth}x${window.innerHeight}`, |
| 5435 | devicePixelRatio: window.devicePixelRatio, |
| 5436 | zoomLevel: window.outerWidth / window.innerWidth |
| 5437 | }); |
| 5438 | |
| 5439 | const overlay = getTutorialOverlay(); |
| 5440 | const popup = overlay?.querySelector('#carrot-tutorial-popup'); |
| 5441 | |
| 5442 | CarrotDebug.tutorial('Tutorial elements found', { |
| 5443 | overlayExists: !!overlay, |
| 5444 | popupExists: !!popup, |
| 5445 | overlayBounds: overlay?.getBoundingClientRect() || 'not found', |
| 5446 | popupBounds: popup?.getBoundingClientRect() || 'not found' |
| 5447 | }); |
| 5448 | |
| 5449 | if (!overlay || !popup) { |
| 5450 | CarrotDebug.error('❌ Tutorial elements missing - cannot position popup', { |
| 5451 | overlay: !!overlay, |
| 5452 | popup: !!popup |
| 5453 | }); |
| 5454 | return; |
| 5455 | } |
| 5456 | |
| 5457 | // Check if we're in a modal context |
| 5458 | const modal = document.querySelector('.popup:not(.popup_template)'); |
| 5459 | let containerRect, containerElement; |
| 5460 | |
| 5461 | if (modal && overlay.parentElement === modal) { |
| 5462 | // Use modal as container |
| 5463 | containerElement = modal; |
| 5464 | containerRect = modal.getBoundingClientRect(); |
| 5465 | |
| 5466 | CarrotDebug.tutorial('🏠 Using modal container', { |
| 5467 | modalExists: true, |
| 5468 | overlayIsChildOfModal: overlay.parentElement === modal, |
| 5469 | modalRect: containerRect, |
| 5470 | modalId: modal.id || 'no-id', |
| 5471 | modalClasses: modal.className |
| 5472 | }); |
| 5473 | } else { |
| 5474 | // Use viewport as container |
| 5475 | containerElement = document.documentElement; |
| 5476 | containerRect = { |
| 5477 | top: 0, |
| 5478 | left: 0, |
| 5479 | width: window.innerWidth, |
| 5480 | height: window.innerHeight |
| 5481 | }; |
| 5482 | |
| 5483 | CarrotDebug.tutorial('🌐 Using viewport container', { |
| 5484 | modalExists: !!modal, |
| 5485 | overlayParent: overlay.parentElement?.tagName || 'unknown', |
| 5486 | overlayIsChildOfModal: modal ? overlay.parentElement === modal : false, |
| 5487 | viewportRect: containerRect |
| 5488 | }); |
| 5489 | } |
no test coverage detected