Make WordPress Core

Ticket #29338: 29338.4.patch

File 29338.4.patch, 1.4 KB (added by azaozz, 11 years ago)
  • src/wp-admin/js/editor-expand.js

     
    223223                }
    224224
    225225                function mceHide() {
    226                         var wrapHeight = $( '#wpwrap' ).height();
    227 
    228226                        textEditorResize();
    229227
    230                         if ( wrapHeight && $window.scrollTop() > wrapHeight ) {
    231                                 window.scrollTo( window.pageXOffset, wrapHeight - 1 );
    232                         }
     228                        window.setTimeout( function() {
     229                                var wrapHeight = $( '#wpwrap' ).height(),
     230                                        windowPos = $window.scrollTop(),
     231                                        iframeHeight = $('#content_ifr').height(),
     232                                        textareaHeight = $textEditor.height(),
     233                                        scroll, topPos;
    233234
    234                         adjust();
     235                                if ( iframeHeight > textareaHeight && ( windowPos + heights.windowHeight ) > ( textareaHeight + $textEditor.offset().top ) ) {
     236                                        scroll = iframeHeight - textareaHeight - 1;
     237                                        topPos = $textEditor.parent().offset().top - heights.toolsHeight - heights.adminBarHeight;
     238
     239                                        if ( windowPos - scroll < topPos ) {
     240                                                window.scrollTo( window.pageXOffset, topPos );
     241                                        } else {
     242                                                window.scrollBy( 0, -scroll );
     243                                        }
     244
     245                                        adjust();
     246                                        window.scrollBy( 0, 1 );
     247                                } else if ( wrapHeight && windowPos > wrapHeight ) {
     248                                        window.scrollTo( window.pageXOffset, wrapHeight - 1 );
     249                                }
     250
     251                                adjust();
     252                        }, 200 );
    235253                }
    236254
    237255                mceBind = function() {