diff --git a/src/jquery.uls.languagefilter.js b/src/jquery.uls.languagefilter.js index 4856b84..3ce59fd 100644 --- a/src/jquery.uls.languagefilter.js +++ b/src/jquery.uls.languagefilter.js @@ -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 ); } ); }, diff --git a/src/jquery.uls.lcd.js b/src/jquery.uls.lcd.js index 332882c..56741ec 100644 --- a/src/jquery.uls.lcd.js +++ b/src/jquery.uls.lcd.js @@ -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 = $( '