Make WordPress Core

Ticket #21718: 21718-4.patch

File 21718-4.patch, 11.8 KB (added by azaozz, 13 years ago)
  • wp-admin/css/wp-admin.css

     
    31073107        background: transparent url(../images/resize.gif) no-repeat scroll right bottom;
    31083108        width: 12px;
    31093109        cursor: se-resize;
    3110         margin: 0 2px;
     3110        margin: 0 1px;
    31113111        position: relative;
    31123112        top: -2px;
    31133113}
     
    31163116        top: 20px;
    31173117}
    31183118
     3119#content-resize-handle {
     3120        background: transparent url(../images/resize.gif) no-repeat scroll right bottom;
     3121        width: 12px;
     3122        cursor: se-resize;
     3123        position: absolute;
     3124        right: 2px;
     3125        height: 19px;
     3126}
     3127
     3128.tmce-active #content-resize-handle {
     3129        display: none;
     3130}
     3131
     3132.post-php #content {
     3133        resize: none;
     3134}
     3135
    31193136#wp-word-count {
    31203137        display: block;
    31213138        padding: 2px 10px;
     
    43094326        box-shadow: none;
    43104327}
    43114328
     4329.comment-php .wp-editor-area {
     4330        height: 200px;
     4331}
     4332
    43124333.comment-ays {
    43134334        margin-bottom: 0;
    43144335        border-style: solid;
  • wp-admin/js/editor.js

     
    4949                        if ( ed && ed.isHidden() )
    5050                                return false;
    5151
    52                         if ( ed ) {
    53                                 txtarea_el.style.height = ed.getContentAreaContainer().offsetHeight + 20 + 'px';
     52                        if ( ed )
    5453                                ed.hide();
    55                         }
    5654
    5755                        dom.removeClass(wrap_id, 'tmce-active');
    5856                        dom.addClass(wrap_id, 'html-active');
  • wp-admin/js/post.js

     
    667667        }
    668668
    669669        wptitlehint();
     670
     671        // resizable textarea#content
     672        (function() {
     673                var textarea = $('textarea#content'), offset = null, el;
     674
     675                function dragging(e) {
     676                        textarea.height( Math.max(50, offset + e.pageY) + 'px' );
     677                        return false;
     678                }
     679
     680                function endDrag(e) {
     681                        var height = $('#wp-content-editor-container').height();
     682
     683                        textarea.focus();
     684                        $(document).unbind('mousemove', dragging).unbind('mouseup', endDrag);
     685
     686                        if ( height > 83 ) {
     687                                height -= 33; // compensate for toolbars, padding...
     688                                setUserSetting( 'content_ed_size', height );
     689                        }
     690                }
     691
     692                el = $('<div id="content-resize-handle"><br></div>');
     693                $('#wp-content-wrap').append(el);
     694                el.on('mousedown', function(e) {
     695                        offset = textarea.height() - e.pageY;
     696                        textarea.blur();
     697                        $(document).mousemove(dragging).mouseup(endDrag);
     698                        return false;
     699                });
     700        })();
     701
    670702});
  • wp-includes/class-wp-editor.php

     
    2828        private function __construct() {}
    2929
    3030        public static function parse_settings($editor_id, $settings) {
     31                if ( isset( $settings['textarea_rows'] ) && ! isset( $settings['editor_height'] ) )
     32                        $settings['editor_height'] = $settings['textarea_rows'] * 18; // Convert rows="" to pixels.
     33
    3134                $set = wp_parse_args( $settings,  array(
    3235                        'wpautop' => true, // use wpautop?
    3336                        'media_buttons' => true, // show insert/upload button(s)
    3437                        'textarea_name' => $editor_id, // set the textarea name to something different, square brackets [] can be used here
    35                         'textarea_rows' => get_option('default_post_edit_rows', 10), // rows="..."
     38                        'editor_height' => '', // editor height in px (replaces textarea rows)
    3639                        'tabindex' => '',
    3740                        'tabfocus_elements' => ':prev,:next', // the previous and next element ID to move the focus to when pressing the Tab key in TinyMCE
    3841                        'editor_css' => '', // intended for extra styles for both visual and Text editors buttons, needs to include the <style> tags, can use "scoped".
     
    5255                if ( self::$this_quicktags )
    5356                        self::$has_quicktags = true;
    5457
     58                if ( 'content' === $editor_id && self::$this_tinymce ) {
     59                        // A cookie (set when a user resizes the editor) overrides the height.
     60                        $cookie = (int) get_user_setting( $editor_id . '_ed_size' );
     61
     62                        // Upgrade an old TinyMCE cookie if it is still around, and the new one isn't.
     63                        if ( ! $cookie && isset( $_COOKIE['TinyMCE_' . $editor_id . '_size'] ) ) {
     64                                parse_str( $_COOKIE['TinyMCE_' . $editor_id . '_size'], $cookie );
     65                                $cookie = $cookie['ch'];
     66                        }
     67
     68                        if ( $cookie )
     69                                $set['editor_height'] = $cookie;
     70                        else
     71                                $set['editor_height'] = 360; // 360px is about 20 textarea rows. the old default val for the main editor
     72                }
     73
     74                // 50px is the minimum height for TinyMCE and all things reasonable.
     75                if ( !empty($set['editor_height']) && $set['editor_height'] < 50 )
     76                        $set['editor_height'] = 50;
     77
    5578                return $set;
    5679        }
    5780
     
    6790                $set = self::parse_settings($editor_id, $settings);
    6891                $editor_class = ' class="' . trim( $set['editor_class'] . ' wp-editor-area' ) . '"';
    6992                $tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : '';
    70                 $rows = ' rows="' . (int) $set['textarea_rows'] . '"';
     93                $editor_height = $set['editor_height'] ? ' style="height: ' . $set['editor_height'] . 'px;"' : '';
    7194                $switch_class = 'html-active';
    7295                $toolbar = $buttons = '';
    7396
     
    116139                        echo "</div>\n";
    117140                }
    118141
    119                 $the_editor = apply_filters('the_editor', '<div id="wp-' . $editor_id . '-editor-container" class="wp-editor-container"><textarea' . $editor_class . $rows . $tabindex . ' cols="40" name="' . $set['textarea_name'] . '" id="' . $editor_id . '">%s</textarea></div>');
     142                $the_editor = apply_filters('the_editor', '<div id="wp-' . $editor_id . '-editor-container" class="wp-editor-container"><textarea' . $editor_class . $editor_height . $tabindex . ' cols="40" name="' . $set['textarea_name'] . '" id="' . $editor_id . '">%s</textarea></div>');
    120143                $content = apply_filters('the_editor_content', $content);
    121144
    122145                printf($the_editor, $content);
     
    403426                                'body_class' => $body_class
    404427                        );
    405428
     429                        $mceInit['theme_advanced_resizing_use_cookie'] = 'content' !== $editor_id;
     430
    406431                        if ( $first_run )
    407432                                $mceInit = array_merge(self::$first_init, $mceInit);
    408433
     
    553578?>
    554579
    555580        <script type="text/javascript">
     581                var wpActiveEditor;
     582
    556583                (function(){
    557                         var init, ed, qt, first_init, mce = <?php echo wp_default_editor() == 'tinymce' ? 'true' : 'false'; ?>;
     584                        var init, ed, qt, first_init, DOM, el, i, mce = <?php
    558585
     586                        if ( ( self::$has_tinymce && wp_default_editor() == 'tinymce' ) || !self::$has_quicktags )
     587                                echo 'true';
     588                        else
     589                                echo 'false';
     590
     591                        ?>;
     592
    559593                        if ( typeof(tinymce) == 'object' ) {
     594                                DOM = tinymce.DOM;
    560595                                // mark wp_theme/ui.css as loaded
    561                                 tinymce.DOM.files[tinymce.baseURI.getURI() + '/themes/advanced/skins/wp_theme/ui.css'] = true;
     596                                DOM.files[tinymce.baseURI.getURI() + '/themes/advanced/skins/wp_theme/ui.css'] = true;
    562597
     598                                DOM.events.add( DOM.select('.wp-editor-wrap'), 'mousedown', function(e){
     599                                        if ( this.id )
     600                                                wpActiveEditor = this.id.slice(3, -5);
     601                                });
     602
    563603                                for ( ed in tinyMCEPreInit.mceInit ) {
    564604                                        if ( first_init ) {
    565605                                                init = tinyMCEPreInit.mceInit[ed] = tinymce.extend( {}, first_init, tinyMCEPreInit.mceInit[ed] );
     
    570610                                        if ( mce )
    571611                                                try { tinymce.init(init); } catch(e){}
    572612                                }
     613                        } else {
     614                                el = document.getElementsByClassName('wp-editor-wrap');
     615                                for ( i in el ) {
     616                                        if ( typeof(el[i]) == 'object' )
     617                                                el[i].onmousedown = function(){ wpActiveEditor = this.id.slice(3, -5); }
     618                                }
    573619                        }
    574620
    575621                        if ( typeof(QTags) == 'function' ) {
     
    578624                                }
    579625                        }
    580626                })();
     627                <?php
    581628
    582                 var wpActiveEditor;
    583 
    584                 jQuery('.wp-editor-wrap').mousedown(function(e){
    585                         wpActiveEditor = this.id.slice(3, -5);
    586                 });
    587 
    588 <?php
    589 
    590629                if ( self::$ext_plugins )
    591630                        echo self::$ext_plugins . "\n";
    592631
    593632                if ( ! $compressed && $tmce_on ) {
    594 ?>
    595                 (function(){var t=tinyMCEPreInit,sl=tinymce.ScriptLoader,ln=t.ref.language,th=t.ref.theme,pl=t.ref.plugins;sl.markDone(t.base+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'_dlg.js');sl.markDone(t.base+'/themes/advanced/skins/wp_theme/ui.css');tinymce.each(pl.split(','),function(n){if(n&&n.charAt(0)!='-'){sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'.js');sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'_dlg.js');}});})();
    596 <?php
     633                        ?>
     634                        (function(){var t=tinyMCEPreInit,sl=tinymce.ScriptLoader,ln=t.ref.language,th=t.ref.theme,pl=t.ref.plugins;sl.markDone(t.base+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'_dlg.js');sl.markDone(t.base+'/themes/advanced/skins/wp_theme/ui.css');tinymce.each(pl.split(','),function(n){if(n&&n.charAt(0)!='-'){sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'.js');sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'_dlg.js');}});})();
     635                        <?php
    597636                }
    598637
    599638                if ( !is_admin() )
    600639                        echo 'var ajaxurl = "' . admin_url( 'admin-ajax.php', 'relative' ) . '";';
    601 ?>
    602         </script>
    603 <?php
    604640
     641                ?>
     642                </script>
     643                <?php
     644
    605645                if ( in_array('wplink', self::$plugins, true) || in_array('link', self::$qt_buttons, true) )
    606646                        self::wp_link_dialog();
    607647
  • wp-includes/css/editor.css

     
    10181018}
    10191019
    10201020/* WP specific */
     1021.wp-editor-wrap {
     1022        position: relative;
     1023}
     1024
    10211025.wp-editor-area {
    10221026        font-family: Consolas, Monaco, monospace;
    10231027        padding: 10px;
     1028        margin: 1px 0 0;
    10241029        line-height: 150%;
    10251030        border: 0 none;
    10261031        outline: none;
     1032        display: block;
    10271033        resize: vertical;
    10281034        -moz-box-sizing: border-box;
    10291035        -webkit-box-sizing: border-box;
  • wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js

     
    33 */
    44
    55(function() {
    6         var DOM = tinymce.DOM;
     6        var DOM = tinymce.DOM, win = window;
    77
    88        tinymce.create('tinymce.plugins.WordPress', {
    99                mceTout : 0,
     
    234234                                }
    235235                        });
    236236
     237                        // resize TinyMCE to match the textarea height when switching Text -> Visual
     238                        ed.onLoadContent.add( function(ed, o) {
     239                                var height, tb_height, ifr_height, txt = ed.getElement(),
     240                                        ed_toolbar = DOM.select('#'+ed.id + '_tbl tr.mceFirst');
     241
     242                                if ( txt && txt.style && txt.style.height )
     243                                        height = parseInt( txt.style.height, 10 );
     244                                else if ( o.initial && win.getUserSetting )
     245                                        height = win.getUserSetting( ed.id + '_ed_size' );
     246
     247                                if ( ed_toolbar && ed_toolbar[0] )
     248                                        tb_height = ed_toolbar[0].clientHeight;
     249
     250                                if ( height && tb_height ) {
     251                                        ifr_height = (height - tb_height) + 12; // compensate for padding in the textarea
     252
     253                                        DOM.setStyle( DOM.get(ed.id + '_tbl'), 'height', '' );
     254                                        DOM.setStyle( DOM.get(ed.id + '_ifr'), 'height', ifr_height + 'px' );
     255
     256                                        if ( win.setUserSetting )
     257                                                win.setUserSetting( ed.id + '_ed_size', height );
     258                                }
     259                        });
     260
     261                        // resize the textarea to match TinyMCE's height when switching Visual -> Text
     262                        ed.onSaveContent.add( function(ed, o) {
     263                                var height = DOM.get(ed.id+'_tbl').clientHeight;
     264
     265                                if ( height && height > 83 ) {
     266                                        height -= 33;
     267
     268                                        DOM.setStyle( ed.getElement(), 'height', height + 'px' );
     269
     270                                        if ( win.setUserSetting )
     271                                                win.setUserSetting( ed.id + '_ed_size', height );
     272                                }
     273                        });
     274
     275                        // save on resize
     276                        ed.onPostRender.add(function() {
     277                                tinymce.dom.Event.add(DOM.doc, 'mouseup', function(e) {
     278                                        var height = document.getElementById('wp-'+ed.id+'-editor-container').clientHeight;
     279
     280                                        height -= 33;
     281
     282                                        if ( !win.setUserSetting || height < 50 || height == win.getUserSetting( ed.id + '_ed_size' ) )
     283                                                return;
     284
     285                                        win.setUserSetting( ed.id + '_ed_size', height );
     286                                });
     287                        });
     288
    237289                        /* disable for now
    238290                        ed.onBeforeSetContent.add(function(ed, o) {
    239291                                o.content = t._setEmbed(o.content);