MediaWiki:Vector.js
Nota: dopo aver salvato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.
- Firefox / Safari: tenere premuto il tasto delle maiuscole Shift e fare clic su Ricarica, oppure premere Ctrl-F5 o Ctrl-R (⌘-R su Mac)
- Google Chrome: premere Ctrl-Shift-R (⌘-Shift-R su un Mac)
- Internet Explorer: tenere premuto il tasto Ctrl e fare clic su Aggiorna, oppure premere Ctrl-F5
- Opera: Vai nel Menu → Impostazioni (Opera → Preferenze su un Mac) e poi in Privacy & sicurezza → Pulisci dati del browser → Immagini e file nella cache.
/* Il codice JavaScript inserito qui viene caricato dagli utenti che usano il tema Vector */
mw.loader.using( 'jquery.suggestions', function () {
$( function () {
var $input = $( '#searchInput' );
if ( !$input.length || $input.data( 'wfAutocomplete' ) ) {
return;
}
$input.data( 'wfAutocomplete', true );
$input.suggestions( {
delay: 150,
cache: true,
maxRows: 8,
fetch: function ( value, callback ) {
new mw.Api().get( {
action: 'opensearch',
search: value,
namespace: 0,
limit: 8
} ).done( function ( data ) {
callback( data[ 1 ] || [] );
} ).fail( function () {
callback( [] );
} );
}
} );
} );
} );