Ticket #29492: 29492.2.patch
| File 29492.2.patch, 1.9 KB (added by , 11 years ago) |
|---|
-
src/wp-admin/js/editor-expand.js
31 31 fixedSideTop = false, 32 32 fixedSideBottom = false, 33 33 scrollTimer, 34 scrollRatio = 0, 34 35 lastScrollPosition = 0, 35 36 pageYOffsetAtTop = 130, 36 37 pinnedToolsTop = 56, … … 255 256 setTimeout( function() { 256 257 editor.execCommand( 'wpAutoResize' ); 257 258 adjust(); 259 260 if ( scrollRatio ) { 261 window.scrollTo( window.pageXOffset, $document.height() * scrollRatio ); 262 scrollRatio = 0; 263 } 258 264 }, 300 ); 259 265 } 260 266 … … 270 276 271 277 textEditorResize(); 272 278 adjust(); 279 280 if ( scrollRatio ) { 281 window.scrollTo( window.pageXOffset, $document.height() * scrollRatio ); 282 scrollRatio = 0; 283 } 273 284 }, 100 ); 274 285 275 286 adjust(); … … 622 633 scrollTimer = setTimeout( adjust, 100 ); 623 634 } 624 635 636 function getScrollRatio() { 637 if ( lastScrollPosition ) { 638 scrollRatio = lastScrollPosition / $document.height(); 639 } else { 640 scrollRatio = 0; 641 } 642 } 643 625 644 function on() { 626 645 // Scroll to the top when triggering this from JS. 627 646 // Ensures toolbars are pinned properly. … … 629 648 window.scrollTo( window.pageXOffset, 0 ); 630 649 } 631 650 632 $wrap.addClass( 'wp-editor-expand' ) ;651 $wrap.addClass( 'wp-editor-expand' ).on( 'mousedown.editor-expand', '.wp-switch-editor', getScrollRatio ); 633 652 634 653 // Adjust when the window is scrolled or resized. 635 654 $window.on( 'scroll.editor-expand resize.editor-expand', function( event ) { … … 690 709 window.scrollTo( window.pageXOffset, 0 ); 691 710 } 692 711 693 $wrap.removeClass( 'wp-editor-expand' ) ;712 $wrap.removeClass( 'wp-editor-expand' ).off( 'mousedown.editor-expand' ); 694 713 695 714 $window.off( '.editor-expand' ); 696 715 $document.off( '.editor-expand' );