jenkins-bot has submitted this change and it was merged.
Change subject: Scroll the ULS panel into view automatically
......................................................................
Scroll the ULS panel into view automatically
Change-Id: I9c46fcaaa13de62147ca0a8151e4e8706a6b09ee
---
M resources/js/ext.uls.interface.js
1 file changed, 35 insertions(+), 3 deletions(-)
Approvals:
Nikerabbit: Looks good to me, approved
Pginer: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/resources/js/ext.uls.interface.js
b/resources/js/ext.uls.interface.js
index 05cb010..3c9db38 100644
--- a/resources/js/ext.uls.interface.js
+++ b/resources/js/ext.uls.interface.js
@@ -22,6 +22,7 @@
$( document ).ready( function () {
var $ulsTrigger, $pLang,
+ uls, ulsOptions,
previousLanguages, previousLang,
ulsPosition = mw.config.get( 'wgULSPosition' ),
tipsyGravity = {
@@ -118,7 +119,7 @@
} );
}
- $ulsTrigger.uls( {
+ ulsOptions = {
onReady: function () {
if ( $.fn.languagesettings ) {
addDisplaySettings( this );
@@ -133,11 +134,42 @@
quickList: function () {
return mw.uls.getFrequentLanguageList();
}
- } );
+ };
if ( ulsPosition === 'interlanguage' ) {
$ulsTrigger.attr( 'title', $.i18n(
'ext-uls-select-language-settings-icon-tooltip' ) );
+
+ // This is a hook that runs in the ULS scope
+ ulsOptions.onVisible = function () {
+ var scrollPosition,
+ padding = 10,
+ $window = $( window ),
+ windowHeight = $window.height(),
+ windowScrollTop = $window.scrollTop(),
+ windowBottom = windowScrollTop +
windowHeight,
+ ulsHeight = this.$menu.height(),
+ ulsTop = this.$menu.offset().top,
+ ulsBottom = ulsTop + ulsHeight;
+
+ if ( ( ulsTop < windowScrollTop ) || (
ulsBottom > windowBottom ) ) {
+ if ( ulsHeight > windowHeight ) {
+ // Scroll to show as much of
the upper
+ // side of ULS as possible
+ scrollPosition = ulsTop -
padding;
+ } else {
+ scrollPosition = ulsBottom -
windowHeight + padding;
+ }
+
+ $( 'html, body' ).stop().animate( {
+ scrollTop: scrollPosition
+ }, 500 );
+ }
+ }
}
+
+ $ulsTrigger.uls( ulsOptions );
+
+ uls = $ulsTrigger.data( 'uls' );
if ( !previousLang ) {
previousLanguages.push( currentLang );
@@ -212,7 +244,7 @@
// manually show the tooltip
$ulsTrigger.on( 'mouseover', function () {
// show only if the ULS panel is not shown
- if ( !$ulsTrigger.data( 'uls' ).shown ) {
+ if ( !uls.shown ) {
showTipsy( 3000 );
}
} );
--
To view, visit https://gerrit.wikimedia.org/r/60574
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9c46fcaaa13de62147ca0a8151e4e8706a6b09ee
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Amire80 <[email protected]>
Gerrit-Reviewer: Amire80 <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Pginer <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits