Remove unused variable and add uls prefix for CSS class

This commit is contained in:
Abijeet
2023-01-16 14:52:13 +05:30
committed by Niklas Laxström
parent 606697ae7c
commit cfbfc5d2ff
2 changed files with 10 additions and 11 deletions

View File

@@ -139,6 +139,6 @@
left: 0; left: 0;
} }
.language-option--highlighted { .uls-language-option--highlighted {
background-color: #eaeff7; background-color: #eaeff7;
} }

View File

@@ -55,14 +55,13 @@
this.$element.addClass( 'uls-lcd' ); this.$element.addClass( 'uls-lcd' );
this.regionLanguages = {}; this.regionLanguages = {};
this.$languageOptionListItems = null;
this.renderTimeout = null; this.renderTimeout = null;
this.$cachedQuicklist = null; this.$cachedQuicklist = null;
this.groupByRegionOverride = null; this.groupByRegionOverride = null;
// The index of the language option that is currently visited using arrow key navigation // The index of the language option that is currently visited using arrow key navigation
// Can take values in the [0, languageOptionListItemsLength - 1] range for top to bottom // Can take values in the [0, language options list item length - 1] range for top to bottom
// navigation, or in the [-1, -languageOptionListItemsLength + 1] range for bottom to top // navigation, or in the [-1, -language options list item length + 1] range for bottom to top
// navigation. // navigation.
this.navigationIndex = null; this.navigationIndex = null;
@@ -104,7 +103,7 @@
// We support navigation starting both from the top and the bottom of the language list. // We support navigation starting both from the top and the bottom of the language list.
// The navigation should stop when the last language option is already highlighted (for // The navigation should stop when the last language option is already highlighted (for
// top to bottom navigation). For top to bottom navigation, that happens when navigation // top to bottom navigation). For top to bottom navigation, that happens when navigation
// index is equal to languageOptionListItemsLength - 1. For bottom to top navigation, // index is equal to language options list item length - 1. For bottom to top navigation,
// that happens when navigation index is equal to -1. // that happens when navigation index is equal to -1.
if ( this.navigationIndex === maxIndex || this.navigationIndex === -1 ) { if ( this.navigationIndex === maxIndex || this.navigationIndex === -1 ) {
return; return;
@@ -140,15 +139,15 @@
}, },
/** /**
* Adds a specific class ("language-option--highlighted") only to the n-th * Adds a specific class ("uls-language-option--highlighted") only to the n-th
* language option <li> element (where n = navigation index) * language option <li> element (where n = navigation index)
*/ */
highlightLanguageOption: function () { highlightLanguageOption: function () {
var $listItems = this.getLanguageOptionListItems(); var $listItems = this.getLanguageOptionListItems();
$listItems.removeClass( 'language-option--highlighted' ); $listItems.removeClass( 'uls-language-option--highlighted' );
var $selectedItem = $listItems.eq( this.navigationIndex ); var $selectedItem = $listItems.eq( this.navigationIndex );
$selectedItem.addClass( 'language-option--highlighted' ); $selectedItem.addClass( 'uls-language-option--highlighted' );
// If the selected item is not visible, then scroll the container to display it // If the selected item is not visible, then scroll the container to display it
if ( !isLanguageFullyVisible( $selectedItem, this.$element ) ) { if ( !isLanguageFullyVisible( $selectedItem, this.$element ) ) {
@@ -529,12 +528,12 @@
this.$element.on( 'mouseenter', 'li[data-code]', function () { this.$element.on( 'mouseenter', 'li[data-code]', function () {
var $listItems = lcd.getLanguageOptionListItems(); var $listItems = lcd.getLanguageOptionListItems();
// Remove the previous option, and then highlight the current one. // Remove the previous option, and then highlight the current one.
$listItems.removeClass( 'language-option--highlighted' ); $listItems.removeClass( 'uls-language-option--highlighted' );
var $self = $( this ); var $self = $( this );
$self.addClass( 'language-option--highlighted' ); $self.addClass( 'uls-language-option--highlighted' );
lcd.navigationIndex = $listItems.index( $self ); lcd.navigationIndex = $listItems.index( $self );
} ).on( 'mouseleave', 'li[data-code]', function () { } ).on( 'mouseleave', 'li[data-code]', function () {
$( this ).removeClass( 'language-option--highlighted' ); $( this ).removeClass( 'uls-language-option--highlighted' );
lcd.navigationIndex = null; lcd.navigationIndex = null;
} ); } );