Rename "that = this" to meaningful names

This commit is contained in:
Amir E. Aharoni
2012-11-29 10:40:24 +02:00
parent b34cbbe9d2
commit 7a04c3c6e0
3 changed files with 35 additions and 32 deletions

View File

@@ -93,7 +93,7 @@
break;
default:
var that = this;
var languageFilter = this;
if ( e.which < 32 ) {
// ignore any ASCII control characters
@@ -103,11 +103,11 @@
this.selectedLanguage = null;
delay( function() {
if ( !that.$element.val() ) {
that.clear();
if ( !languageFilter.$element.val() ) {
languageFilter.clear();
} else {
that.options.$target.empty();
that.search();
languageFilter.options.$target.empty();
languageFilter.search();
}
}, 300 );
@@ -194,18 +194,18 @@
},
searchAPI: function( query ) {
var that = this;
var languageFilter = this;
$.get( that.options.searchAPI, { search: query }, function( result ) {
$.get( languageFilter.options.searchAPI, { search: query }, function( result ) {
$.each( result['languagesearch'], function( code, name ) {
if ( that.resultCount === 0 ) {
if ( languageFilter.resultCount === 0 ) {
// Autofill the first result.
that.autofill( code, name );
languageFilter.autofill( code, name );
}
that.render( code );
that.resultCount++;
languageFilter.render( code );
languageFilter.resultCount++;
} );
that.resultHandler( query );
languageFilter.resultHandler( query );
} );
},

View File

@@ -72,8 +72,8 @@
* @param region Optional region
*/
addToRegion: function( langCode, region ) {
var that = this;
var language = that.options.languages[langCode],
var lcd = this,
language = lcd.options.languages[langCode],
langName = $.uls.data.getAutonym( langCode ) || language || langCode,
regions = [];
@@ -102,7 +102,7 @@
);
// Append the element to the column in the list
var $column = that.getColumn( regionCode );
var $column = lcd.getColumn( regionCode );
var lastLanguage = $column.find( 'li:last' ).data( 'code' );
if ( lastLanguage ) {
@@ -112,7 +112,7 @@
if ( lastScriptGroup !== currentScriptGroup ) {
if ( $column.find( 'li' ).length > 2 ) {
// If column already has 2 or more languages, add a new column
$column = that.getColumn( regionCode, true );
$column = lcd.getColumn( regionCode, true );
}
}
}
@@ -152,28 +152,30 @@
},
render: function() {
var that = this;
var $section, $sectionTitle;
var regions = {
// These are fallback text when i18n library not present
WW: 'Worldwide',
AM: 'America',
EU: 'Europe',
ME: 'Middle East',
AS: 'Asia',
AF: 'Africa',
PA: 'Pacific'
};
var $section, $sectionTitle,
lcd = this,
regions = {
// These are fallback text when i18n library not present
WW: 'Worldwide',
AM: 'America',
EU: 'Europe',
ME: 'Middle East',
AS: 'Asia',
AF: 'Africa',
PA: 'Pacific'
};
$.each( $.uls.data.regiongroups, function( regionCode, regionIndex ) {
$section = $( '<div>' ).addClass( 'twelve columns uls-lcd-region-section' ).prop( 'id', regionCode );
$sectionTitle = $( '<h3 data-i18n="uls-region-'+ regionCode+'">' )
.addClass( 'eleven columns uls-lcd-region-section uls-lcd-region-title offset-by-one' )
.text( regions[regionCode] );
$section.append( $sectionTitle );
that.$element.append( $section );
lcd.$element.append( $section );
$section.hide();
that.regionDivs[regionCode] = $section;
lcd.regionDivs[regionCode] = $section;
} );
this.$noResults.hide();
this.i18n();
},

View File

@@ -104,10 +104,11 @@
if ( !this.$element.hasClass( 'active') ) {
return true;
}
var that = this;
var regionSelector = this;
// Do not respond to all scroll end events, but only after a short interval
delay( function () {
var regiongroup = that.$element.data( 'regiongroup' );
var regiongroup = regionSelector.$element.data( 'regiongroup' );
var nextRegiongroup = regiongroup + 1;
var $nextRegion = $( '#uls-region-' + nextRegiongroup );