mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 23:05:35 +00:00
Merge "After saving a specific section, scroll to it"
This commit is contained in:
commit
945d3d4cbc
|
@ -1448,7 +1448,7 @@ ve.init.mw.DesktopArticleTarget.prototype.replacePageContent = function (
|
|||
html, categoriesHtml, displayTitle, lastModified, contentSub, isRedirect
|
||||
) {
|
||||
var $content = $( $.parseHTML( html ) ),
|
||||
$veSectionLinks, $categories;
|
||||
$veSectionLinks, $categories, $sections, editedSectionHeader;
|
||||
|
||||
if ( lastModified ) {
|
||||
// If we were not viewing the most recent revision before (a requirement
|
||||
|
@ -1510,6 +1510,23 @@ ve.init.mw.DesktopArticleTarget.prototype.replacePageContent = function (
|
|||
$( '.redirectMsg' )
|
||||
.addClass( 'mw-content-' + $( 'html' ).attr( 'dir' ) )
|
||||
.addClass( 've-redirect-header' );
|
||||
|
||||
// Scroll the page to the edited section, if any
|
||||
if ( this.section !== null ) {
|
||||
$sections = $( '#mw-content-text' )
|
||||
.find( 'h1, h2, h3, h4, h5, h6' )
|
||||
.not( '#toc h2' );
|
||||
if ( this.section === 'new' ) {
|
||||
editedSectionHeader = $sections.last().get( 0 );
|
||||
} else if ( this.section > 0 ) {
|
||||
editedSectionHeader = $sections.get( this.section - 1 );
|
||||
}
|
||||
if ( editedSectionHeader ) {
|
||||
setTimeout( function () {
|
||||
OO.ui.Element.static.scrollIntoView( editedSectionHeader );
|
||||
}, 0 );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue