Make WordPress Core

Ticket #28328: 28328.24.patch

File 28328.24.patch, 6.1 KB (added by azaozz, 10 years ago)
  • src/wp-admin/css/edit.css

     
    405405}
    406406/* end editor-expand.js override */
    407407
     408#poststuff #post-body #postbox-container-1.pinned {
     409        position: fixed;
     410        margin: 0;
     411        top: 56px;
     412        bottom: 0;
     413        right: 20px;
     414        transition: top 200ms;
     415}
     416
    408417#timestampdiv select {
    409418        height: 21px;
    410419        line-height: 14px;
  • src/wp-admin/js/editor-expand.js

     
    1616                $textEditorClone = $( '<div id="content-textarea-clone"></div>' ),
    1717                $bottom = $( '#post-status-info' ),
    1818                $statusBar,
     19                $sideSortables = $( '#side-sortables' ),
     20                $postboxContainer = $('#postbox-container-1'),
     21                $postBodyContent = $('#post-body-content'),
     22                $postBody = $('#post-body'),
    1923                fullscreen = window.wp.editor && window.wp.editor.fullscreen,
    2024                mceEditor,
    2125                mceBind = function(){},
     
    2226                mceUnbind = function(){},
    2327                fixedTop = false,
    2428                fixedBottom = false,
    25                 scrollTimer;
     29                fixedSide = false,
     30                scrollTimer,
     31                lastScrollPosition = 0,
     32                pageYOffsetAtTop = 130,
     33                textEditorClonePaddingTop = 37,
     34                autoresizeMinHeight = $window.height() - 310;
    2635
    2736        $textEditorClone.insertAfter( $textEditor );
    2837
     
    3140                'font-size': $textEditor.css( 'font-size' ),
    3241                'line-height': $textEditor.css( 'line-height' ),
    3342                'padding': $textEditor.css( 'padding' ),
    34                 'padding-top': 37,
     43                'padding-top': textEditorClonePaddingTop,
    3544                'white-space': 'pre-wrap',
    3645                'word-wrap': 'break-word'
    3746        } );
     
    8897
    8998                hiddenHeight = $textEditorClone.height();
    9099
    91                 if ( hiddenHeight < 300 ) {
    92                         hiddenHeight = 300;
     100                if ( hiddenHeight < autoresizeMinHeight ) {
     101                        hiddenHeight = autoresizeMinHeight;
    93102                }
    94103
    95104                if ( hiddenHeight === textEditorHeight ) {
     
    112121                mceEditor = editor;
    113122
    114123                // Set the minimum height to the initial viewport height.
    115                 editor.settings.autoresize_min_height = 300;
     124                editor.settings.autoresize_min_height = autoresizeMinHeight;
    116125
    117126                // Get the necessary UI elements.
    118127                $visualTop = $contentWrap.find( '.mce-toolbar-grp' );
     
    218227                        adminBarHeight = windowWidth > 600 ? $adminBar.height() : 0,
    219228                        resize = type !== 'scroll',
    220229                        visual = ( mceEditor && ! mceEditor.isHidden() ),
    221                         buffer = 200,
     230                        buffer = autoresizeMinHeight + adminBarHeight,
    222231                        $top, $editor,
    223                         toolsHeight, topPos, topHeight, editorPos, editorHeight, editorWidth, statusBarHeight;
     232                        toolsHeight, topPos, topHeight, editorPos, editorHeight, editorWidth, statusBarHeight, sideScrollTrigger;
    224233
    225234                if ( visual ) {
    226235                        $top = $visualTop;
     
    236245                editorPos = $editor.offset().top;
    237246                editorHeight = $editor.outerHeight();
    238247                editorWidth = $editor.outerWidth();
     248                borderWidth = 1;
    239249                statusBarHeight = visual ? $statusBar.outerHeight() : 0;
    240250
    241251                // Maybe pin the top.
     
    256266                        $tools.css( {
    257267                                position: 'fixed',
    258268                                top: adminBarHeight,
    259                                 width: editorWidth + 2
     269                                width: editorWidth + ( borderWidth * 2 )
    260270                        } );
    261271                // Maybe unpin the top.
    262272                } else if ( fixedTop || resize ) {
     
    287297
    288298                                $tools.css( {
    289299                                        position: 'absolute',
    290                                         top: editorHeight - buffer + 1, // border
     300                                        top: editorHeight - buffer + borderWidth, // border
    291301                                        width: $contentWrap.width()
    292302                                } );
    293303                        }
     
    295305
    296306                // Maybe adjust the bottom bar.
    297307                if ( ( ! fixedBottom || resize ) &&
    298                                 // + 1 for the border around the .wp-editor-container.
    299                                 ( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + 1 ) ) {
     308                                // +[n] for the border around the .wp-editor-container.
     309                                ( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + borderWidth ) ) {
    300310                        fixedBottom = true;
    301311
    302312                        $bottom.css( {
    303313                                position: 'fixed',
    304314                                bottom: 0,
    305                                 width: editorWidth + 2,
     315                                width: editorWidth + ( borderWidth * 2 ),
    306316                                borderTop: '1px solid #dedede'
    307317                        } );
    308318                } else if ( ( fixedBottom || resize ) &&
    309                                 ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - 1 ) ) {
     319                                ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - borderWidth ) ) {
    310320                        fixedBottom = false;
    311321
    312322                        $bottom.css( {
     
    317327                        } );
    318328                }
    319329
     330                // The sidebar is on the left, pin it
     331                if ( ( $postboxContainer.position().top - 10 ) < $postBodyContent.position().top ) {
     332                        sideScrollTrigger = ( $sideSortables.height() - ( windowHeight - 56 ) );
     333                       
     334                        if ( ! fixedSide && ( $postBody.offset().top - 56 ) < windowPos ) {
     335                                fixedSide = true;
     336                                $postboxContainer.addClass('pinned');
     337                        } else if ( fixedSide ) {
     338                                if ( ( $postBody.offset().top - 56 ) >= windowPos ) {
     339                                        fixedSide = false;
     340                                        $postboxContainer.removeClass('pinned scroll-down');
     341                                }
     342                        }
     343
     344                        if ( fixedSide && windowPos > lastScrollPosition ) {
     345                                // Scrolling down
     346                                if ( sideScrollTrigger > 1 && sideScrollTrigger < windowPos ) {
     347                                        $postboxContainer.css( 'top', -( sideScrollTrigger -36 ) );
     348                                }
     349                        } else if ( windowPos < lastScrollPosition ) {
     350                                $postboxContainer.css( 'top', '' );
     351                        }
     352
     353                        lastScrollPosition = windowPos;
     354                }
     355
    320356                if ( resize ) {
    321357                        $contentWrap.css( {
    322358                                paddingTop: $tools.outerHeight()
     
    350386                clearTimeout( scrollTimer );
    351387                scrollTimer = setTimeout( adjust, 200 );
    352388        }
    353 
    354389        function on() {
    355390                // Scroll to the top when triggering this from JS.
    356391                // Ensures toolbars are pinned properly.
    357                 if ( window.pageYOffset && window.pageYOffset > 130 ) {
     392                if ( window.pageYOffset && window.pageYOffset > pageYOffsetAtTop ) {
    358393                        window.scrollTo( window.pageXOffset, 0 );
    359394                }
    360395
     
    397432
    398433                // Scroll to the top when triggering this from JS.
    399434                // Ensures toolbars are reset properly.
    400                 if ( window.pageYOffset && window.pageYOffset > 130 ) {
     435                if ( window.pageYOffset && window.pageYOffset > pageYOffsetAtTop ) {
    401436                        window.scrollTo( window.pageXOffset, 0 );
    402437                }
    403438