Merge "Check validity and availability of usernames during signup via AJAX"
[lhc/web/wiklou.git] / resources / mediawiki / mediawiki.searchSuggest.js
index 3b360af..6999610 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*!
  * 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