From a9384b7a308bde5ebdd5741f2a75e0fd91386624 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Fri, 12 Sep 2014 01:20:09 +0000 Subject: [PATCH] Editor expand: hide TinyMCE float panels and tooltips when scrolling, props avryl, fixes #29516 for trunk. git-svn-id: https://develop.svn.wordpress.org/trunk@29738 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/editor-expand.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/js/editor-expand.js b/src/wp-admin/js/editor-expand.js index ab5e8854d1..0ce5e40658 100644 --- a/src/wp-admin/js/editor-expand.js +++ b/src/wp-admin/js/editor-expand.js @@ -2,7 +2,7 @@ window.wp = window.wp || {}; -jQuery( document ).ready( function($) { +jQuery( document ).ready( function( $ ) { var $window = $( window ), $document = $( document ), $adminBar = $( '#wpadminbar' ), @@ -148,6 +148,11 @@ jQuery( document ).ready( function($) { // We need to wait for TinyMCE to initialize. $document.on( 'tinymce-editor-init.editor-expand', function( event, editor ) { + var hideFloatPanels = _.debounce( function() { + ! $( '.mce-floatpanel:hover' ).length && tinymce.ui.FloatPanel.hideAll(); + $( '.mce-tooltip' ).hide(); + }, 1000, true ); + // Make sure it's the main editor. if ( editor.id !== 'content' ) { return; @@ -224,6 +229,8 @@ jQuery( document ).ready( function($) { // Adjust when switching editor modes. function mceShow() { + $window.on( 'scroll.mce-float-panels', hideFloatPanels ); + setTimeout( function() { editor.execCommand( 'wpAutoResize' ); adjust(); @@ -231,6 +238,8 @@ jQuery( document ).ready( function($) { } function mceHide() { + $window.off( 'scroll.mce-float-panels' ); + setTimeout( function() { var top = $contentWrap.offset().top; @@ -251,6 +260,8 @@ jQuery( document ).ready( function($) { editor.on( 'hide', mceHide ); // Adjust when the editor resizes. editor.on( 'setcontent wp-autoresize wp-toolbar-toggle', adjust ); + + $window.off( 'scroll.mce-float-panels' ).on( 'scroll.mce-float-panels', hideFloatPanels ); }; mceUnbind = function() { @@ -258,6 +269,8 @@ jQuery( document ).ready( function($) { editor.off( 'show', mceShow ); editor.off( 'hide', mceHide ); editor.off( 'setcontent wp-autoresize wp-toolbar-toggle', adjust ); + + $window.off( 'scroll.mce-float-panels' ); }; if ( $wrap.hasClass( 'wp-editor-expand' ) ) {