Remove lot of scroll to view related code
Just use javascript scrollIntoView to do that. Also remove duplication of code related to this Change-Id: Ied1235a85f4fe2d99afa127737979c24d3591118
This commit is contained in:
committed by
Gerrit Code Review
parent
4021b72812
commit
73716f3f67
@@ -485,14 +485,7 @@
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
$tabButtons.on( 'click', function () {
|
$tabButtons.on( 'click', function () {
|
||||||
var scrollPosition,
|
var $button = $( this );
|
||||||
panelHeight, panelTop, panelBottom,
|
|
||||||
padding,
|
|
||||||
$window,
|
|
||||||
windowHeight,
|
|
||||||
windowScrollTop,
|
|
||||||
windowBottom,
|
|
||||||
$button = $( this );
|
|
||||||
|
|
||||||
if ( $button.hasClass( 'down' ) ) {
|
if ( $button.hasClass( 'down' ) ) {
|
||||||
return;
|
return;
|
||||||
@@ -508,35 +501,10 @@
|
|||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
displaySettings.$parent.position();
|
||||||
$tabButtons.filter( '.down' ).removeClass( 'down');
|
$tabButtons.filter( '.down' ).removeClass( 'down');
|
||||||
$button.addClass( '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 );
|
|
||||||
}
|
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -600,4 +568,3 @@
|
|||||||
display: DisplaySettings
|
display: DisplaySettings
|
||||||
} );
|
} );
|
||||||
})( jQuery, mediaWiki );
|
})( jQuery, mediaWiki );
|
||||||
|
|
||||||
|
|||||||
@@ -502,4 +502,3 @@
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
} ( jQuery, mediaWiki ) );
|
} ( jQuery, mediaWiki ) );
|
||||||
|
|
||||||
|
|||||||
@@ -115,38 +115,11 @@
|
|||||||
$settingsMenuItems.append( $settingsLink );
|
$settingsMenuItems.append( $settingsLink );
|
||||||
|
|
||||||
$settingsLink.on( 'click', function () {
|
$settingsLink.on( 'click', function () {
|
||||||
var scrollPosition,
|
var module = $( this ).data( 'module' );
|
||||||
panelHeight, panelTop, panelBottom,
|
|
||||||
padding = 10,
|
|
||||||
$window = $( window ),
|
|
||||||
windowHeight = $window.height(),
|
|
||||||
windowScrollTop = $window.scrollTop(),
|
|
||||||
windowBottom = windowScrollTop + windowHeight,
|
|
||||||
module = $( this ).data( 'module' );
|
|
||||||
|
|
||||||
module.render();
|
module.render();
|
||||||
|
// re-position the window and scroll in to view if required.
|
||||||
panelHeight = languageSettings.$window.height();
|
languageSettings.position();
|
||||||
panelTop = languageSettings.$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 );
|
|
||||||
}
|
|
||||||
|
|
||||||
$settingsMenuItems.find( '.menu-section' ).removeClass( 'active' );
|
$settingsMenuItems.find( '.menu-section' ).removeClass( 'active' );
|
||||||
$( this ).addClass( 'active' );
|
$( this ).addClass( 'active' );
|
||||||
} );
|
} );
|
||||||
@@ -158,12 +131,8 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
position: function () {
|
position: function () {
|
||||||
var top, pos, left, bottom, height,
|
var top, pos, left;
|
||||||
$window = $( window ),
|
|
||||||
windowHeight = $window.height(),
|
|
||||||
windowScrollTop = $window.scrollTop(),
|
|
||||||
windowBottom = windowScrollTop + windowHeight,
|
|
||||||
scrollPosition;
|
|
||||||
pos = $.extend( {}, this.$element.offset(), {
|
pos = $.extend( {}, this.$element.offset(), {
|
||||||
height: this.$element[0].offsetHeight
|
height: this.$element[0].offsetHeight
|
||||||
} );
|
} );
|
||||||
@@ -173,23 +142,7 @@
|
|||||||
top: top,
|
top: top,
|
||||||
left: left
|
left: left
|
||||||
} );
|
} );
|
||||||
|
this.$window[0].scrollIntoView();
|
||||||
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 () {
|
show: function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user