/* SearchModal Gadget - JS Initialisation, Setup, Events. Moves the search to a separate modal with is opened from the custom header See detailed documentation in Dev/mediawiki deferrable:YES -- Because it's an augmentation / gadget and is not needed as a depedency */ (function() { if( $('#custom-header').length == 0 ) return; // ----- // Setup let modal = $('
'); $('body').append( modal ); modal.miniModal('init'); // Transform main Search to Vector Skin // Move SearchForm to Modal let search = $('#p-search'); modal.find('.content').append( search ); // ------ // Events modal.on('shown.miniModal', function() { if( ! modal.hasClass('modal-initialized') ) { $('#searchInput').focus(); } let inputName, inputNameOptions = ['vector-search-box-input','input.wvui-input__input']; for( const name of inputNameOptions ) { if( search.find( '.' + name ).length ) { inputName = name; break; } } search.find( '.' + inputName ).val(''); search.find( '.' + inputName ).focus(); modal.addClass('modal-initialized'); }); // ------ // Events // Event: Search Button click $('#custom-header .search').on( 'click', function(e) { $('#top-bar-search-modal').miniModal('show'); e.preventDefault(); }); })(); /* [[Category:MultiWiki]] */