Make WordPress Core

Ticket #37690: 37690.2.patch

File 37690.2.patch, 3.2 KB (added by azaozz, 8 years ago)
  • src/wp-admin/js/editor-expand.js

     
    5353                                sideSortablesHeight: 0
    5454                        };
    5555
     56                var shrinkTextarea = window._.throttle( function() {
     57                        var x = window.scrollX || document.documentElement.scrollLeft;
     58                        var y = window.scrollY || document.documentElement.scrollTop;
     59                        var height = parseInt( textEditor.style.height, 10 );
     60
     61                        textEditor.style.height = autoresizeMinHeight + 'px';
     62
     63                        if ( textEditor.scrollHeight > autoresizeMinHeight ) {
     64                                textEditor.style.height = textEditor.scrollHeight + 'px';
     65                        }
     66
     67                        if ( typeof x !== 'undefined' ) {
     68                                window.scrollTo( x, y );
     69                        }
     70
     71                        if ( textEditor.scrollHeight < height ) {
     72                                adjust();
     73                        }
     74                }, 300 );
     75
     76                function textEditorResize() {
     77                        var length = textEditor.value.length;
     78
     79                        if ( mceEditor && ! mceEditor.isHidden() ) {
     80                                return;
     81                        }
     82
     83                        if ( ! mceEditor && initialMode === 'tinymce' ) {
     84                                return;
     85                        }
     86
     87                        if ( length < oldTextLength ) {
     88                                shrinkTextarea();
     89                        } else if ( parseInt( textEditor.style.height, 10 ) < textEditor.scrollHeight ) {
     90                                textEditor.style.height = Math.ceil( textEditor.scrollHeight ) + 'px';
     91                                adjust();
     92                        }
     93
     94                        oldTextLength = length;
     95                }
     96
    5697                function getHeights() {
    5798                        var windowWidth = $window.width();
    5899
     
    75116                        }
    76117                }
    77118
    78                 function textEditorResize() {
    79                         if ( mceEditor && ! mceEditor.isHidden() ) {
    80                                 return;
    81                         }
    82 
    83                         if ( ! mceEditor && initialMode === 'tinymce' ) {
    84                                 return;
    85                         }
    86 
    87                         var length = textEditor.value.length;
    88                         var height = parseInt( textEditor.style.height, 10 );
    89                         var top = window.scrollTop;
    90 
    91                         if ( length < oldTextLength ) {
    92                                 // textEditor.scrollHeight is not adjusted until the next line.
    93                                 textEditor.style.height = 'auto';
    94 
    95                                 if ( textEditor.scrollHeight > autoresizeMinHeight ) {
    96                                         textEditor.style.height = textEditor.scrollHeight + 'px';
    97                                 } else {
    98                                         textEditor.style.height = autoresizeMinHeight + 'px';
    99                                 }
    100 
    101                                 // Prevent scroll-jumping in Firefox and IE.
    102                                 window.scrollTop = top;
    103 
    104                                 if ( textEditor.scrollHeight < height ) {
    105                                         adjust();
    106                                 }
    107                         } else if ( height < textEditor.scrollHeight ) {
    108                                 textEditor.style.height = textEditor.scrollHeight + 'px';
    109                                 adjust();
    110                         }
    111 
    112                         oldTextLength = length;
    113                 }
    114 
    115119                // We need to wait for TinyMCE to initialize.
    116120                $document.on( 'tinymce-editor-init.editor-expand', function( event, editor ) {
    117121                        var VK = window.tinymce.util.VK,
  • src/wp-includes/script-loader.php

     
    563563                        'suggestedImgAlt' => __( 'Suggested image #%d' ),
    564564                ) );
    565565
    566                 $scripts->add( 'editor-expand', "/wp-admin/js/editor-expand$suffix.js", array( 'jquery' ), false, 1 );
     566                $scripts->add( 'editor-expand', "/wp-admin/js/editor-expand$suffix.js", array( 'jquery', 'underscore' ), false, 1 );
    567567
    568568                $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 );
    569569