Ticket #33301: 33301.9.patch
File 33301.9.patch, 12.2 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-input { 1754 float: left; 1755 margin: 2px; 1756 max-width: 694px; 1757 } 1758 1759 div.wp-link-input input { 1760 width: 300px; 1761 padding: 3px; 1762 -webkit-box-sizing: border-box; 1763 -moz-box-sizing: border-box; 1764 box-sizing: border-box; 1765 } 1766 1767 @media screen and ( max-width: 400px ) { 1768 div.wp-link-input { 1769 min-width: auto; 1770 max-width: 70%; 1771 max-width: -webkit-calc(100% - 80px); 1772 max-width: calc(100% - 80px); 1773 } 1774 1775 div.wp-link-input input { 1776 width: 100%; 1777 font-size: 16px; 1778 padding: 4px; 1779 } 1780 } 1781 1782 .ui-autocomplete.mce-wp-autocomplete { 1783 z-index: 100100; 1784 margin-top: 10px; 1785 max-height: 200px; 1786 overflow-y: auto; 1787 } 1788 1712 1789 /* =Overlay Body 1713 1790 -------------------------------------------------------------- */ 1714 1791 -
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-input">' + 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 var $ = window.jQuery; 70 71 editor.on( 'preinit', function() { 72 if ( editor.wp && editor.wp._createToolbar ) { 73 toolbar = editor.wp._createToolbar( [ 74 'wp_link_preview', 75 'wp_link_edit', 76 'wp_link_remove' 77 ], true ); 78 79 editToolbar = editor.wp._createToolbar( [ 80 'wp_link_input', 81 'wp_link_apply', 82 'wp_link_advanced' 83 ], true ); 84 85 editToolbar.on( 'show', function() { 86 var node = editToolbar.find( 'toolbar' )[0]; 87 node && node.focus( true ); 88 a = editor.dom.getParent( editor.selection.getNode(), 'a' ); 89 } ); 90 91 editToolbar.on( 'hide', function() { 92 editToolbar.scrolling || editor.execCommand( 'wp_link_cancel' ); 93 } ); 94 } 95 } ); 52 96 53 97 editor.addCommand( 'WP_Link', function() { 54 window.wpLink && window.wpLink.open( editor.id ); 55 }); 98 var a = editor.dom.getParent( editor.selection.getNode(), 'a' ); 99 100 if ( a ) { 101 editor.dom.setAttribs( a, { 'data-wp-edit': true } ); 102 } else { 103 editor.execCommand( 'mceInsertLink', false, { href: '_wp_link_placeholder' } ); 104 } 105 106 editor.nodeChanged(); 107 } ); 108 109 editor.addCommand( 'wp_link_apply', function() { 110 if ( editToolbar.scrolling ) { 111 return; 112 } 113 114 var href = tinymce.trim( inputInstance.getEl().firstChild.value ); 115 116 if ( href && ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( href ) ) { 117 href = 'http://' + href; 118 } 119 120 if ( ! href ) { 121 editor.dom.remove( a, true ); 122 return; 123 } 124 125 if ( a ) { 126 editor.dom.setAttribs( a, { href: href, 'data-wp-edit': null } ); 127 } 128 129 a = false; 130 131 editor.nodeChanged(); 132 editor.focus(); 133 } ); 134 135 editor.addCommand( 'wp_link_cancel', function() { 136 if ( a ) { 137 if ( editor.$( a ).attr( 'href' ) === '_wp_link_placeholder' ) { 138 editor.dom.remove( a, true ); 139 } else { 140 editor.dom.setAttribs( a, { 'data-wp-edit': null } ); 141 } 142 } 143 144 a = false; 145 146 editor.nodeChanged(); 147 editor.focus(); 148 } ); 56 149 57 150 // WP default shortcut 58 151 editor.addShortcut( 'access+a', '', 'WP_Link' ); … … 102 195 editor.addButton( 'wp_link_preview', { 103 196 type: 'WPLinkPreview', 104 197 onPostRender: function() { 105 var self = this; 198 previewInstance = this; 199 } 200 } ); 106 201 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; 202 editor.addButton( 'wp_link_input', { 203 type: 'WPLinkInput', 204 onPostRender: function() { 205 var input = this.getEl().firstChild; 206 var cache; 207 var last; 208 209 inputInstance = this; 210 211 if ( $ ) { 212 $( input ) 213 .on( 'keydown', function() { 214 $( input ).removeAttr( 'aria-activedescendant' ); 215 } ) 216 .autocomplete( { 217 source: function( request, response ) { 218 if ( last === request.term ) { 219 response( cache ); 220 return; 221 } 222 223 if ( /^https?:/.test( request.term ) || request.term.indexOf( '.' ) !== -1 ) { 224 return response(); 225 } 226 227 $.post( window.ajaxurl, { 228 action: 'wp-link-ajax', 229 page: 1, 230 search: request.term, 231 _ajax_linking_nonce: $( '#_ajax_linking_nonce' ).val() 232 }, function( data ) { 233 cache = data; 234 response( data ); 235 }, 'json' ); 236 237 last = request.term; 238 }, 239 focus: function( event, ui ) { 240 $( input ).attr( 'aria-activedescendant', 'mce-wp-autocomplete-' + ui.item.ID ); 241 $( input ).val( ui.item.permalink ); 242 return false; 243 }, 244 select: function( event, ui ) { 245 $( input ).val( ui.item.permalink ); 246 return false; 247 }, 248 open: function() { 249 $( input ).attr( 'aria-expanded', 'true' ); 250 }, 251 close: function() { 252 $( input ).attr( 'aria-expanded', 'false' ); 253 }, 254 minLength: 2, 255 position: { 256 my: 'left top+5' 120 257 } 121 } 258 } ).autocomplete( 'instance' )._renderItem = function( ul, item ) { 259 return $( '<li role="option" id="mce-wp-autocomplete-' + item.ID + '">' ) 260 .append( '<span>' + item.title + '</span> <span class="alignright">' + item.info + '</span>' ) 261 .appendTo( ul ); 262 }; 263 264 $( input ) 265 .attr( { 266 'role': 'combobox', 267 'aria-autocomplete': 'list', 268 'aria-expanded': 'false', 269 'aria-owns': $( input ).autocomplete( 'widget' ).attr( 'id' ) 270 } ) 271 .on( 'focus', function() { 272 $( input ).autocomplete( 'search' ); 273 } ) 274 .autocomplete( 'widget' ) 275 .addClass( 'mce-wp-autocomplete' ) 276 .attr( 'role', 'listbox' ) 277 .hover( 278 function() { 279 $( document.body ).addClass( 'modal-open' ); 280 }, 281 function() { 282 $( document.body ).removeClass( 'modal-open' ); 283 } 284 ); 285 } 286 287 tinymce.$( input ).on( 'keydown', function( event ) { 288 event.keyCode === 13 && editor.execCommand( 'wp_link_apply' ); 122 289 } ); 123 290 } 124 291 } ); 125 292 293 editor.on( 'wptoolbar', function( event ) { 294 var anchor = editor.dom.getParent( event.element, 'a' ), 295 $anchor, 296 href, edit; 297 298 if ( anchor ) { 299 $anchor = editor.$( anchor ); 300 href = $anchor.attr( 'href' ); 301 edit = $anchor.attr( 'data-wp-edit' ); 302 303 if ( href === '_wp_link_placeholder' || edit ) { 304 inputInstance.setURL( edit ? href : '' ); 305 event.element = anchor; 306 event.toolbar = editToolbar; 307 } else if ( href && ! $anchor.find( 'img' ).length ) { 308 previewInstance.setURL( href ); 309 event.element = anchor; 310 event.toolbar = toolbar; 311 } 312 } 313 } ); 314 126 315 editor.addButton( 'wp_link_edit', { 127 316 tooltip: 'Edit ', // trailing space is needed, used for context 128 317 icon: 'dashicon dashicons-edit', … … 135 324 cmd: 'unlink' 136 325 } ); 137 326 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);327 // Advanced, more, options? 328 editor.addButton( 'wp_link_advanced', { 329 tooltip: 'Advanced', 330 icon: 'dashicon dashicons-admin-generic', 331 onclick: function() { 332 editor.execCommand( 'wp_link_apply' ); 333 window.wpLink && window.wpLink.open( editor.id ); 145 334 } 146 335 } ); 336 337 editor.addButton( 'wp_link_apply', { 338 tooltip: 'Apply', 339 icon: 'dashicon dashicons-editor-break', 340 cmd: 'wp_link_apply', 341 classes: 'widget btn primary' 342 } ); 147 343 } ); 148 344 } )( window.tinymce );