Ticket #30468: 30468.3.patch
| File 30468.3.patch, 16.2 KB (added by , 11 years ago) |
|---|
-
src/wp-includes/class-wp-editor.php
1436 1436 // display: none is required here, see #WP27605 1437 1437 ?> 1438 1438 <div id="wp-link-backdrop" style="display: none"></div> 1439 <div id="wp-link-wrap" class="wp-core-ui<?php echo $search_panel_visible; ?>" style="display: none" >1439 <div id="wp-link-wrap" class="wp-core-ui<?php echo $search_panel_visible; ?>" style="display: none" role="dialog" aria-labelledby="link-modal-title" tabindex="0"> 1440 1440 <form id="wp-link" tabindex="-1"> 1441 1441 <?php wp_nonce_field( 'internal-linking', '_ajax_linking_nonce', false ); ?> 1442 <div id="link-modal-title"> 1443 <?php _e( 'Insert/edit link' ) ?> 1444 <button type="button" id="wp-link-close"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button> 1445 </div> 1442 <h1 id="link-modal-title"><?php _e( 'Insert/edit link' ) ?></h1> 1443 <button type="button" id="wp-link-close"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button> 1446 1444 <div id="link-selector"> 1447 1445 <div id="link-options"> 1448 <p class="howto" ><?php _e( 'Enter the destination URL' ); ?></p>1446 <p class="howto" id="wp-link-howto-url"><?php _e( 'Enter the destination URL' ); ?></p> 1449 1447 <div class="wp-link-text-field"> 1450 1448 <label><span><?php _e( 'Link Text' ); ?></span><input id="wp-link-text" type="text" /></label> 1451 1449 </div> 1452 1450 <div> 1453 <label><span><?php _e( 'URL' ); ?></span><input id="wp-link-url" type="text" /></label>1451 <label><span><?php _e( 'URL' ); ?></span><input id="wp-link-url" type="text" aria-describedby="wp-link-howto-url" /></label> 1454 1452 </div> 1455 1453 <div class="link-target"> 1456 <label><span> </span><input type="checkbox" id="wp-link-target" /> <?php _e( 'Open link in a new window/tab' ); ?></label>1454 <label><span></span><input type="checkbox" id="wp-link-target" /> <?php _e( 'Open link in a new window/tab' ); ?></label> 1457 1455 </div> 1458 1456 </div> 1459 < p class="howto"><a href="#" id="wp-link-search-toggle"><?php _e( 'Or link to existing content' ); ?></a></p>1457 <div class="howto"><button type="button" id="wp-link-search-toggle" class="button" aria-expanded="false"><?php _e( 'Or link to existing content' ); ?></button></div> 1460 1458 <div id="search-panel"> 1461 1459 <div class="link-search-wrapper"> 1462 1460 <label> 1463 <span class="search-label"><?php _e( 'Search' ); ?></span> 1464 <input type="search" id="wp-link-search" class="link-search-field" autocomplete="off" /> 1461 <span class="search-label"><?php _e( 'Search' ); ?></span><input type="search" id="wp-link-search" class="link-search-field" autocomplete="off" aria-describedby="query-notice-hint" /> 1465 1462 <span class="spinner"></span> 1466 1463 </label> 1467 1464 </div> 1468 <div id="search-results" class="query-results" tabindex="0"> 1469 <ul></ul> 1470 <div class="river-waiting"> 1471 <span class="spinner"></span> 1465 <div role="application" aria-label="<?php esc_attr_e( 'Links:' ); ?>"> 1466 <div id="search-results" class="query-results" tabindex="0" role="list" aria-label="<?php esc_attr_e( 'Search results:' ); ?>"> 1467 <ul aria-live="polite" aria-relevant="all" aria-atomic="true"></ul> 1468 <div class="river-waiting"> 1469 <span class="spinner"></span> 1470 </div> 1472 1471 </div> 1473 1472 </div> 1474 <div id="most-recent-results" class="query-results" tabindex="0" >1473 <div id="most-recent-results" class="query-results" tabindex="0" role="list" aria-labelledby="query-notice-default"> 1475 1474 <div class="query-notice" id="query-notice-message"> 1476 <em class="query-notice-default" ><?php _e( 'No search term specified. Showing recent items.' ); ?></em>1477 <em class="query-notice-hint screen-reader-text" ><?php _e( 'Search or use up and down arrow keys to select an item.' ); ?></em>1475 <em class="query-notice-default" id="query-notice-default"><?php _e( 'No search term specified. Showing recent items.' ); ?></em> 1476 <em class="query-notice-hint screen-reader-text" id="query-notice-hint"><?php _e( 'Search or use up and down arrow keys to select an item.' ); ?></em> 1478 1477 </div> 1479 1478 <ul></ul> 1480 1479 <div class="river-waiting"> … … 1485 1484 </div> 1486 1485 <div class="submitbox"> 1487 1486 <div id="wp-link-cancel"> 1488 < a class="submitdelete deletion" href="#"><?php _e( 'Cancel' ); ?></a>1487 <button type="button" id="wp-link-cancel-button" class="button"><?php _e( 'Cancel' ); ?></button> 1489 1488 </div> 1490 1489 <div id="wp-link-update"> 1491 1490 <input type="submit" value="<?php esc_attr_e( 'Add Link' ); ?>" class="button button-primary" id="wp-link-submit" name="wp-link-submit"> -
src/wp-includes/css/editor.css
920 920 padding: 10px; 921 921 margin: 1px 0 0; 922 922 line-height: 150%; 923 border: 0 none;923 border: 0; 924 924 outline: none; 925 925 display: block; 926 926 resize: vertical; … … 1220 1220 } 1221 1221 1222 1222 #wp-link-wrap.search-panel-visible { 1223 height: 5 00px;1224 margin-top: -25 0px;1223 height: 510px; 1224 margin-top: -255px; 1225 1225 } 1226 1226 1227 1227 #wp-link-wrap .wp-link-text-field { … … 1239 1239 font-size: 18px; 1240 1240 font-weight: 600; 1241 1241 line-height: 36px; 1242 margin: 0; 1242 1243 padding: 0 36px 0 16px; 1243 top: 0;1244 right: 0;1245 left: 0;1246 1244 } 1247 1245 1248 1246 #wp-link-close { … … 1307 1305 1308 1306 #wp-link-search-toggle:after { 1309 1307 display: inline-block; 1310 font: normal 20px/ 1'dashicons';1308 font: normal 20px/26px 'dashicons'; 1311 1309 vertical-align: top; 1312 1310 speak: none; 1313 1311 -webkit-font-smoothing: antialiased; … … 1329 1327 padding: 8px 0 12px; 1330 1328 } 1331 1329 1330 #wp-link div.howto { 1331 margin: 0 0 12px 85px; 1332 } 1333 1332 1334 #wp-link p.howto { 1333 1335 margin: 3px 0; 1334 1336 } … … 1338 1340 color: inherit; 1339 1341 } 1340 1342 1341 #wp-link-search-toggle { 1342 cursor: pointer; 1343 } 1344 1345 #wp-link label input[type="text"] { 1343 #wp-link label input[type="text"], 1344 #wp-link label input[type="search"] { 1346 1345 margin-top: 5px; 1347 1346 width: 70%; 1348 1347 } … … 1356 1355 max-width: 24%; 1357 1356 } 1358 1357 1359 #wp-link .link-search-field {1360 float: left;1361 width: 250px;1362 max-width: 70%;1363 }1364 1365 1358 #wp-link .link-search-wrapper { 1366 1359 margin: 5px 0 9px; 1367 1360 display: block; … … 1368 1361 overflow: hidden; 1369 1362 } 1370 1363 1371 #wp-link .link-search-wrapper span {1372 float: left;1373 margin-top: 4px;1374 }1375 1376 1364 #wp-link .link-search-wrapper .spinner { 1377 1365 display: none; 1378 1366 vertical-align: text-bottom; 1367 margin: 8px 20px 0 0; 1379 1368 } 1380 1369 1381 1370 #wp-link .link-target { … … 1383 1372 white-space: nowrap; 1384 1373 overflow: hidden; 1385 1374 text-overflow: ellipsis; 1375 max-width: 90%; 1386 1376 } 1387 1377 1388 #wp-link .link-target label {1389 max-width: 70%;1390 }1391 1392 1378 #wp-link .query-results { 1393 1379 border: 1px #dfdfdf solid; 1394 1380 margin: 0; … … 1402 1388 } 1403 1389 1404 1390 .has-text-field #wp-link .query-results { 1405 top: 2 05px;1391 top: 215px; 1406 1392 } 1407 1393 1408 1394 #wp-link li { … … 1413 1399 padding: 4px 6px 4px 10px; 1414 1400 cursor: pointer; 1415 1401 position: relative; 1402 outline: 0; 1416 1403 } 1417 1404 1418 1405 #wp-link .query-notice { … … 1544 1531 } 1545 1532 1546 1533 #wp-link-wrap.search-panel-visible.has-text-field .query-results { 1547 top: 2 35px;1534 top: 270px; 1548 1535 } 1549 1536 1550 1537 #link-selector { … … 1558 1545 #wp-link-cancel { 1559 1546 line-height: 32px; 1560 1547 } 1548 1549 #wp-link .link-target { 1550 padding-top: 10px; 1551 } 1552 1553 #wp-link-search-toggle { 1554 line-height: 26px; 1555 } 1556 1557 #wp-link-wrap.search-panel-visible #link-selector { 1558 bottom: 48px; 1559 } 1560 1561 #wp-link .link-search-wrapper .spinner { 1562 margin-top: 12px; 1563 } 1561 1564 } 1562 1565 1563 1566 @media screen and ( max-width: 520px ) { … … 1901 1904 1902 1905 #wp-fullscreen-buttons .mce-btn button { 1903 1906 margin: 0; 1904 outline: 0 none;1905 border: 0 none;1907 outline: 0; 1908 border: 0; 1906 1909 white-space: nowrap; 1907 1910 width: auto; 1908 1911 background: none; -
src/wp-includes/js/wplink.js
5 5 var editor, searchTimer, River, Query, correctedURL, 6 6 inputs = {}, 7 7 rivers = {}, 8 isTouch = ( 'ontouchend' in document ); 8 isTouch = ( 'ontouchend' in document ), 9 visible; 9 10 10 11 function getLink() { 11 12 return editor.dom.getParent( editor.selection.getNode(), 'a' ); … … 15 16 timeToTriggerRiver: 150, 16 17 minRiverAJAXDuration: 200, 17 18 riverBottomThreshold: 5, 18 keySensitivity: 1 00,19 keySensitivity: 150, 19 20 lastSearch: '', 20 21 textarea: '', 21 22 … … 31 32 inputs.url = $( '#wp-link-url' ); 32 33 inputs.nonce = $( '#_ajax_linking_nonce' ); 33 34 inputs.openInNewTab = $( '#wp-link-target' ); 35 inputs.searchToggle = $( '#wp-link-search-toggle' ); 34 36 inputs.search = $( '#wp-link-search' ); 35 37 36 38 // Build Rivers … … 50 52 event.preventDefault(); 51 53 wpLink.update(); 52 54 }); 53 inputs.close.add( inputs.backdrop ).add( '#wp-link-cancel a' ).click( function( event ) {55 inputs.close.add( inputs.backdrop ).add( '#wp-link-cancel-button' ).click( function( event ) { 54 56 event.preventDefault(); 55 57 wpLink.close(); 56 58 }); 57 59 58 $( '#wp-link-search-toggle' ).on( 'click', wpLink.toggleInternalLinking );60 inputs.searchToggle.on( 'click', wpLink.toggleInternalLinking ); 59 61 60 62 rivers.elements.on( 'river-select', wpLink.updateFields ); 61 63 … … 145 147 // Refresh rivers (clear links, check visibility) 146 148 rivers.search.refresh(); 147 149 rivers.recent.refresh(); 150 visible = inputs.wrap.hasClass( 'search-panel-visible' ); 148 151 149 152 if ( wpLink.isMCE() ) { 150 153 wpLink.mceRefresh(); … … 156 159 157 160 if ( isTouch ) { 158 161 // Close the onscreen keyboard 159 inputs. url.focus().blur();162 inputs.text.focus().blur(); 160 163 } else { 161 164 // Focus the URL field and highlight its contents. 162 165 // If this is moved above the selection changes, 163 166 // IE will show a flashing cursor over the dialog. 164 inputs. url.focus()[0].select();167 inputs.text.focus()[0].select(); 165 168 } 166 169 167 170 // Load the most recent results if this is the first time opening the panel. … … 170 173 } 171 174 172 175 correctedURL = inputs.url.val().replace( /^http:\/\//, '' ); 176 177 // Toggle the button aria-expanded attribute. 178 if ( visible ) { 179 inputs.searchToggle.attr( 'aria-expanded', 'true' ); 180 } else { 181 inputs.searchToggle.attr( 'aria-expanded', 'false' ); 182 } 173 183 }, 174 184 175 185 hasSelectedText: function( linkNode ) { … … 401 411 rivers.search.show(); 402 412 403 413 // Don't search if the keypress didn't change the title. 404 if ( wpLink.lastSearch == search ) 414 if ( wpLink.lastSearch == search ) { 405 415 return; 416 } 406 417 407 418 wpLink.lastSearch = search; 408 419 waiting = t.parent().find('.spinner').show(); … … 452 463 return; 453 464 } 454 465 455 if ( document.activeElement && 456 ( document.activeElement.id === 'link-title-field' || document.activeElement.id === 'url-field' ) ) { 466 if ( document.activeElement && ( 467 'wp-link-close' === document.activeElement.id || 468 'link-title-field' === document.activeElement.id || 469 'url-field' === document.activeElement.id || 470 'link-target-checkbox' === document.activeElement.id || 471 'wp-link-search-toggle' === document.activeElement.id || 472 'wp-link-cancel-button' === document.activeElement.id || 473 'wp-link-submit' === document.activeElement.id 474 ) ) { 457 475 return; 458 476 } 459 477 … … 476 494 delayedCallback: function( func, delay ) { 477 495 var timeoutTriggered, funcTriggered, funcArgs, funcContext; 478 496 479 if ( ! delay ) 497 if ( ! delay ) { 480 498 return func; 499 } 481 500 482 501 setTimeout( function() { 483 if ( funcTriggered ) 502 if ( funcTriggered ) { 484 503 return func.apply( funcContext, funcArgs ); 504 } 485 505 // Otherwise, wait. 486 506 timeoutTriggered = true; 487 507 }, delay ); 488 508 489 509 return function() { 490 if ( timeoutTriggered ) 510 if ( timeoutTriggered ) { 491 511 return func.apply( this, arguments ); 512 } 492 513 // Otherwise, wait. 493 514 funcArgs = arguments; 494 515 funcContext = this; … … 497 518 }, 498 519 499 520 toggleInternalLinking: function( event ) { 500 v ar visible = inputs.wrap.hasClass( 'search-panel-visible' );521 visible = inputs.wrap.hasClass( 'search-panel-visible' ); 501 522 502 523 inputs.wrap.toggleClass( 'search-panel-visible', ! visible ); 503 524 setUserSetting( 'wplink', visible ? '0' : '1' ); 504 inputs[ ! visible ? 'search' : 'url' ].focus(); 525 if ( ! visible ) { 526 inputs.search.focus(); 527 inputs.searchToggle.attr( 'aria-expanded', 'true' ); 528 } else { 529 inputs.searchToggle.attr( 'aria-expanded', 'false' ); 530 } 505 531 event.preventDefault(); 506 532 } 507 533 }; … … 544 570 select: function( li, event ) { 545 571 var liHeight, elHeight, liTop, elTop; 546 572 547 if ( li.hasClass( 'unselectable' ) || li == this.selected ) 548 return; 573 if ( li.hasClass( 'unselectable' ) || li == this.selected ) { 574 return; 575 } 549 576 550 577 this.deselect(); 551 this.selected = li.addClass( 'selected' ) ;578 this.selected = li.addClass( 'selected' ).attr( 'aria-selected', 'true' ).focus(); 552 579 // Make sure the element is visible 553 580 liHeight = li.outerHeight(); 554 581 elHeight = this.element.height(); … … 555 582 liTop = li.position().top; 556 583 elTop = this.element.scrollTop(); 557 584 558 if ( liTop < 0 ) // Make first visible element585 if ( liTop < 0 ) { // Make first visible element 559 586 this.element.scrollTop( elTop + liTop ); 560 else if ( liTop + liHeight > elHeight )// Make last visible element587 } else if ( liTop + liHeight > elHeight ) { // Make last visible element 561 588 this.element.scrollTop( elTop + liTop - elHeight + liHeight ); 589 } 562 590 563 591 // Trigger the river-select event 564 592 this.element.trigger( 'river-select', [ li, event, this ] ); 565 593 }, 566 594 deselect: function() { 567 if ( this.selected ) 568 this.selected.removeClass( 'selected' ); 595 if ( this.selected ) { 596 this.selected.removeClass( 'selected' ).attr( 'aria-selected', 'false' ); 597 } 569 598 this.selected = false; 570 599 }, 571 600 prev: function() { 572 if ( ! this.visible ) 601 if ( ! this.visible ) { 573 602 return; 603 } 574 604 575 605 var to; 576 606 if ( this.selected ) { 577 607 to = this.selected.prev( 'li' ); 578 if ( to.length ) 608 if ( to.length ) { 579 609 this.select( to ); 610 } 580 611 } 581 612 }, 582 613 next: function() { 583 if ( ! this.visible ) 614 if ( ! this.visible ) { 584 615 return; 616 } 585 617 586 618 var to = this.selected ? this.selected.next( 'li' ) : $( 'li:not(.unselectable):first', this.element ); 587 if ( to.length ) 619 if ( to.length ) { 588 620 this.select( to ); 621 } 589 622 }, 590 623 ajax: function( callback ) { 591 624 var self = this, … … 592 625 delay = this.query.page == 1 ? 0 : wpLink.minRiverAJAXDuration, 593 626 response = wpLink.delayedCallback( function( results, params ) { 594 627 self.process( results, params ); 595 if ( callback ) 628 if ( callback ) { 596 629 callback( results, params ); 630 } 597 631 }, delay ); 598 632 599 633 this.query.ajax( response ); 600 634 }, 601 635 change: function( search ) { 602 if ( this.query && this._search == search ) 636 if ( this.query && this._search == search ) { 603 637 return; 638 } 604 639 605 640 this._search = search; 606 641 this.query = new Query( search ); … … 619 654 $.each( results, function() { 620 655 classes = alt ? 'alternate' : ''; 621 656 classes += this.title ? '' : ' no-title'; 622 list += classes ? '<li class="' + classes + '" >' : '<li>';657 list += classes ? '<li class="' + classes + '" tabindex="-1" role="listitem">' : '<li tabindex="-1" role="listitem">'; 623 658 list += '<input type="hidden" class="item-permalink" value="' + this.permalink + '" />'; 624 659 list += '<span class="item-title">'; 625 660 list += this.title ? this.title : wpLinkL10n.noTitle; … … 635 670 el = this.element, 636 671 bottom = el.scrollTop() + el.height(); 637 672 638 if ( ! this.query.ready() || bottom < this.contentHeight.height() - wpLink.riverBottomThreshold ) 673 if ( ! this.query.ready() || bottom < this.contentHeight.height() - wpLink.riverBottomThreshold ) { 639 674 return; 675 } 640 676 641 677 setTimeout(function() { 642 678 var newTop = el.scrollTop(), 643 679 newBottom = newTop + el.height(); 644 680 645 if ( ! self.query.ready() || newBottom < self.contentHeight.height() - wpLink.riverBottomThreshold ) 681 if ( ! self.query.ready() || newBottom < self.contentHeight.height() - wpLink.riverBottomThreshold ) { 646 682 return; 683 } 647 684 648 685 self.waiting.show(); 649 686 el.scrollTop( newTop + self.waiting.outerHeight() ); … … 674 711 '_ajax_linking_nonce' : inputs.nonce.val() 675 712 }; 676 713 677 if ( this.search ) 714 if ( this.search ) { 678 715 query.search = this.search; 716 } 679 717 680 718 this.querying = true; 681 719