Ticket #33301: 33301.5.patch
File 33301.5.patch, 10.5 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
1477 1477 1478 1478 $args = array(); 1479 1479 1480 if ( isset( $_POST['search'] ) ) 1480 if ( isset( $_POST['search'] ) ) { 1481 1481 $args['s'] = wp_unslash( $_POST['search'] ); 1482 } 1483 1484 if ( isset( $_POST['term'] ) ) { 1485 $args['s'] = wp_unslash( $_POST['term'] ); 1486 } 1487 1482 1488 $args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1; 1483 1489 1484 1490 require(ABSPATH . WPINC . '/class-wp-editor.php'); -
src/wp-includes/class-wp-editor.php
779 779 780 780 if ( in_array('wplink', self::$plugins, true) || in_array('link', self::$qt_buttons, true) ) { 781 781 wp_enqueue_script('wplink'); 782 wp_enqueue_script( 'jquery-ui-autocomplete' ); 782 783 } 783 784 784 785 if ( self::$old_dfw_compat ) { -
src/wp-includes/css/editor.css
451 451 width: 20px; 452 452 } 453 453 454 .mce-toolbar .mce-btn-group .mce-btn.mce-primary { 455 min-width: auto; 456 457 background: #0085ba; 458 border-color: #0073aa #006799 #006799; 459 -webkit-box-shadow: 0 1px 0 #006799; 460 box-shadow: 0 1px 0 #006799; 461 color: #fff; 462 text-decoration: none; 463 text-shadow: 0 -1px 1px #006799, 464 1px 0 1px #006799, 465 0 1px 1px #006799, 466 -1px 0 1px #006799; 467 } 468 469 .mce-toolbar .mce-btn-group .mce-btn.mce-primary .mce-ico { 470 color: #fff; 471 } 472 473 .mce-toolbar .mce-btn-group .mce-btn.mce-primary:hover, 474 .mce-toolbar .mce-btn-group .mce-btn.mce-primary:focus { 475 background: #008ec2; 476 border-color: #006799; 477 color: #fff; 478 } 479 480 .mce-toolbar .mce-btn-group .mce-btn.mce-primary:focus { 481 -webkit-box-shadow: 0 1px 0 #0073aa, 482 0 0 2px 1px #33b3db; 483 box-shadow: 0 1px 0 #0073aa, 484 0 0 2px 1px #33b3db; 485 } 486 487 .mce-toolbar .mce-btn-group .mce-btn.mce-primary:active { 488 background: #0073aa; 489 border-color: #006799; 490 -webkit-box-shadow: inset 0 2px 0 #006799; 491 box-shadow: inset 0 2px 0 #006799; 492 vertical-align: top; 493 } 494 454 495 /* mce listbox */ 455 496 .mce-toolbar .mce-btn-group .mce-btn.mce-listbox { 456 497 -webkit-border-radius: 0; … … 1709 1750 } 1710 1751 } 1711 1752 1753 div.wp-link-preview input { 1754 width: 300px; 1755 } 1756 1712 1757 /* =Overlay Body 1713 1758 -------------------------------------------------------------- */ 1714 1759 -
src/wp-includes/js/tinymce/plugins/wordpress/plugin.js
744 744 top, left; 745 745 746 746 if ( spaceTop >= editorHeight || spaceBottom >= editorHeight ) { 747 return this.hide(); 747 this.scrolling = true; 748 this.hide(); 749 this.scrolling = false; 750 return this; 748 751 } 749 752 750 753 // Add offset in iOS to move the menu over the image, out of the way of the default iOS menu. … … 850 853 851 854 currentSelection = args.selection || args.element; 852 855 853 if ( activeToolbar ) {856 if ( activeToolbar && activeToolbar !== args.toolbar ) { 854 857 activeToolbar.hide(); 855 858 } 856 859 857 860 if ( args.toolbar ) { 858 activeToolbar = args.toolbar; 859 activeToolbar.show(); 861 if ( activeToolbar !== args.toolbar ) { 862 activeToolbar = args.toolbar; 863 activeToolbar.show(); 864 } else { 865 activeToolbar.reposition(); 866 } 860 867 } else { 861 868 activeToolbar = false; 862 869 } … … 870 877 871 878 function hide( event ) { 872 879 if ( activeToolbar ) { 873 activeToolbar.hide();874 875 880 if ( event.type === 'hide' ) { 881 activeToolbar.hide(); 876 882 activeToolbar = false; 877 883 } else if ( event.type === 'resize' || event.type === 'scroll' ) { 878 884 clearTimeout( timeout ); 879 885 880 886 timeout = setTimeout( function() { 881 887 if ( activeToolbar && typeof activeToolbar.show === 'function' ) { 888 activeToolbar.scrolling = false; 882 889 activeToolbar.show(); 883 890 } 884 891 }, 250 ); 892 893 activeToolbar.scrolling = true; 894 activeToolbar.hide(); 885 895 } 886 896 } 887 897 } -
src/wp-includes/js/tinymce/plugins/wplink/plugin.js
47 47 } 48 48 } ); 49 49 50 tinymce.ui.WPLinkInput = tinymce.ui.Control.extend( { 51 renderHtml: function() { 52 return ( 53 '<div id="' + this._id + '" class="wp-link-preview">' + 54 '<input type="text" value="" tabindex="-1" />' + 55 '</div>' 56 ); 57 }, 58 setURL: function( url ) { 59 this.getEl().firstChild.value = url; 60 } 61 } ); 62 50 63 tinymce.PluginManager.add( 'wplink', function( editor ) { 64 var a; 51 65 var toolbar; 66 var editToolbar; 67 var previewInstance; 68 var inputInstance; 69 70 editor.on( 'preinit', function() { 71 if ( editor.wp && editor.wp._createToolbar ) { 72 toolbar = editor.wp._createToolbar( [ 73 'wp_link_preview', 74 'wp_link_edit', 75 'wp_link_remove' 76 ], true ); 77 78 editToolbar = editor.wp._createToolbar( [ 79 'wp_link_input', 80 'wp_link_advanced', 81 'wp_link_apply' 82 ], true ); 83 84 editToolbar.on( 'show', function() { 85 a = editor.dom.getParent( editor.selection.getNode(), 'a' ); 86 node = editToolbar.find( 'toolbar' )[0]; 87 node && node.focus( true ); 88 } ); 89 90 editToolbar.on( 'hide', function() { 91 editToolbar.scrolling || editor.execCommand( 'wp_link_cancel' ); 92 } ); 93 } 94 } ); 52 95 53 96 editor.addCommand( 'WP_Link', function() { 54 window.wpLink && window.wpLink.open( editor.id ); 55 }); 97 var a = editor.dom.getParent( editor.selection.getNode(), 'a' ); 98 99 if ( a ) { 100 editor.dom.setAttribs( a, { 'data-wp-edit': true } ); 101 } else { 102 editor.execCommand( 'mceInsertLink', false, { href: '_wp_link_placeholder' } ); 103 } 104 105 editor.nodeChanged(); 106 } ); 107 108 editor.addCommand( 'wp_link_apply', function() { 109 if ( editToolbar.scrolling ) { 110 return; 111 } 112 113 href = tinymce.trim( inputInstance.getEl().firstChild.value ); 114 115 if ( href && ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( href ) ) { 116 href = 'http://' + href; 117 } 118 119 if ( ! href ) { 120 editor.dom.remove( a, true ); 121 return; 122 } 123 124 if ( a ) { 125 editor.dom.setAttribs( a, { href: href, 'data-wp-edit': null } ); 126 } 127 128 a = false; 129 130 editor.nodeChanged(); 131 editor.focus(); 132 } ); 133 134 editor.addCommand( 'wp_link_cancel', function() { 135 if ( a ) { 136 if ( editor.$( a ).attr( 'href' ) === '_wp_link_placeholder' ) { 137 editor.dom.remove( a, true ); 138 } else { 139 editor.dom.setAttribs( a, { 'data-wp-edit': null } ); 140 } 141 } 142 143 a = false; 144 145 editor.nodeChanged(); 146 editor.focus(); 147 } ); 56 148 57 149 // WP default shortcut 58 150 editor.addShortcut( 'access+a', '', 'WP_Link' ); … … 102 194 editor.addButton( 'wp_link_preview', { 103 195 type: 'WPLinkPreview', 104 196 onPostRender: function() { 105 var self = this; 197 previewInstance = this; 198 } 199 } ); 200 201 editor.addButton( 'wp_link_input', { 202 type: 'WPLinkInput', 203 onPostRender: function() { 204 var input = this.getEl().firstChild; 205 var cache; 206 var last; 207 208 inputInstance = this; 209 210 jQuery( input ).autocomplete( { 211 source: function( request, response ) { 212 if ( last === request.term ) { 213 response( cache ); 214 return; 215 } 106 216 107 editor.on( 'wptoolbar', function( event ) { 108 var anchor = editor.dom.getParent( event.element, 'a' ), 109 $anchor, 110 href; 111 112 if ( anchor ) { 113 $anchor = editor.$( anchor ); 114 href = $anchor.attr( 'href' ); 115 116 if ( href && ! $anchor.find( 'img' ).length ) { 117 self.setURL( href ); 118 event.element = anchor; 119 event.toolbar = toolbar; 217 if ( /^https?:/.test( request.term ) || request.term.indexOf( '.' ) !== -1 ) { 218 return response(); 120 219 } 121 } 220 221 jQuery.post( ajaxurl, { 222 action: 'wp-link-ajax', 223 page: 1, 224 search: request.term, 225 _ajax_linking_nonce: jQuery( '#_ajax_linking_nonce' ).val() 226 }, function( data ) { 227 cache = data; 228 response( data ); 229 }, 'json' ); 230 231 last = request.term; 232 }, 233 select: function( event, ui ) { 234 jQuery( input ).val( ui.item.permalink ); 235 return false; 236 }, 237 minLength: 2 238 } ).autocomplete( 'instance' )._renderItem = function( ul, item ) { 239 return jQuery( '<li>' ) 240 .append( '<span>' + item.title + '</span><span>' + item.info + '</span>' ) 241 .appendTo( ul ); 242 }; 243 244 jQuery( input ).on( 'focus', function() { 245 jQuery( input ).autocomplete( 'search' ); 246 } ); 247 248 tinymce.$( input ).on( 'keydown', function( event ) { 249 event.keyCode === 13 && editor.execCommand( 'wp_link_apply' ); 122 250 } ); 123 251 } 124 252 } ); 125 253 254 editor.on( 'wptoolbar', function( event ) { 255 var anchor = editor.dom.getParent( event.element, 'a' ), 256 $anchor, 257 href, edit, node; 258 259 if ( anchor ) { 260 $anchor = editor.$( anchor ); 261 href = $anchor.attr( 'href' ); 262 edit = $anchor.attr( 'data-wp-edit' ); 263 264 if ( href === '_wp_link_placeholder' || edit ) { 265 inputInstance.setURL( edit ? href : '' ); 266 event.element = anchor; 267 event.toolbar = editToolbar; 268 } else if ( href && ! $anchor.find( 'img' ).length ) { 269 previewInstance.setURL( href ); 270 event.element = anchor; 271 event.toolbar = toolbar; 272 } 273 } 274 } ); 275 126 276 editor.addButton( 'wp_link_edit', { 127 277 tooltip: 'Edit ', // trailing space is needed, used for context 128 278 icon: 'dashicon dashicons-edit', … … 135 285 cmd: 'unlink' 136 286 } ); 137 287 138 editor.on( 'preinit', function() {139 if ( editor.wp && editor.wp._createToolbar ){140 toolbar = editor.wp._createToolbar( [141 'wp_link_preview',142 'wp_link_edit',143 'wp_link_remove'144 ], true);288 // Advanced, more, options? 289 editor.addButton( 'wp_link_advanced', { 290 tooltip: 'Advanced', 291 icon: 'dashicon dashicons-admin-generic', 292 onclick: function() { 293 editor.execCommand( 'wp_link_cancel' ); 294 window.wpLink && window.wpLink.open( editor.id ); 145 295 } 146 296 } ); 297 298 editor.addButton( 'wp_link_apply', { 299 tooltip: 'Apply', 300 icon: 'dashicon dashicons-editor-break', 301 cmd: 'wp_link_apply', 302 classes: 'widget btn primary' 303 } ); 147 304 } ); 148 305 } )( window.tinymce );