(function() {const configuration = {"frDataLbl":"Retour en haut","arDataLbl":"العودة إلى الأعلى"}; const fragmentElement = document.querySelector('#fragment-304b752d-ed89-2032-1fa6-bd6085691f1b'); const fragmentEntryLinkNamespace = 'rujc'; const fragmentNamespace = 'rujc'; const layoutMode = 'view';const buttonMYO = document.getElementById('backToTopButton'); const labelElement = document.getElementById('backToTopLabel'); // Scroll event to show/hide button based on scroll position window.addEventListener('scroll', function() { if (window.scrollY > 300) { // Show after user scrolls 300px buttonMYO.classList.add('show'); } else { buttonMYO.classList.remove('show'); } }); // Click event for smooth scroll to top buttonMYO?.addEventListener('click', function() { window.scrollTo({ top: 0, behavior: 'smooth' }); }); buttonMYO?.addEventListener('mousedown', function() { buttonMYO.style.outline = 'none'; }); buttonMYO?.addEventListener('keydown', function(event) { if (event.key === 'Enter') { buttonMYO.style.outline = 'none'; } }); // Function to change label based on language function changeLabel(language) { let translatedText = 'Back To Top'; // Default label text // Retrieve the translated text based on the selected language if (language === 'fr_FR') { translatedText = configuration.frDataLbl; } else if (language === 'ar_SA') { translatedText = configuration.arDataLbl; } labelElement.textContent = translatedText; } // Set the initial label based on the selected language changeLabel(Liferay.ThemeDisplay.getLanguageId()); ;}());