Two tiny performance improvements.
The complexity of a regular expression is not needed to check if a
string contains a character. string.match() returns an array of
matches which is not used anyway in this case. Either
string.indexOf() or RegExp.test() should be used.
Duplicate jQuery call merged.
Change-Id: Ifec79eada70181df0d56c583ef832ee82594620e
// Compute form data for search suggestions functionality.
function computeResultRenderCache( context ) {
// 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' );
// 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 ) {
linkParams = {};
$.each( $form.serializeArray(), function ( idx, obj ) {
special: {
render: specialRenderFunction,
select: function ( $input ) {
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"/>' ) )
+ .submit();
}
},
$region: $searchRegion
}
},
$region: $searchRegion