Make WordPress Core

Changeset 38156


Ignore:
Timestamp:
07/26/2016 09:50:51 PM (10 years ago)
Author:
azaozz
Message:

TinyMCE: fix selecting an image on touch in iOS Safari for TinyMCE 4.4.1.

Fixes #37427.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js

    r36983 r38156  
    8080        } );
    8181
     82        function isNonEditable( node ) {
     83                var parent = editor.$( node ).parents( '[contenteditable]' );
     84                return parent && parent.attr( 'contenteditable' ) === 'false';
     85        }
     86
    8287        // Safari on iOS fails to select images in contentEditoble mode on touch.
    8388        // Select them again.
    … …  
    8590                editor.on( 'init', function() {
    8691                        editor.on( 'touchstart', function( event ) {
    87                                 if ( event.target.nodeName === 'IMG' ) {
     92                                if ( event.target.nodeName === 'IMG' && ! isNonEditable( event.target ) ) {
    8893                                        touchOnImage = true;
    8994                                }
    9095                        });
    9196
    92                         editor.dom.bind( editor.getDoc(), 'touchmove', function( event ) {
    93                                 if ( event.target.nodeName === 'IMG' ) {
    94                                         touchOnImage = false;
    95                                 }
     97                        editor.dom.bind( editor.getDoc(), 'touchmove', function() {
     98                                touchOnImage = false;
    9699                        });
    97100
    98101                        editor.on( 'touchend', function( event ) {
    99                                 if ( touchOnImage && event.target.nodeName === 'IMG' ) {
     102                                if ( touchOnImage && event.target.nodeName === 'IMG' && ! isNonEditable( event.target ) ) {
    100103                                        var node = event.target;
    101104
    … …  
    105108                                                editor.selection.select( node );
    106109                                                editor.nodeChanged();
    107                                         }, 200 );
     110                                        }, 100 );
    108111                                } else if ( toolbar ) {
    109112                                        toolbar.hide();
Note: See TracChangeset for help on using the changeset viewer.