Make WordPress Core

Changeset 30256


Ignore:
Timestamp:
11/06/2014 08:11:03 AM (12 years ago)
Author:
nacin
Message:

Editor expand: hide TinyMCE float panels and tooltips when scrolling.

Merges [29738] to the 4.0 branch.

props avryl.
see #29516.

Location:
branches/4.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.0

  • branches/4.0/src/wp-admin/js/editor-expand.js

    r30251 r30256  
    33window.wp = window.wp || {};
    44
    5 jQuery( document ).ready( function($) {
     5jQuery( document ).ready( function( $ ) {
    66        var $window = $( window ),
    77                $document = $( document ),
     
    149149        // We need to wait for TinyMCE to initialize.
    150150        $document.on( 'tinymce-editor-init.editor-expand', function( event, editor ) {
     151                var hideFloatPanels = _.debounce( function() {
     152                        ! $( '.mce-floatpanel:hover' ).length && tinymce.ui.FloatPanel.hideAll();
     153                        $( '.mce-tooltip' ).hide();
     154                }, 1000, true );
     155
    151156                // Make sure it's the main editor.
    152157                if ( editor.id !== 'content' ) {
     
    225230                // Adjust when switching editor modes.
    226231                function mceShow() {
     232                        $window.on( 'scroll.mce-float-panels', hideFloatPanels );
     233
    227234                        setTimeout( function() {
    228235                                editor.execCommand( 'wpAutoResize' );
     
    232239
    233240                function mceHide() {
     241                        $window.off( 'scroll.mce-float-panels' );
     242
    234243                        setTimeout( function() {
    235244                                var top = $contentWrap.offset().top;
     
    252261                        // Adjust when the editor resizes.
    253262                        editor.on( 'setcontent wp-autoresize wp-toolbar-toggle', adjust );
     263
     264                        $window.off( 'scroll.mce-float-panels' ).on( 'scroll.mce-float-panels', hideFloatPanels );
    254265                };
    255266
     
    259270                        editor.off( 'hide', mceHide );
    260271                        editor.off( 'setcontent wp-autoresize wp-toolbar-toggle', adjust );
     272
     273                        $window.off( 'scroll.mce-float-panels' );
    261274                };
    262275
Note: See TracChangeset for help on using the changeset viewer.