jenkins-bot has submitted this change and it was merged. Change subject: Revert "Revert "Preserve textarea state when building WikiEditor UI"" ......................................................................
Revert "Revert "Preserve textarea state when building WikiEditor UI"" Ib97f47ef1d66420682bd429c9c12e66c3392e77d Didn't cause problems so this is now safe to reapply (to wmf2). This reverts commit 908e7cc56c4ef5db2ab0d213b2dbd8c8034a0da7. Change-Id: I510536959b58ff0adacd7908f6150c95bfdb3ec1 --- M modules/jquery.wikiEditor.js 1 file changed, 11 insertions(+), 0 deletions(-) Approvals: TheDJ: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/jquery.wikiEditor.js b/modules/jquery.wikiEditor.js index c414e19..0b87409 100644 --- a/modules/jquery.wikiEditor.js +++ b/modules/jquery.wikiEditor.js @@ -486,6 +486,9 @@ .append( $( '<span>' + mediaWiki.msg( 'wikieditor-loading' ) + '</span>' ) .css( 'marginTop', context.$textarea.height() / 2 ) ); */ + /* Preserving cursor and focus state, which will get lost due to wrapAll */ + var hasFocus = context.$textarea.is( ':focus' ), + cursorPos = context.$textarea.textSelection( 'getCaretPosition', { startAndEnd: true } ); // Encapsulate the textarea with some containers for layout context.$textarea /* Disabling our loading div for now @@ -497,6 +500,14 @@ .wrapAll( $( '<div>' ).addClass( 'wikiEditor-ui-left' ) ) .wrapAll( $( '<div>' ).addClass( 'wikiEditor-ui-bottom' ) ) .wrapAll( $( '<div>' ).addClass( 'wikiEditor-ui-text' ) ); + // Restore scroll position after this wrapAll (tracked by mediawiki.action.edit) + context.$textarea.prop( 'scrollTop', $( '#wpScrolltop' ).val() ); + // Restore focus and cursor if needed + if ( hasFocus ) { + context.$textarea.focus(); + context.$textarea.textSelection( 'setSelection', { start: cursorPos[0], end: cursorPos[1] } ); + } + // Get references to some of the newly created containers context.$ui = context.$textarea.parent().parent().parent().parent().parent(); context.$wikitext = context.$textarea.parent().parent().parent().parent(); -- To view, visit https://gerrit.wikimedia.org/r/130514 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I510536959b58ff0adacd7908f6150c95bfdb3ec1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikiEditor Gerrit-Branch: master Gerrit-Owner: Mwalker <mwal...@wikimedia.org> Gerrit-Reviewer: Bartosz DziewoĆski <matma....@gmail.com> Gerrit-Reviewer: Greg Grossmeier <g...@wikimedia.org> Gerrit-Reviewer: TheDJ <hartman.w...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits