Make WordPress Core

Ticket #32604: 32604.12.patch

File 32604.12.patch, 3.1 KB (added by iseulde, 8 years ago)
  • src/wp-includes/js/tinymce/plugins/wordpress/plugin.js

     
    443443         * Experimental: create a floating toolbar.
    444444         * This functionality will change in the next releases. Not recommended for use by plugins.
    445445         */
    446         ( function() {
     446        editor.on( 'preinit', function() {
    447447                var Factory = tinymce.ui.Factory,
    448448                        settings = editor.settings,
    449449                        activeToolbar,
    450450                        currentSelection,
     451                        timeout,
    451452                        wpAdminbar = document.getElementById( 'wpadminbar' ),
    452                         mceIframe, mceToolbar, mceStatusbar, wpStatusbar;
    453 
    454                 editor.on( 'init', function() {
    455                         mceIframe = document.getElementById( editor.id + '_ifr' );
    456                         mceToolbar = tinymce.$( '.mce-toolbar-grp', editor.getContainer() )[0];
    457                         mceStatusbar = tinymce.$( '.mce-statusbar', editor.getContainer() )[0];
     453                        mceIframe = document.getElementById( editor.id + '_ifr' ),
     454                        mceToolbar = tinymce.$( '.mce-toolbar-grp', editor.getContainer() )[0],
     455                        mceStatusbar = tinymce.$( '.mce-statusbar', editor.getContainer() )[0],
     456                        wpStatusbar;
    458457
    459458                        if ( editor.id === 'content' ) {
    460459                                wpStatusbar = document.getElementById( 'post-status-info' );
    461460                        }
    462                 } );
    463461
    464462                function create( buttons, bottom ) {
    465463                        var toolbar,
     
    587585
    588586                        toolbar.bottom = bottom;
    589587
    590                         function hide() {
    591                                 toolbar.hide();
    592                         }
    593 
    594588                        function reposition() {
    595589                                var scrollX = window.pageXOffset || document.documentElement.scrollLeft,
    596590                                        scrollY = window.pageYOffset || document.documentElement.scrollTop,
     
    617611                                        className = '',
    618612                                        top, left;
    619613
     614                                if ( spaceTop >= editorHeight || spaceBottom >= editorHeight ) {
     615                                        return this.hide();
     616                                }
     617
    620618                                if ( this.bottom ) {
    621619                                        if ( spaceBottom >= spaceNeeded ) {
    622620                                                className = ' mce-arrow-up';
     
    677675                                }
    678676                        } );
    679677
    680                         toolbar.on( 'remove', function() {
    681                                 DOM.unbind( window, 'resize scroll', hide );
    682                                 editor.dom.unbind( editor.getWin(), 'resize scroll', hide );
    683                                 editor.off( 'blur hide', hide );
    684                         } );
    685 
    686                         editor.once( 'init', function() {
    687                                 DOM.bind( window, 'resize scroll', hide );
    688                                 editor.dom.bind( editor.getWin(), 'resize scroll', hide );
    689                                 editor.on( 'blur hide', hide );
    690                         } );
    691 
    692678                        toolbar.reposition = reposition;
    693679                        toolbar.hide().renderTo( document.body );
    694680
     
    735721                        }
    736722                } );
    737723
    738                 editor.on( 'hide', function() {
    739                         activeToolbar = false;
    740                 } );
     724                function hide( event ) {
     725                        if ( activeToolbar ) {
     726                                activeToolbar.hide();
     727
     728                                if ( event.type === 'hide' ) {
     729                                        activeToolbar = false;
     730                                } else if ( event.type === 'resize' || event.type === 'scroll' ) {
     731                                        clearTimeout( timeout );
     732
     733                                        timeout = setTimeout( function() {
     734                                                activeToolbar.show();
     735                                        }, 250 );
     736                                }
     737                        }
     738                }
     739
     740                DOM.bind( window, 'resize scroll', hide );
     741                editor.dom.bind( editor.getWin(), 'resize scroll', hide );
     742                editor.on( 'blur hide', hide );
    741743
    742744                editor.wp = editor.wp || {};
    743745                editor.wp._createToolbar = create;
    744         }());
     746        }, true );
    745747
    746748        function noop() {}
    747749