[MediaWiki-commits] [Gerrit] mediawiki...VisualEditor[master]: After saving a specific section, scroll to it
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/329119 ) Change subject: After saving a specific section, scroll to it .. After saving a specific section, scroll to it Bug: T153297 Change-Id: I233e5226abc44d5d0bf8e56957a133d595e7be6f --- M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js 1 file changed, 18 insertions(+), 1 deletion(-) Approvals: jenkins-bot: Verified Jforrester: Looks good to me, approved diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js index ac5819a..b08a3b5 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js @@ -1436,7 +1436,7 @@ 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 @@ -1498,6 +1498,23 @@ $( '.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 ); + } + } }; /** -- To view, visit https://gerrit.wikimedia.org/r/329119 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I233e5226abc44d5d0bf8e56957a133d595e7be6f Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Alex MonkGerrit-Reviewer: Jforrester Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] mediawiki...VisualEditor[master]: After saving a specific section, scroll to it
Alex Monk has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/329119 ) Change subject: After saving a specific section, scroll to it .. After saving a specific section, scroll to it Bug: T153297 Change-Id: I233e5226abc44d5d0bf8e56957a133d595e7be6f --- M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js 1 file changed, 17 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/19/329119/1 diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js index ac5819a..33da804 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js @@ -1436,7 +1436,7 @@ 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 @@ -1498,6 +1498,22 @@ $( '.redirectMsg' ) .addClass( 'mw-content-' + $( 'html' ).attr( 'dir' ) ) .addClass( 've-redirect-header' ); + + 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 ); + } + } }; /** -- To view, visit https://gerrit.wikimedia.org/r/329119 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I233e5226abc44d5d0bf8e56957a133d595e7be6f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Alex Monk___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits