2020-02-16 00:00:19 +00:00
|
|
|
/* eslint-disable */
|
2020-02-16 00:05:44 +00:00
|
|
|
|
2019-12-11 22:14:36 +00:00
|
|
|
/**
|
|
|
|
* Based on https://gerrit.wikimedia.org/g/wikimedia/portals/+/refs/heads/master
|
|
|
|
* See T219590 for more details
|
|
|
|
*/
|
2020-02-16 00:00:19 +00:00
|
|
|
|
2019-12-26 09:40:43 +00:00
|
|
|
/* global WMTypeAhead, _, addEvent */
|
2019-12-11 22:25:24 +00:00
|
|
|
( function ( WMTypeAhead ) {
|
2019-12-11 22:14:36 +00:00
|
|
|
|
2019-12-25 23:24:31 +00:00
|
|
|
let inputEvent,
|
2020-06-06 18:47:03 +00:00
|
|
|
searchInput = document.getElementById( 'searchInput' ),
|
|
|
|
typeAhead = new WMTypeAhead( 'searchform', 'searchInput' );
|
2019-12-11 22:14:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 () {
|
2019-12-11 23:09:05 +00:00
|
|
|
typeAhead.query( searchInput.value );
|
2019-12-11 22:14:36 +00:00
|
|
|
}, 100 ) );
|
|
|
|
|
2019-12-11 22:25:24 +00:00
|
|
|
}( WMTypeAhead ) );
|