jenkins-bot has submitted this change and it was merged.

Change subject: Scroll the window to show language settings if necessary
......................................................................


Scroll the window to show language settings if necessary

Restores the feature removed while refactoring in
Iafb15ac9a7140fcce9e71ed933be6c55be81dc7e

Change-Id: I3aec168457190b7bfb40c09c97252e0cbb3dd1de
---
M resources/js/ext.uls.languagesettings.js
1 file changed, 23 insertions(+), 3 deletions(-)

Approvals:
  Amire80: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/resources/js/ext.uls.languagesettings.js 
b/resources/js/ext.uls.languagesettings.js
index 6e17954..9167dab 100644
--- a/resources/js/ext.uls.languagesettings.js
+++ b/resources/js/ext.uls.languagesettings.js
@@ -158,18 +158,38 @@
                },
 
                position: function () {
-                       var top, pos, left;
+                       var top, pos, left, bottom, height,
+                               $window = $( window ),
+                               windowHeight = $window.height(),
+                               windowScrollTop = $window.scrollTop(),
+                               windowBottom = windowScrollTop + windowHeight,
+                               scrollPosition;
                        pos = $.extend( {}, this.$element.offset(), {
                                        height: this.$element[0].offsetHeight
                                } );
                        top = this.top || pos.top + pos.height;
                        left = this.left || '25%';
-                       // FIXME this is not exactly correct. position may not
-                       // be relative to the trigger.
                        this.$window.css( {
                                top: top,
                                left: left
                        } );
+
+                       height = this.$window.height();
+                       bottom = top + height;
+                       // If the language settings windpw is out of the 
viewport,
+                       // scroll the window to show it
+                       if ( ( top < windowScrollTop ) || ( bottom > 
windowBottom ) ) {
+                               if ( height > windowHeight ) {
+                                       // Scroll to show as much of the upper 
part of window as possible
+                                       scrollPosition = top;
+                               } else {
+                                       // Scroll just enough to show the 
language settings window.
+                                       scrollPosition = bottom - windowHeight;
+                               }
+                               $( 'html, body' ).stop().animate( {
+                                       scrollTop: scrollPosition
+                               }, 500 );
+                       }
                },
 
                show: function () {

-- 
To view, visit https://gerrit.wikimedia.org/r/64553
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3aec168457190b7bfb40c09c97252e0cbb3dd1de
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>
Gerrit-Reviewer: Amire80 <amir.ahar...@mail.huji.ac.il>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to