From 95912d438c48033857b5ec2419402bd74836bc5a Mon Sep 17 00:00:00 2001 From: Amir Aharoni Date: Thu, 21 Nov 2019 11:33:28 +0200 Subject: [PATCH] Update jquery.uls from upstream * Update linters Updating to https://github.com/wikimedia/jquery.uls/commit/d53beca7193c6793b108fa748f3ca6db08a49fdd Change-Id: Ia7886a13fc17e27344280449d0377e0fa5d0d9f5 --- lib/jquery.uls/css/jquery.uls.lcd.css | 14 +++++++------- lib/jquery.uls/css/jquery.uls.mobile.css | 6 +++++- lib/jquery.uls/src/jquery.uls.core.js | 9 +++++---- .../src/jquery.uls.languagefilter.js | 7 ++++--- lib/jquery.uls/src/jquery.uls.lcd.js | 18 +++++++++--------- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/lib/jquery.uls/css/jquery.uls.lcd.css b/lib/jquery.uls/css/jquery.uls.lcd.css index a97121d5..0154b9bd 100644 --- a/lib/jquery.uls/css/jquery.uls.lcd.css +++ b/lib/jquery.uls/css/jquery.uls.lcd.css @@ -17,7 +17,13 @@ padding: 0 16px; } -.uls-lcd--no-quicklist [data-region="all"] .uls-lcd-region-title { +.uls-lcd-region-title { + color: #555; + font-size: 14px; + padding-left: 28px; +} + +.uls-lcd--no-quicklist [ data-region='all' ] .uls-lcd-region-title { display: none; } @@ -25,12 +31,6 @@ margin-top: 10px; } -.uls-lcd-region-title { - color: #555; - font-size: 14px; - padding-left: 28px; -} - /* * We need to have this as a grid row to push rest of the content below it, but resetting * padding and margin so that calculating them for children is easier. diff --git a/lib/jquery.uls/css/jquery.uls.mobile.css b/lib/jquery.uls/css/jquery.uls.mobile.css index f6ba97bc..76ab0bdb 100644 --- a/lib/jquery.uls/css/jquery.uls.mobile.css +++ b/lib/jquery.uls/css/jquery.uls.mobile.css @@ -1,5 +1,5 @@ +/* stylelint-disable declaration-no-important */ @media only screen and ( max-width: 767px ) { - .uls-mobile.uls-menu { width: 95%; left: 2.5%; @@ -248,6 +248,7 @@ .uls-mobile .hide-for-xlarge { display: block !important; } + .uls-mobile .hide-for-small, .uls-mobile .show-for-medium, .uls-mobile .hide-for-medium-down, @@ -274,6 +275,7 @@ .uls-mobile .hide-for-portrait { display: block !important; } + .uls-mobile .hide-for-landscape, .uls-mobile .show-for-portrait { display: none !important; @@ -285,6 +287,7 @@ .uls-mobile .hide-for-landscape { display: block !important; } + .uls-mobile .hide-for-portrait, .uls-mobile .show-for-landscape { display: none !important; @@ -297,6 +300,7 @@ display: none !important; } +/* stylelint-disable-next-line no-descending-specificity */ .uls-mobile .hide-for-touch, .uls-mobile .touch .show-for-touch { display: block !important; diff --git a/lib/jquery.uls/src/jquery.uls.core.js b/lib/jquery.uls/src/jquery.uls.core.js index e4607878..86615788 100644 --- a/lib/jquery.uls/src/jquery.uls.core.js +++ b/lib/jquery.uls/src/jquery.uls.core.js @@ -149,7 +149,7 @@ this.$menu.addClass( widthClasses[ this.menuWidth ] ); if ( !this.initialized ) { - $( 'body' ).prepend( this.$menu ); + $( document.body ).prepend( this.$menu ); this.i18n(); this.initialized = true; } @@ -160,7 +160,7 @@ this.shown = true; if ( !this.isMobile() ) { - this.$languageFilter.focus(); + this.$languageFilter.trigger( 'focus' ); } this.visible(); @@ -267,8 +267,8 @@ this.$languageFilter.on( 'resultsfound.uls', this.success.bind( this ) ); - $( 'html' ).click( this.cancel.bind( this ) ); - $( window ).resize( $.fn.uls.debounce( this.resize.bind( this ), 250 ) ); + $( document.body ).on( 'click', this.cancel.bind( this ) ); + $( window ).on( 'resize', $.fn.uls.debounce( this.resize.bind( this ), 250 ) ); }, resize: function () { @@ -477,6 +477,7 @@ } else { scrollPosition = panelBottom - windowHeight; } + // eslint-disable-next-line no-jquery/no-global-selector $( 'html, body' ).stop().animate( { scrollTop: scrollPosition }, 500 ); diff --git a/lib/jquery.uls/src/jquery.uls.languagefilter.js b/lib/jquery.uls/src/jquery.uls.languagefilter.js index cdc96c6f..f397aab2 100644 --- a/lib/jquery.uls/src/jquery.uls.languagefilter.js +++ b/lib/jquery.uls/src/jquery.uls.languagefilter.js @@ -103,7 +103,7 @@ e.preventDefault(); e.stopPropagation(); - query = $.trim( this.$element.val() ).toLowerCase(); + query = ( this.$element.val() || '' ).trim().toLowerCase(); if ( this.selectedLanguage ) { // this.selectLanguage will be populated from a matching search @@ -126,7 +126,7 @@ this.$element.val( '' ); if ( !$.fn.uls.Constructor.prototype.isMobile() ) { - this.$element.focus(); + this.$element.trigger( 'focus' ); } this.toggleClear(); @@ -160,7 +160,7 @@ search: function () { var languages = Object.keys( this.options.languages ), results = [], - query = $.trim( this.$element.val() ).toLowerCase(); + query = ( this.$element.val() || '' ).trim().toLowerCase(); if ( query === '' ) { this.options.lcd.setGroupByRegionOverride( null ); @@ -189,6 +189,7 @@ var autofillLabel, results = []; + // eslint-disable-next-line no-jquery/no-each-util $.each( result.languagesearch, function ( apiCode, name ) { var code, redirect; diff --git a/lib/jquery.uls/src/jquery.uls.lcd.js b/lib/jquery.uls/src/jquery.uls.lcd.js index ceadbf15..8462fa5d 100644 --- a/lib/jquery.uls/src/jquery.uls.lcd.js +++ b/lib/jquery.uls/src/jquery.uls.lcd.js @@ -57,7 +57,7 @@ this.$element.addClass( 'uls-lcd' ); this.regionLanguages = {}; this.renderTimeout = null; - this.cachedQuicklist = null; + this.$cachedQuicklist = null; this.groupByRegionOverride = null; this.render(); @@ -327,17 +327,17 @@ buildQuicklist: function () { var quickList, $quickListSection, $quickListSectionTitle; - if ( this.cachedQuicklist !== null ) { - return this.cachedQuicklist; + if ( this.$cachedQuicklist !== null ) { + return this.$cachedQuicklist; } - if ( $.isFunction( this.options.quickList ) ) { + if ( typeof this.options.quickList === 'function' ) { this.options.quickList = this.options.quickList(); } if ( !this.options.quickList.length ) { - this.cachedQuicklist = $( [] ); - return this.cachedQuicklist; + this.$cachedQuicklist = $( [] ); + return this.$cachedQuicklist; } // Pick only the first elements, because we don't have room for more @@ -363,8 +363,8 @@ $quickListSectionTitle.i18n(); - this.cachedQuicklist = $quickListSection; - return this.cachedQuicklist; + this.$cachedQuicklist = $quickListSection; + return this.$cachedQuicklist; }, show: function () { @@ -382,7 +382,7 @@ }, focus: function () { - this.$element.focus(); + this.$element.trigger( 'focus' ); }, /**