~canonical-sysadmins/wordpress/4.8.1

« back to all changes in this revision

Viewing changes to wp-includes/js/tinymce/plugins/wpeditimage/plugin.js

  • Committer: Barry Price
  • Date: 2016-08-17 04:50:12 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: barry.price@canonical.com-20160817045012-qfui81zhqnqv2ba9
Merge WP4.6 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
                }
80
80
        } );
81
81
 
 
82
        function isNonEditable( node ) {
 
83
                var parent = editor.$( node ).parents( '[contenteditable]' );
 
84
                return parent && parent.attr( 'contenteditable' ) === 'false';
 
85
        }
 
86
 
82
87
        // Safari on iOS fails to select images in contentEditoble mode on touch.
83
88
        // Select them again.
84
89
        if ( iOS ) {
85
90
                editor.on( 'init', function() {
86
91
                        editor.on( 'touchstart', function( event ) {
87
 
                                if ( event.target.nodeName === 'IMG' ) {
 
92
                                if ( event.target.nodeName === 'IMG' && ! isNonEditable( event.target ) ) {
88
93
                                        touchOnImage = true;
89
94
                                }
90
95
                        });
91
96
 
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;
96
99
                        });
97
100
 
98
101
                        editor.on( 'touchend', function( event ) {
99
 
                                if ( touchOnImage && event.target.nodeName === 'IMG' ) {
 
102
                                if ( touchOnImage && event.target.nodeName === 'IMG' && ! isNonEditable( event.target ) ) {
100
103
                                        var node = event.target;
101
104
 
102
105
                                        touchOnImage = false;
104
107
                                        window.setTimeout( function() {
105
108
                                                editor.selection.select( node );
106
109
                                                editor.nodeChanged();
107
 
                                        }, 200 );
 
110
                                        }, 100 );
108
111
                                } else if ( toolbar ) {
109
112
                                        toolbar.hide();
110
113
                                }