(tutorial, step, targetElement)
| 319 | |
| 320 | // Show tutorial overlay |
| 321 | function showTutorialOverlay(tutorial, step, targetElement) { |
| 322 | CarrotDebug.ui(`🎓 showTutorialOverlay called`); |
| 323 | // Get or create overlay |
| 324 | let overlay = getTutorialOverlay(); |
| 325 | CarrotDebug.ui(`🎓 Overlay element:`, overlay); |
| 326 | |
| 327 | // Create tutorial popup content |
| 328 | const totalSteps = tutorialSteps.length; |
| 329 | const stepNumber = currentStep + 1; |
| 330 | const progress = ((currentStep + 1) / totalSteps) * 100; |
| 331 | |
| 332 | const popupHTML = ` |
| 333 | <div class="carrot-tutorial-popup" id="carrot-tutorial-popup"> |
| 334 | <div class="carrot-tutorial-header"> |
| 335 | <h3 class="carrot-tutorial-title">${tutorial.title}</h3> |
| 336 | <button class="carrot-tutorial-close" onclick="window.closeTutorial()">×</button> |
| 337 | </div> |
| 338 | <div class="carrot-tutorial-progress"> |
| 339 | <div class="carrot-tutorial-progress-bar" style="width: ${progress}%"></div> |
| 340 | <span class="carrot-tutorial-progress-text">Step ${stepNumber} of ${totalSteps}</span> |
| 341 | </div> |
| 342 | <div class="carrot-tutorial-step-header"> |
| 343 | <h4>${step.title}</h4> |
| 344 | </div> |
| 345 | <div class="carrot-tutorial-content"> |
| 346 | ${step.content} |
| 347 | </div> |
| 348 | <div class="carrot-tutorial-navigation"> |
| 349 | ${currentStep > 0 ? '<button class="carrot-tutorial-btn carrot-tutorial-prev" onclick="window.previousTutorialStep()">← Previous</button>' : '<span></span>'} |
| 350 | ${currentStep < totalSteps - 1 |
| 351 | ? '<button class="carrot-tutorial-btn carrot-tutorial-next" onclick="window.nextTutorialStep()">Next →</button>' |
| 352 | : '<button class="carrot-tutorial-btn carrot-tutorial-finish" onclick="window.closeTutorial()">Finish</button>'} |
| 353 | </div> |
| 354 | </div> |
| 355 | `; |
| 356 | |
| 357 | overlay.innerHTML = popupHTML; |
| 358 | overlay.style.display = 'flex'; |
| 359 | overlay.classList.add('active'); // Make overlay visible |
| 360 | CarrotDebug.ui(`🎓 Set overlay display to flex and added active class`); |
| 361 | |
| 362 | // Position popup near target |
| 363 | const targetRect = targetElement.getBoundingClientRect(); |
| 364 | const popup = document.getElementById('carrot-tutorial-popup'); |
| 365 | CarrotDebug.ui(`🎓 Tutorial popup element:`, popup); |
| 366 | positionTutorialPopup(popup, targetRect); |
| 367 | |
| 368 | // Add resize handler |
| 369 | if (resizeHandler) { |
| 370 | window.removeEventListener('resize', resizeHandler); |
| 371 | } |
| 372 | resizeHandler = () => { |
| 373 | const newRect = targetElement.getBoundingClientRect(); |
| 374 | positionTutorialPopup(popup, newRect); |
| 375 | }; |
| 376 | window.addEventListener('resize', resizeHandler); |
| 377 | } |
| 378 |
no test coverage detected