(bug 39230) Autocompletion does not get cleared on region change
* Introduced deactivate (clear without showing all languages) * Renamed noresult in region filter to noresults to match the callback in languagefilter * Some comments to help understand the code Change-Id: I544a29b860a6d3f4a5aa770f84cc8a72ae4a4b9d
This commit is contained in:
@@ -159,11 +159,12 @@
|
|||||||
$target: lcd,
|
$target: lcd,
|
||||||
languages: that.languages,
|
languages: that.languages,
|
||||||
success: function() {
|
success: function() {
|
||||||
// clear the search field.
|
// Deactivate search filtering
|
||||||
that.$languageFilter.val( '' );
|
that.$languageFilter.languagefilter( 'deactivate' );
|
||||||
|
// Show 'results view' if we are in no results mode
|
||||||
that.success();
|
that.success();
|
||||||
},
|
},
|
||||||
noresult: function() {
|
noresults: function() {
|
||||||
that.$languageFilter.languagefilter( 'clear' );
|
that.$languageFilter.languagefilter( 'clear' );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|||||||
@@ -85,13 +85,29 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
clear: function() {
|
/**
|
||||||
|
* Clears the current search removing
|
||||||
|
* clear buttons and suggestions.
|
||||||
|
*/
|
||||||
|
deactivate: function() {
|
||||||
this.$element.val( '' );
|
this.$element.val( '' );
|
||||||
this.$element.focus();
|
this.$element.focus();
|
||||||
this.toggleClear();
|
this.toggleClear();
|
||||||
|
this.autofill();
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the search and shows all languages
|
||||||
|
*/
|
||||||
|
clear: function() {
|
||||||
|
this.deactivate();
|
||||||
this.search();
|
this.search();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles the visibility of clear icon depending
|
||||||
|
* on whether there is anything to clear.
|
||||||
|
*/
|
||||||
toggleClear: function() {
|
toggleClear: function() {
|
||||||
if ( !this.$clear.length ) {
|
if ( !this.$clear.length ) {
|
||||||
return;
|
return;
|
||||||
@@ -331,8 +347,8 @@
|
|||||||
click: function( e ) {
|
click: function( e ) {
|
||||||
if( this.$element.hasClass( 'active' ) ) {
|
if( this.$element.hasClass( 'active' ) ) {
|
||||||
this.$element.removeClass( 'active' );
|
this.$element.removeClass( 'active' );
|
||||||
if ( this.options.noresult ) {
|
if ( this.options.noresults ) {
|
||||||
this.options.noresult.call();
|
this.options.noresults.call();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.show();
|
this.show();
|
||||||
@@ -360,7 +376,7 @@
|
|||||||
$.fn.regionselector.defaults = {
|
$.fn.regionselector.defaults = {
|
||||||
$target: null, // Where to render the results
|
$target: null, // Where to render the results
|
||||||
success: null, // callback if any results found.
|
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
|
languages: null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user