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

@@ -224,6 +224,7 @@
* Callback for no results found context.
*/
noresults: function () {
$( '.regionselector' ).removeClass( 'active' );
this.$resultsView.lcd( 'noResults' );
},
@@ -231,6 +232,7 @@
* callback for results found context.
*/
success: function () {
$( '.regionselector' ).removeClass( 'active' );
this.$resultsView.show();
},
@@ -244,7 +246,9 @@
// Register all event listeners to the ULS here.
uls.$element.on( 'click', $.proxy( uls.click, uls ) );
uls.$languageFilter.on( 'searchclear', $.proxy( uls.defaultSearch, uls ) );
uls.$languageFilter.on( 'searchclear.uls', $.proxy( uls.defaultSearch, uls ) );
uls.$languageFilter.on( 'noresults.uls', $.proxy( uls.noresults, uls ) );
uls.$languageFilter.on( 'resultsfound.uls', $.proxy( uls.success, uls ) );
// Close when clicking on the close button
uls.$menu.find( '#uls-close' ).on( 'click', $.proxy( uls.cancel, uls ) );
@@ -272,14 +276,6 @@
uls.$languageFilter.languagefilter( {
$target: lcd,
languages: uls.languages,
success: function () {
$( '.regionselector' ).removeClass( 'active' );
uls.success();
},
noresults: function () {
$( '.regionselector' ).removeClass( 'active' );
uls.noresults();
},
searchAPI: uls.options.searchAPI,
onSelect: $.proxy( uls.select, uls )
} );