Merge "(bug 39230) Autocompletion does not get cleared on region change"

This commit is contained in:
Amire80
2012-08-16 15:17:28 +00:00
committed by Gerrit Code Review
2 changed files with 24 additions and 7 deletions

View File

@@ -159,11 +159,12 @@
$target: lcd,
languages: that.languages,
success: function() {
// clear the search field.
that.$languageFilter.val( '' );
// Deactivate search filtering
that.$languageFilter.languagefilter( 'deactivate' );
// Show 'results view' if we are in no results mode
that.success();
},
noresult: function() {
noresults: function() {
that.$languageFilter.languagefilter( 'clear' );
}
} );

View File

@@ -85,13 +85,29 @@
}
},
clear: function() {
/**
* Clears the current search removing
* clear buttons and suggestions.
*/
deactivate: function() {
this.$element.val( '' );
this.$element.focus();
this.toggleClear();
this.autofill();
},
/**
* Clears the search and shows all languages
*/
clear: function() {
this.deactivate();
this.search();
},
/**
* Toggles the visibility of clear icon depending
* on whether there is anything to clear.
*/
toggleClear: function() {
if ( !this.$clear.length ) {
return;
@@ -331,8 +347,8 @@
click: function( e ) {
if( this.$element.hasClass( 'active' ) ) {
this.$element.removeClass( 'active' );
if ( this.options.noresult ) {
this.options.noresult.call();
if ( this.options.noresults ) {
this.options.noresults.call();
}
} else {
this.show();
@@ -360,7 +376,7 @@
$.fn.regionselector.defaults = {
$target: null, // Where to render the results
success: null, // callback if any results found.
noresult: null, // callback when no results to show
noresults: null, // callback when no results to show
languages: null
};