|
Balises : Annulation Modification par mobile Modification par le web mobile |
| Ligne 13 : |
Ligne 13 : |
| } ); | | } ); |
| } ); | | } ); |
|
| |
| /**
| |
| * Intégration recherche page d'accueil avec Citizen
| |
| */
| |
| (function() {
| |
| 'use strict';
| |
|
| |
| mw.hook('wikipage.content').add(function($content) {
| |
| // Sélectionne le bouton de recherche custom
| |
| const $customSearch = $content.find('.home-header__search');
| |
|
| |
| if (!$customSearch.length) return;
| |
|
| |
| // Déclenche la recherche native de Citizen au clic
| |
| $customSearch.on('click', function(e) {
| |
| e.preventDefault();
| |
|
| |
| // Méthode 1: Déclenche le bouton de recherche Citizen
| |
| const citizenSearchButton = document.querySelector('.citizen-search__button');
| |
| if (citizenSearchButton) {
| |
| citizenSearchButton.click();
| |
| return;
| |
| }
| |
|
| |
| // Méthode 2 (fallback): Focus direct sur l'input
| |
| const searchInput = document.querySelector('#searchInput, .citizen-search__input');
| |
| if (searchInput) {
| |
| searchInput.focus();
| |
| }
| |
| });
| |
|
| |
| // Support du raccourci clavier "/"
| |
| document.addEventListener('keydown', function(e) {
| |
| if (e.key === '/' && !isInputFocused()) {
| |
| e.preventDefault();
| |
| $customSearch.click();
| |
| }
| |
| });
| |
|
| |
| // Vérifie si un input est focus
| |
| function isInputFocused() {
| |
| const activeEl = document.activeElement;
| |
| return activeEl && (
| |
| activeEl.tagName === 'INPUT' ||
| |
| activeEl.tagName === 'TEXTAREA' ||
| |
| activeEl.isContentEditable
| |
| );
| |
| }
| |
| });
| |
| })();
| |