Editor scrolling: Remember and restore scroll position for visual and text modes.
This prevents the editor from jumping off screen when the rendered visual content is significantly taller than plain text, e.g. when there are views present. This is also a close restoration of 3.9 behavior, some of which was browser-specific. props avryl. fixes #29338. Built from https://develop.svn.wordpress.org/trunk@29693 git-svn-id: http://core.svn.wordpress.org/trunk@29468 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0f73f0bea3
commit
c8cdcef9be
|
@ -31,6 +31,8 @@ jQuery( document ).ready( function($) {
|
||||||
fixedSideBottom = false,
|
fixedSideBottom = false,
|
||||||
scrollTimer,
|
scrollTimer,
|
||||||
lastScrollPosition = 0,
|
lastScrollPosition = 0,
|
||||||
|
visualEditorScrollPosition = 0,
|
||||||
|
textEditorScrollPosition = 0,
|
||||||
pageYOffsetAtTop = 130,
|
pageYOffsetAtTop = 130,
|
||||||
pinnedToolsTop = 56,
|
pinnedToolsTop = 56,
|
||||||
sidebarBottom = 20,
|
sidebarBottom = 20,
|
||||||
|
@ -224,20 +226,35 @@ jQuery( document ).ready( function($) {
|
||||||
|
|
||||||
// Adjust when switching editor modes.
|
// Adjust when switching editor modes.
|
||||||
function mceShow() {
|
function mceShow() {
|
||||||
|
textEditorScrollPosition = window.pageYOffset;
|
||||||
|
|
||||||
setTimeout( function() {
|
setTimeout( function() {
|
||||||
|
var top = $contentWrap.offset().top;
|
||||||
|
|
||||||
|
if ( window.pageYOffset > top || visualEditorScrollPosition ) {
|
||||||
|
window.scrollTo( window.pageXOffset, visualEditorScrollPosition ? visualEditorScrollPosition : top - heights.adminBarHeight );
|
||||||
|
}
|
||||||
|
|
||||||
editor.execCommand( 'wpAutoResize' );
|
editor.execCommand( 'wpAutoResize' );
|
||||||
adjust();
|
adjust();
|
||||||
}, 300 );
|
}, 300 );
|
||||||
|
|
||||||
|
adjust();
|
||||||
}
|
}
|
||||||
|
|
||||||
function mceHide() {
|
function mceHide() {
|
||||||
var wrapHeight = $( '#wpwrap' ).height();
|
visualEditorScrollPosition = window.pageYOffset;
|
||||||
|
|
||||||
|
setTimeout( function() {
|
||||||
|
var top = $contentWrap.offset().top;
|
||||||
|
|
||||||
|
if ( window.pageYOffset > top || textEditorScrollPosition ) {
|
||||||
|
window.scrollTo( window.pageXOffset, textEditorScrollPosition ? textEditorScrollPosition : top - heights.adminBarHeight );
|
||||||
|
}
|
||||||
|
|
||||||
textEditorResize();
|
textEditorResize();
|
||||||
|
adjust();
|
||||||
if ( wrapHeight && $window.scrollTop() > wrapHeight ) {
|
}, 100 );
|
||||||
window.scrollTo( window.pageXOffset, wrapHeight - 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
adjust();
|
adjust();
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue