Consistently use this when scope allows it

We have uls = this for scoping, but then we randomly switch between the two, even when 'this' is allowed. We only need to used the local variable in un-proxied anonymous functions.
This commit is contained in:
Ed S
2014-04-22 14:59:46 -07:00
parent 0d34e864c6
commit f0be8b5425

View File

@@ -242,46 +242,46 @@
uls = this; uls = this;
// Register all event listeners to the ULS here. // Register all event listeners to the ULS here.
uls.$element.on( 'click', $.proxy( uls.click, uls ) ); this.$element.on( 'click', $.proxy( this.click, this ) );
uls.$languageFilter.on( 'searchclear.uls', $.proxy( uls.defaultSearch, uls ) ); this.$languageFilter.on( 'searchclear.uls', $.proxy( this.defaultSearch, this ) );
uls.$languageFilter.on( 'noresults.uls', $.proxy( uls.noresults, uls ) ); this.$languageFilter.on( 'noresults.uls', $.proxy( this.noresults, this ) );
uls.$languageFilter.on( 'resultsfound.uls', $.proxy( uls.success, uls ) ); this.$languageFilter.on( 'resultsfound.uls', $.proxy( this.success, this ) );
// Close when clicking on the close button // Close when clicking on the close button
uls.$menu.find( '#uls-close' ).on( 'click', $.proxy( uls.cancel, uls ) ); this.$menu.find( '#uls-close' ).on( 'click', $.proxy( this.cancel, this ) );
// Don't do anything if pressing on empty space in the ULS // Don't do anything if pressing on empty space in the ULS
uls.$menu.on( 'click', function ( e ) { this.$menu.on( 'click', function ( e ) {
e.stopPropagation(); e.stopPropagation();
} ); } );
// Handle key press events on the menu // Handle key press events on the menu
uls.$menu.on( 'keypress', $.proxy( this.keypress, this ) ) this.$menu.on( 'keypress', $.proxy( this.keypress, this ) )
.on( 'keyup', $.proxy( this.keyup, this ) ); .on( 'keyup', $.proxy( this.keyup, this ) );
if ( this.eventSupported( 'keydown' ) ) { if ( this.eventSupported( 'keydown' ) ) {
this.$menu.on( 'keydown', $.proxy( this.keypress, this ) ); this.$menu.on( 'keydown', $.proxy( this.keypress, this ) );
} }
lcd = uls.$resultsView.lcd( { lcd = this.$resultsView.lcd( {
languages: uls.languages, languages: this.languages,
quickList: uls.options.quickList, quickList: this.options.quickList,
clickhandler: $.proxy( uls.select, uls ), clickhandler: $.proxy( this.select, this ),
source: uls.$languageFilter, source: this.$languageFilter,
showRegions: uls.options.showRegions showRegions: this.options.showRegions
} ).data( 'lcd' ); } ).data( 'lcd' );
uls.$languageFilter.languagefilter( { this.$languageFilter.languagefilter( {
$target: lcd, $target: lcd,
languages: uls.languages, languages: this.languages,
searchAPI: uls.options.searchAPI, searchAPI: this.options.searchAPI,
onSelect: $.proxy( uls.select, uls ) onSelect: $.proxy( this.select, this )
} ); } );
// Create region selectors, one per region // Create region selectors, one per region
this.$menu.find( '.uls-region, .uls-region-link' ).regionselector( { this.$menu.find( '.uls-region, .uls-region-link' ).regionselector( {
$target: lcd, $target: lcd,
languages: uls.languages, languages: this.languages,
success: function ( regionfilter ) { success: function ( regionfilter ) {
// Deactivate search filtering // Deactivate search filtering
uls.$languageFilter.languagefilter( 'deactivate' ); uls.$languageFilter.languagefilter( 'deactivate' );