Ticket #37427: 37427.patch
File 37427.patch, 2.1 KB (added by , 9 years ago) |
---|
-
src/wp-includes/js/tinymce/plugins/wpview/plugin.js
3 3 */ 4 4 ( function( tinymce, wp ) { 5 5 tinymce.PluginManager.add( 'wpview', function( editor ) { 6 var scrolled = false; 7 6 8 function noop () {} 7 9 8 10 if ( ! wp || ! wp.mce || ! wp.mce.views ) { … … 11 13 }; 12 14 } 13 15 16 /** 17 * Returns the node or a parent of the node that has the passed className. 18 * Doing this directly is about 40% faster 19 */ 20 function getParent( node, className ) { 21 while ( node && node.parentNode ) { 22 if ( node.className && ( ' ' + node.className + ' ' ).indexOf( ' ' + className + ' ' ) !== -1 ) { 23 return node; 24 } 25 26 node = node.parentNode; 27 } 28 29 return false; 30 } 31 32 function getView( node ) { 33 return getParent( node, 'wpview' ); 34 } 35 14 36 // Check if a node is a view or not. 15 37 function isView( node ) { 16 38 return editor.dom.hasClass( node, 'wpview' ); … … 125 147 } 126 148 } ); 127 149 150 if ( tinymce.Env.ie || ( 'ontouchend' in document ) ) { 151 editor.on( 'init', function() { 152 editor.dom.bind( editor.getDoc(), 'touchmove', function() { 153 scrolled = true; 154 }); 155 156 editor.on( 'mousedown mouseup click touchend', function( event ) { 157 var view = getView( event.target ); 158 159 if ( view ) { 160 event.stopImmediatePropagation(); 161 event.preventDefault(); 162 163 if ( event.type === 'touchend' && scrolled ) { 164 scrolled = false; 165 } else { 166 editor.selection.select( view ); 167 } 168 } else { 169 if ( event.type === 'touchend' || event.type === 'mousedown' ) { 170 editor.selection.collapse(); 171 } 172 } 173 174 if ( event.type === 'touchend' && scrolled ) { 175 scrolled = false; 176 } 177 }, true ); 178 }); 179 } 180 128 181 editor.addButton( 'wp_view_edit', { 129 182 tooltip: 'Edit ', // trailing space is needed, used for context 130 183 icon: 'dashicon dashicons-edit',