TinyMCE: fix the edit image and wpview buttons on touch screen PCs, fixes #29235.

git-svn-id: https://develop.svn.wordpress.org/trunk@29521 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2014-08-17 20:10:16 +00:00
parent 712b9d0897
commit ed01241d4b
2 changed files with 7 additions and 10 deletions

View File

@ -549,8 +549,6 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
} }
if ( 'ontouchend' in document ) { if ( 'ontouchend' in document ) {
editor.on( 'touchend', edit );
editor.on( 'click', function( event ) { editor.on( 'click', function( event ) {
var target = event.target; var target = event.target;
@ -563,10 +561,10 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
event.stopPropagation(); event.stopPropagation();
} }
}); });
} else {
editor.on( 'mouseup', edit );
} }
editor.on( 'mouseup touchend', edit );
editor.on( 'init', function() { editor.on( 'init', function() {
var dom = editor.dom, var dom = editor.dom,
captionClass = editor.getParam( 'wpeditimage_html5_captions' ) ? 'html5-captions' : 'html4-captions'; captionClass = editor.getParam( 'wpeditimage_html5_captions' ) ? 'html5-captions' : 'html4-captions';

View File

@ -11,7 +11,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
toRemove = false, toRemove = false,
firstFocus = true, firstFocus = true,
_noop = function() { return false; }, _noop = function() { return false; },
isTouchDevice = ( 'ontouchend' in document ), isios = /iPad|iPod|iPhone/.test( navigator.userAgent ),
cursorInterval, lastKeyDownNode, setViewCursorTries, focus, execCommandView; cursorInterval, lastKeyDownNode, setViewCursorTries, focus, execCommandView;
function getView( node ) { function getView( node ) {
@ -141,7 +141,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
dom.bind( selected, 'beforedeactivate focusin focusout', _stop ); dom.bind( selected, 'beforedeactivate focusin focusout', _stop );
// select the hidden div // select the hidden div
if ( isTouchDevice ) { if ( isios ) {
editor.selection.select( clipboard ); editor.selection.select( clipboard );
} else { } else {
editor.selection.select( clipboard, true ); editor.selection.select( clipboard, true );
@ -298,8 +298,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
}); });
editor.on( 'mousedown mouseup click touchend', function( event ) { editor.on( 'mousedown mouseup click touchend', function( event ) {
var view = getView( event.target ), var view = getView( event.target );
type = isTouchDevice ? 'touchend' : 'mousedown';
firstFocus = false; firstFocus = false;
@ -308,7 +307,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
event.stopImmediatePropagation(); event.stopImmediatePropagation();
event.preventDefault(); event.preventDefault();
if ( event.type === type && ! event.metaKey && ! event.ctrlKey ) { if ( ( event.type === 'touchend' || event.type === 'mousedown' ) && ! event.metaKey && ! event.ctrlKey ) {
if ( editor.dom.hasClass( event.target, 'edit' ) ) { if ( editor.dom.hasClass( event.target, 'edit' ) ) {
wp.mce.views.edit( view ); wp.mce.views.edit( view );
editor.focus(); editor.focus();
@ -329,7 +328,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
// Unfortunately, it also inhibits the dragging of views to a new location. // Unfortunately, it also inhibits the dragging of views to a new location.
return false; return false;
} else { } else {
if ( event.type === type ) { if ( event.type === 'touchend' || event.type === 'mousedown' ) {
deselect(); deselect();
} }
} }