mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-02 13:41:24 +01:00
TinyMCE: don't hide the image toolbar when the iframe window fires onresize. There is a bug in several browsers that triggers onresize when a tooltip is shown, only in RTL mode. Also use better variable name. Fixes #30147.
Built from https://develop.svn.wordpress.org/trunk@30560 git-svn-id: http://core.svn.wordpress.org/trunk@30549 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a71d642a05
commit
f3ba529c2f
@ -1,6 +1,6 @@
|
|||||||
/* global tinymce */
|
/* global tinymce */
|
||||||
tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||||
var tb, serializer,
|
var floatingToolbar, serializer,
|
||||||
DOM = tinymce.DOM,
|
DOM = tinymce.DOM,
|
||||||
settings = editor.settings,
|
settings = editor.settings,
|
||||||
Factory = tinymce.ui.Factory,
|
Factory = tinymce.ui.Factory,
|
||||||
@ -155,30 +155,41 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
tb = Factory.create( toolbarConfig() ).renderTo( document.body ).hide();
|
floatingToolbar = Factory.create( toolbarConfig() ).renderTo( document.body ).hide();
|
||||||
|
|
||||||
tb.reposition = function() {
|
floatingToolbar.reposition = function() {
|
||||||
var top, left, minTop, className,
|
var top, left, minTop, className,
|
||||||
|
windowPos, adminbar, mceToolbar, boundary,
|
||||||
|
boundaryMiddle, boundaryVerticalMiddle, spaceTop,
|
||||||
|
spaceBottom, windowWidth, toolbarWidth, toolbarHalf,
|
||||||
|
iframe, iframePos, iframeWidth, iframeHeigth,
|
||||||
|
toolbarNodeHeight, verticalSpaceNeeded,
|
||||||
toolbarNode = this.getEl(),
|
toolbarNode = this.getEl(),
|
||||||
buffer = 5,
|
buffer = 5,
|
||||||
margin = 8,
|
margin = 8,
|
||||||
windowPos = window.pageYOffset || document.documentElement.scrollTop,
|
|
||||||
adminbar = tinymce.$( '#wpadminbar' )[0],
|
|
||||||
mceToolbar = tinymce.$( '.mce-tinymce .mce-toolbar-grp' )[0],
|
|
||||||
adminbarHeight = 0,
|
adminbarHeight = 0,
|
||||||
boundary = editor.selection.getNode().getBoundingClientRect(),
|
imageNode = editor.selection.getNode();
|
||||||
boundaryMiddle = ( boundary.left + boundary.right ) / 2,
|
|
||||||
boundaryVerticalMiddle = ( boundary.top + boundary.bottom ) / 2,
|
if ( ! imageNode || imageNode.nodeName !== 'IMG' ) {
|
||||||
spaceTop = boundary.top,
|
return this;
|
||||||
spaceBottom = iframeHeigth - boundary.bottom,
|
}
|
||||||
windowWidth = window.innerWidth,
|
|
||||||
toolbarWidth = toolbarNode.offsetWidth,
|
windowPos = window.pageYOffset || document.documentElement.scrollTop;
|
||||||
toolbarHalf = toolbarWidth / 2,
|
adminbar = tinymce.$( '#wpadminbar' )[0];
|
||||||
iframe = editor.getContentAreaContainer().firstChild,
|
mceToolbar = tinymce.$( '.mce-tinymce .mce-toolbar-grp' )[0];
|
||||||
iframePos = DOM.getPos( iframe ),
|
boundary = imageNode.getBoundingClientRect();
|
||||||
iframeWidth = iframe.offsetWidth,
|
boundaryMiddle = ( boundary.left + boundary.right ) / 2;
|
||||||
iframeHeigth = iframe.offsetHeight,
|
boundaryVerticalMiddle = ( boundary.top + boundary.bottom ) / 2;
|
||||||
toolbarNodeHeight = toolbarNode.offsetHeight,
|
spaceTop = boundary.top;
|
||||||
|
spaceBottom = iframeHeigth - boundary.bottom;
|
||||||
|
windowWidth = window.innerWidth;
|
||||||
|
toolbarWidth = toolbarNode.offsetWidth;
|
||||||
|
toolbarHalf = toolbarWidth / 2;
|
||||||
|
iframe = editor.getContentAreaContainer().firstChild;
|
||||||
|
iframePos = DOM.getPos( iframe );
|
||||||
|
iframeWidth = iframe.offsetWidth;
|
||||||
|
iframeHeigth = iframe.offsetHeight;
|
||||||
|
toolbarNodeHeight = toolbarNode.offsetHeight;
|
||||||
verticalSpaceNeeded = toolbarNodeHeight + margin + buffer;
|
verticalSpaceNeeded = toolbarNodeHeight + margin + buffer;
|
||||||
|
|
||||||
if ( iOS ) {
|
if ( iOS ) {
|
||||||
@ -263,7 +274,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
|||||||
editor.selection.select( node );
|
editor.selection.select( node );
|
||||||
}, 200 );
|
}, 200 );
|
||||||
} else {
|
} else {
|
||||||
tb.hide();
|
floatingToolbar.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -272,7 +283,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
|||||||
var delay = iOS ? 350 : 100;
|
var delay = iOS ? 350 : 100;
|
||||||
|
|
||||||
if ( event.element.nodeName !== 'IMG' || isPlaceholder( event.element ) ) {
|
if ( event.element.nodeName !== 'IMG' || isPlaceholder( event.element ) ) {
|
||||||
tb.hide();
|
floatingToolbar.hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,18 +291,18 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
|||||||
var element = editor.selection.getNode();
|
var element = editor.selection.getNode();
|
||||||
|
|
||||||
if ( element.nodeName === 'IMG' && ! isPlaceholder( element ) ) {
|
if ( element.nodeName === 'IMG' && ! isPlaceholder( element ) ) {
|
||||||
if ( tb._visible ) {
|
if ( floatingToolbar._visible ) {
|
||||||
tb.reposition();
|
floatingToolbar.reposition();
|
||||||
} else {
|
} else {
|
||||||
tb.show();
|
floatingToolbar.show();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tb.hide();
|
floatingToolbar.hide();
|
||||||
}
|
}
|
||||||
}, delay );
|
}, delay );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
tb.on( 'show', function() {
|
floatingToolbar.on( 'show', function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
toolbarIsHidden = false;
|
toolbarIsHidden = false;
|
||||||
@ -304,14 +315,14 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
|||||||
}, 100 );
|
}, 100 );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
tb.on( 'hide', function() {
|
floatingToolbar.on( 'hide', function() {
|
||||||
toolbarIsHidden = true;
|
toolbarIsHidden = true;
|
||||||
DOM.removeClass( this.getEl(), 'mce-inline-toolbar-grp-active' );
|
DOM.removeClass( this.getEl(), 'mce-inline-toolbar-grp-active' );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
function hide() {
|
function hide() {
|
||||||
if ( ! toolbarIsHidden ) {
|
if ( ! toolbarIsHidden ) {
|
||||||
tb.hide();
|
floatingToolbar.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,19 +333,19 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
editor.on( 'init', function() {
|
editor.on( 'init', function() {
|
||||||
DOM.bind( editor.getWin(), 'resize scroll', hide );
|
editor.dom.bind( editor.getWin(), 'scroll', hide );
|
||||||
} );
|
});
|
||||||
|
|
||||||
editor.on( 'blur hide', hide );
|
editor.on( 'blur hide', hide );
|
||||||
|
|
||||||
// 119 = F8
|
// 119 = F8
|
||||||
editor.shortcuts.add( 'Alt+119', '', function() {
|
editor.shortcuts.add( 'Alt+119', '', function() {
|
||||||
var node = tb.find( 'toolbar' )[0];
|
var node = floatingToolbar.find( 'toolbar' )[0];
|
||||||
|
|
||||||
if ( node ) {
|
if ( node ) {
|
||||||
node.focus( true );
|
node.focus( true );
|
||||||
}
|
}
|
||||||
} );
|
});
|
||||||
|
|
||||||
function parseShortcode( content ) {
|
function parseShortcode( content ) {
|
||||||
return content.replace( /(?:<p>)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?/g, function( a, b, c ) {
|
return content.replace( /(?:<p>)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?/g, function( a, b, c ) {
|
||||||
@ -1110,8 +1121,8 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
|||||||
editor.nodeChanged();
|
editor.nodeChanged();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if ( tb ) {
|
if ( floatingToolbar ) {
|
||||||
tb.reposition();
|
floatingToolbar.reposition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.1-beta2-30559';
|
$wp_version = '4.1-beta2-30560';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user