From ed01241d4bdd2584171ad4a8b33e11356f8648f9 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sun, 17 Aug 2014 20:10:16 +0000 Subject: [PATCH] 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 --- .../js/tinymce/plugins/wpeditimage/plugin.js | 6 ++---- src/wp-includes/js/tinymce/plugins/wpview/plugin.js | 11 +++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js index 93391b24af..21d2ca0d5d 100644 --- a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js @@ -549,8 +549,6 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } if ( 'ontouchend' in document ) { - editor.on( 'touchend', edit ); - editor.on( 'click', function( event ) { var target = event.target; @@ -563,10 +561,10 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { event.stopPropagation(); } }); - } else { - editor.on( 'mouseup', edit ); } + editor.on( 'mouseup touchend', edit ); + editor.on( 'init', function() { var dom = editor.dom, captionClass = editor.getParam( 'wpeditimage_html5_captions' ) ? 'html5-captions' : 'html4-captions'; diff --git a/src/wp-includes/js/tinymce/plugins/wpview/plugin.js b/src/wp-includes/js/tinymce/plugins/wpview/plugin.js index 34634a2561..dba3fc7c67 100644 --- a/src/wp-includes/js/tinymce/plugins/wpview/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpview/plugin.js @@ -11,7 +11,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) { toRemove = false, firstFocus = true, _noop = function() { return false; }, - isTouchDevice = ( 'ontouchend' in document ), + isios = /iPad|iPod|iPhone/.test( navigator.userAgent ), cursorInterval, lastKeyDownNode, setViewCursorTries, focus, execCommandView; function getView( node ) { @@ -141,7 +141,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) { dom.bind( selected, 'beforedeactivate focusin focusout', _stop ); // select the hidden div - if ( isTouchDevice ) { + if ( isios ) { editor.selection.select( clipboard ); } else { editor.selection.select( clipboard, true ); @@ -298,8 +298,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) { }); editor.on( 'mousedown mouseup click touchend', function( event ) { - var view = getView( event.target ), - type = isTouchDevice ? 'touchend' : 'mousedown'; + var view = getView( event.target ); firstFocus = false; @@ -308,7 +307,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) { event.stopImmediatePropagation(); 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' ) ) { wp.mce.views.edit( view ); editor.focus(); @@ -329,7 +328,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) { // Unfortunately, it also inhibits the dragging of views to a new location. return false; } else { - if ( event.type === type ) { + if ( event.type === 'touchend' || event.type === 'mousedown' ) { deselect(); } }