-/**
+/*!
* Add search suggestions to the search form.
*/
( function ( mw, $ ) {
// Compute form data for search suggestions functionality.
function computeResultRenderCache( context ) {
- var $form, formAction, baseHref, linkParams;
+ var $form, baseHref, linkParams;
// Compute common parameters for links' hrefs
$form = context.config.$region.closest( 'form' );
- formAction = $form.attr( 'action' );
- baseHref = formAction + ( formAction.match( /\?/ ) ? '&' : '?' );
+ baseHref = $form.attr( 'action' );
+ baseHref += baseHref.indexOf( '?' ) > -1 ? '&' : '?';
linkParams = {};
$.each( $form.serializeArray(), function ( idx, obj ) {
},
result: {
render: renderFunction,
- select: function ( $input ) {
- $input.closest( 'form' ).submit();
+ select: function () {
+ return true; // allow the form to be submitted
}
},
delay: 120,
$searchInput.suggestions( {
result: {
render: renderFunction,
- select: function ( $input ) {
- $input.closest( 'form' ).submit();
+ select: function () {
+ return true; // allow the form to be submitted
}
},
special: {
render: specialRenderFunction,
select: function ( $input ) {
- $input.closest( 'form' ).append(
- $( '<input type="hidden" name="fulltext" value="1"/>' )
- );
- $input.closest( 'form' ).submit();
+ $input.closest( 'form' )
+ .append( $( '<input type="hidden" name="fulltext" value="1"/>' ) );
+ return true; // allow the form to be submitted
}
},
$region: $searchRegion
} );
+ // If the form includes any fallback fulltext search buttons, remove them
+ $searchInput.closest( 'form' ).find( '.mw-fallbackSearchButton' ).remove();
+
// In most skins (at least Monobook and Vector), the font-size is messed up in <body>.
// (they use 2 elements to get a sane font-height). So, instead of making exceptions for
// each skin or adding more stylesheets, just copy it from the active element so auto-fit.