Santhosh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/64553
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(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UniversalLanguageSelector
refs/changes/53/64553/1
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: newchange
Gerrit-Change-Id: I3aec168457190b7bfb40c09c97252e0cbb3dd1de
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits