*
* @param {string} [options.expandFrom=auto] Which direction to offset the suggestion box from.
* Values 'start' and 'end' translate to left and right respectively depending on the directionality
- * of the current document, according to `$( 'html' ).css( 'direction' )`.
+ * of the current document, according to `$( document.documentElement ).css( 'direction' )`.
* Valid values: "left", "right", "start", "end", and "auto".
*
* @param {boolean} [options.positionFromLeft] Sets `expandFrom=left`, for backwards
context.data.prevText = '';
} else if (
val !== context.data.prevText ||
+ // eslint-disable-next-line no-jquery/no-sizzle
!context.data.$container.is( ':visible' )
) {
context.data.prevText = val;
if ( !result.get || selected.get( 0 ) !== result.get( 0 ) ) {
if ( result === 'prev' ) {
if ( selected.hasClass( 'suggestions-special' ) ) {
- result = context.data.$container.find( '.suggestions-result:last' );
+ result = context.data.$container.find( '.suggestions-result' ).last();
} else {
result = selected.prev();
if ( !( result.length && result.hasClass( 'suggestions-result' ) ) ) {
if ( context.data.$container.find( '.suggestions-special' ).html() !== '' ) {
result = context.data.$container.find( '.suggestions-special' );
} else {
- result = context.data.$container.find( '.suggestions-results .suggestions-result:last' );
+ result = context.data.$container.find( '.suggestions-results .suggestions-result' ).last();
}
}
}
} else if ( result === 'next' ) {
if ( selected.length === 0 ) {
// No item selected, go to the first one
- result = context.data.$container.find( '.suggestions-results .suggestions-result:first' );
+ result = context.data.$container.find( '.suggestions-results .suggestions-result' ).first();
if ( result.length === 0 && context.data.$container.find( '.suggestions-special' ).html() !== '' ) {
// No suggestion exists, go to the special one directly
result = context.data.$container.find( '.suggestions-special' );
// Process expandFrom, after this it is set to left or right.
context.config.expandFrom = ( function ( expandFrom ) {
var regionWidth, docWidth, regionCenter, docCenter,
- docDir = $( document.documentElement ).css( 'direction' ),
+ isRTL = $( document.documentElement ).css( 'direction' ) === 'rtl',
$region = context.config.$region;
// Backwards compatible
}
if ( expandFrom === 'start' ) {
- expandFrom = docDir === 'rtl' ? 'right' : 'left';
+ expandFrom = isRTL ? 'right' : 'left';
} else if ( expandFrom === 'end' ) {
- expandFrom = docDir === 'rtl' ? 'left' : 'right';
+ expandFrom = isRTL ? 'left' : 'right';
}
return expandFrom;
*/
function keypress( e, context, key ) {
var selected,
+ // eslint-disable-next-line no-jquery/no-sizzle
wasVisible = context.data.$container.is( ':visible' ),
preventDefault = false;
} );
// Load suggestions if the value is changed because there are already
// typed characters before the JavaScript is loaded.
- if ( this.value !== this.defaultValue ) {
+ if ( $( this ).is( ':focus' ) && this.value !== this.defaultValue ) {
update( context, false );
}
}