Changeset 3462482
- Timestamp:
- 02/16/2026 12:06:35 PM (5 days ago)
- Location:
- ai-translate/trunk
- Files:
-
- 4 edited
-
ai-translate.php (modified) (2 diffs)
-
assets/language-switcher.css (modified) (1 diff)
-
assets/language-switcher.js (modified) (3 diffs)
-
assets/switcher.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ai-translate/trunk/ai-translate.php
r3462432 r3462482 654 654 \AITranslate\AI_Lang::set_cookie((string) $defaultLang); 655 655 \AITranslate\AI_Lang::set_current((string) $defaultLang); 656 // Add JavaScript redirect to /after page renders656 // Add JavaScript redirect to site root after page renders 657 657 add_action('wp_footer', function() { 658 echo '<script> setTimeout(function(){window.location.href="/";},100);</script>';658 echo '<script>window.location.replace(' . wp_json_encode(home_url('/')) . ');</script>'; 659 659 }, 999); 660 660 // Continue to render page - Rule 3 below will be skipped … … 2931 2931 $menu_item->ID, 2932 2932 array( 2933 'menu-item-title' => 'Language Switcher'2933 'menu-item-title' => __('Language Switcher', 'ai-translate') 2934 2934 ) 2935 2935 ); -
ai-translate/trunk/assets/language-switcher.css
r3436692 r3462482 126 126 127 127 /* Force show submenu when JavaScript sets ai-force-show class */ 128 .menu-item-language-switcher .sub-menu.ai-force-show, 129 .menu-item-language-switcher .sub-menu[style*="display: block"] { 128 .menu-item-language-switcher .sub-menu.ai-force-show { 130 129 display: block !important; 131 130 opacity: 1 !important; -
ai-translate/trunk/assets/language-switcher.js
r3436692 r3462482 218 218 */ 219 219 function initMobileMenuSupport() { 220 // Wait for mobile menu to be ready 221 setTimeout(function() { 220 let attempts = 0; 221 const maxAttempts = 10; 222 223 function bindMobileSwitchers() { 222 224 // Find language switcher menu items 223 225 const languageItems = document.querySelectorAll('.menu-item-language-switcher'); 226 let boundCount = 0; 224 227 225 228 languageItems.forEach(function(item) { … … 229 232 // Only handle dropdown items (with submenu), inline items work without JS 230 233 if (link && submenu) { 234 if (link.getAttribute('data-ai-mobile-bound') === '1') { 235 return; 236 } 237 link.setAttribute('data-ai-mobile-bound', '1'); 238 boundCount++; 239 231 240 // Add click handler for mobile 232 241 link.addEventListener('click', function(event) { 242 // Prevent hash-jumps and theme anchor handlers from hijacking this toggle. 243 event.preventDefault(); 244 233 245 // Only handle click on mobile/tablet (screen width <= 768px) 234 246 if (window.innerWidth <= 768) { 235 event.preventDefault();236 247 event.stopPropagation(); 237 248 … … 270 281 }); 271 282 272 273 }, 1000); // Shorter timeout for testing 283 // Retry shortly for themes that render/replace menus after initial load. 284 if (boundCount === 0 && attempts < maxAttempts) { 285 attempts++; 286 setTimeout(bindMobileSwitchers, 300); 287 } 288 } 289 290 bindMobileSwitchers(); 274 291 } -
ai-translate/trunk/assets/switcher.js
r3438193 r3462482 64 64 // Handle dropdown toggle button clicks 65 65 b.addEventListener("click", function (e) { 66 e.preventDefault(); 66 67 e.stopPropagation(); 67 68 var open = !w.classList.contains("ai-trans-open");
Note: See TracChangeset
for help on using the changeset viewer.