Merge "Scroll language settings on all changes"

This commit is contained in:
jenkins-bot
2013-05-16 09:52:35 +00:00
committed by Gerrit Code Review
2 changed files with 70 additions and 5 deletions

View File

@@ -553,7 +553,14 @@
} );
$tabButtons.on( 'click', function () {
var $button = $( this );
var scrollPosition,
panelHeight, panelTop, panelBottom,
padding,
$window,
windowHeight,
windowScrollTop,
windowBottom,
$button = $( this );
if ( $button.hasClass( 'down' ) ) {
return;
@@ -571,6 +578,33 @@
$tabButtons.filter( '.down' ).removeClass( 'down');
$button.addClass( 'down' );
padding = 10;
$window = $( window );
windowHeight = $window.height();
windowScrollTop = $window.scrollTop();
windowBottom = windowScrollTop + windowHeight;
panelHeight = displaySettings.$parent.$window.height();
panelTop = displaySettings.$parent.$window.offset().top;
panelBottom = panelTop + panelHeight;
// If the ULS panel is out of the viewport,
// scroll the window to show it
if ( ( panelTop < windowScrollTop ) || ( panelBottom > windowBottom ) ) {
if ( panelHeight > windowHeight ) {
// Scroll to show as much of the upper
// part of ULS as possible
scrollPosition = panelTop - padding;
} else {
// Scroll just enough to show the ULS panel
scrollPosition = panelBottom - windowHeight + padding;
}
$( 'html, body' ).stop().animate( {
scrollTop: scrollPosition
}, 500 );
}
} );
},