Use events instead of callbacks for success or no results

Allows extension users to bind for this event, also reduces callbacks

Change-Id: I14cc6d51ad23432956e3ea3275c72db26d71a8c8
This commit is contained in:
Santhosh Thottingal
2013-08-15 12:16:12 +05:30
parent d40c160cf6
commit 33ec9285e3
2 changed files with 11 additions and 17 deletions

View File

@@ -143,7 +143,7 @@
*/
clear: function() {
this.deactivate();
this.$element.trigger( 'searchclear' );
this.$element.trigger( 'searchclear.uls' );
},
/**
@@ -222,15 +222,15 @@
/**
* Handler method to be called once search is over.
* Based on search result call success or noresults callbacks
* Based on search result triggers resultsfound or noresults events
* @param query string
*/
resultHandler: function( query ) {
if ( this.resultCount === 0 && this.options.noresults ) {
if ( this.resultCount === 0 ) {
this.$suggestion.val( '' );
this.options.noresults.call( this, query );
} else if ( this.options.success ) {
this.options.success( this, query, this.resultCount );
this.$element.trigger( 'noresults.uls', query );
} else {
this.$element.trigger( 'resultsfound.uls', [query, this.resultCount] );
}
},
@@ -339,8 +339,6 @@
$target: null, // Where to append the results
searchAPI: null,
languages: null, // Languages as code:name format.
noresults: null, // callback for no results found case
success: null, // callback if any results found.
onSelect: null // Language select handler - like enter in filter textbox.
};