mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-25 14:57:31 +00:00
31 lines
736 B
JavaScript
31 lines
736 B
JavaScript
/**
|
|
* Based on https://gerrit.wikimedia.org/g/wikimedia/portals/+/refs/heads/master
|
|
* See T219590 for more details
|
|
*/
|
|
|
|
/* global wmTest, WMTypeAhead, _, addEvent */
|
|
|
|
( function ( WMTypeAhead ) {
|
|
|
|
var inputEvent,
|
|
searchInput = document.getElementById( 'search-input' ),
|
|
typeAhead = new WMTypeAhead( 'search-form', 'search-input' );
|
|
|
|
/**
|
|
* Testing for 'input' event and falling back to 'propertychange' event for IE.
|
|
*/
|
|
if ( 'oninput' in document ) {
|
|
inputEvent = 'input';
|
|
} else {
|
|
inputEvent = 'propertychange';
|
|
}
|
|
|
|
/**
|
|
* Attaching type-ahead query action to 'input' event.
|
|
*/
|
|
addEvent( searchInput, inputEvent, _.debounce( function () {
|
|
typeAhead.query( searchInput.value );
|
|
}, 100 ) );
|
|
|
|
}( WMTypeAhead ) );
|