Merge "Handling enter key in language filter"
This commit is contained in:
@@ -107,11 +107,7 @@
|
|||||||
|
|
||||||
lcd = that.$resultsView.lcd( {
|
lcd = that.$resultsView.lcd( {
|
||||||
languages: that.languages,
|
languages: that.languages,
|
||||||
clickhandler: function( langCode ) {
|
clickhandler: $.proxy( that.onSelect, that )
|
||||||
if ( that.options.onSelect ) {
|
|
||||||
that.options.onSelect.call( this, langCode );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} ).data( "lcd" );
|
} ).data( "lcd" );
|
||||||
|
|
||||||
that.$languageFilter.languagefilter( {
|
that.$languageFilter.languagefilter( {
|
||||||
@@ -119,7 +115,8 @@
|
|||||||
languages: that.languages,
|
languages: that.languages,
|
||||||
success: $.proxy( that.success, that ),
|
success: $.proxy( that.success, that ),
|
||||||
noresults: $.proxy( that.noresults, that ),
|
noresults: $.proxy( that.noresults, that ),
|
||||||
searchAPI: that.options.searchAPI
|
searchAPI: that.options.searchAPI,
|
||||||
|
onSelect: $.proxy( that.onSelect, that )
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// Create region selectors, one per region
|
// Create region selectors, one per region
|
||||||
@@ -135,6 +132,12 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onSelect: function( langCode ) {
|
||||||
|
if ( this.options.onSelect ) {
|
||||||
|
this.options.onSelect.call( this, langCode );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
keyup: function( e ) {
|
keyup: function( e ) {
|
||||||
if ( !this.shown ) {
|
if ( !this.shown ) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
this.resultCount = 0;
|
this.resultCount = 0;
|
||||||
this.$suggestion = $( '#' + this.$element.data( 'suggestion' ) );
|
this.$suggestion = $( '#' + this.$element.data( 'suggestion' ) );
|
||||||
this.$clear = $( '#'+ this.$element.data( 'clear' ) );
|
this.$clear = $( '#'+ this.$element.data( 'clear' ) );
|
||||||
|
this.selectedLanguage = null;
|
||||||
this.listen();
|
this.listen();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -66,11 +67,16 @@
|
|||||||
this.$element.val( suggestion );
|
this.$element.val( suggestion );
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
} else {
|
|
||||||
this.options.$target.focus();
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
if ( this.options.onSelect && this.selectedLanguage ) {
|
||||||
|
this.options.onSelect( this.selectedLanguage );
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
var that = this;
|
var that = this;
|
||||||
|
this.selectedLanguage = null;
|
||||||
delay( function() {
|
delay( function() {
|
||||||
that.options.$target.empty();
|
that.options.$target.empty();
|
||||||
that.search();
|
that.search();
|
||||||
@@ -113,6 +119,9 @@
|
|||||||
// Autofill the first result.
|
// Autofill the first result.
|
||||||
this.autofill( langCode );
|
this.autofill( langCode );
|
||||||
}
|
}
|
||||||
|
if ( query === langCode ) {
|
||||||
|
this.selectedLanguage = langCode;
|
||||||
|
}
|
||||||
this.render( langCode );
|
this.render( langCode );
|
||||||
this.resultCount++;
|
this.resultCount++;
|
||||||
}
|
}
|
||||||
@@ -162,6 +171,7 @@
|
|||||||
this.$suggestion.val( '' );
|
this.$suggestion.val( '' );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.selectedLanguage = langCode;
|
||||||
languageName = languageName || this.options.languages[langCode];
|
languageName = languageName || this.options.languages[langCode];
|
||||||
var autonym,
|
var autonym,
|
||||||
userInput = this.$element.val(),
|
userInput = this.$element.val(),
|
||||||
@@ -229,7 +239,8 @@
|
|||||||
searchAPI: null,
|
searchAPI: null,
|
||||||
languages: null, // Languages as code:name format.
|
languages: null, // Languages as code:name format.
|
||||||
noresults: null, // callback for no results found case
|
noresults: null, // callback for no results found case
|
||||||
success: null // callback if any results found.
|
success: null, // callback if any results found.
|
||||||
|
onSelect: null // Language select handler - like enter in filter textbox.
|
||||||
};
|
};
|
||||||
|
|
||||||
$.fn.languagefilter.Constructor = LanguageFilter;
|
$.fn.languagefilter.Constructor = LanguageFilter;
|
||||||
|
|||||||
Reference in New Issue
Block a user