Ticket #22502: 22502.3.diff
File 22502.3.diff, 6.4 KB (added by , 12 years ago) |
---|
-
wp-includes/css/media-views.css
372 372 user-select: none; 373 373 } 374 374 375 .media-menu li { 375 .media-menu .media-menu-item { 376 display: block; 376 377 position: relative; 377 378 padding: 4px 20px; 378 379 margin: 0; 379 380 line-height: 18px; 380 381 font-size: 14px; 381 color: #21759B;382 382 text-shadow: 0 1px 0 #fff; 383 text-decoration: none; 383 384 } 384 385 385 .media-menu-item { 386 cursor: pointer; 387 } 388 389 .media-menu li:hover { 386 .media-menu .media-menu-item:hover, 387 .media-menu .media-menu-item:focus { 388 color: #21759B; 389 background: #f1f1f1; 390 390 background: rgba( 0, 0, 0, 0.04 ); 391 outline: none; 391 392 } 392 393 393 .media-menu . active,394 .media-menu . active:hover {394 .media-menu .media-menu-item.active, 395 .media-menu .media-menu-item.active:hover { 395 396 color: #333; 396 397 font-weight: bold; 397 398 } … … 523 524 cursor: pointer; 524 525 } 525 526 527 .attachment-preview:focus { 528 outline: thin dotted; 529 } 530 526 531 .attachment .icon { 527 532 margin: 0 auto; 528 533 overflow: hidden; … … 1354 1359 width: 119px; 1355 1360 } 1356 1361 1357 .media-menu li{1362 .media-menu .media-menu-item { 1358 1363 padding: 4px 10px; 1359 1364 } 1360 1365 -
wp-includes/js/media-editor.js
535 535 workflow.open(); 536 536 else 537 537 workflow = wp.media.editor.add( id ); 538 538 539 // Add focus to modal 540 $( '.media-menu .active' ).focus(); 541 539 542 return workflow; 540 543 } 541 544 }; -
wp-includes/js/media-views.js
1648 1648 tagName: 'div', 1649 1649 template: media.template('media-modal'), 1650 1650 1651 attributes: { 1652 tabindex: 0 1653 }, 1654 1651 1655 events: { 1652 'click .media-modal-backdrop, .media-modal-close' : 'closeHandler' 1656 'click .media-modal-backdrop, .media-modal-close': 'closeHandler', 1657 'keydown': 'keydown' 1653 1658 }, 1654 1659 1655 1660 initialize: function() { … … 1659 1664 container: document.body, 1660 1665 title: '' 1661 1666 }); 1667 1668 _.bindAll( this, '_captureBodyKeydown' ); 1662 1669 }, 1663 1670 1664 1671 render: function() { … … 1691 1698 }, 1692 1699 1693 1700 open: function() { 1701 document.addEventListener( 'keydown', this._captureBodyKeydown, true ); 1694 1702 this.$el.show(); 1695 1703 this.trigger('open'); 1696 1704 return this; 1697 1705 }, 1698 1706 1699 1707 close: function() { 1708 document.removeEventListener( 'keydown', this._captureBodyKeydown, true ); 1700 1709 this.$el.hide(); 1701 1710 this.trigger('close'); 1702 1711 return this; … … 1715 1724 // Set and render the content. 1716 1725 this.options.$content = ( $content instanceof Backbone.View ) ? $content.$el : $content; 1717 1726 return this.render(); 1727 }, 1728 1729 1730 // Thanks to jQuery UI dialog, which also limits tabbing to a modal 1731 // window. The `:tabbable` expression, `$.ui.keyCode` object, and 1732 // the overloaded `$.fn.focus( delay )` signature are all from the 1733 // jQuery UI core. 1734 keydown: function( event ) { 1735 var tabbables, first, last; 1736 1737 // Close the modal when escape is pressed. 1738 if ( $.ui.keyCode.ESCAPE === event.which ) { 1739 event.preventDefault(); 1740 this.close(); 1741 return; 1742 } 1743 1744 // Prevent tabbing outside of the modal. 1745 if ( event.keyCode !== $.ui.keyCode.TAB ) 1746 return; 1747 1748 tabbables = this.$(':tabbable'); 1749 first = tabbables.filter(':first'); 1750 last = tabbables.filter(':last'); 1751 1752 // If we attempt to tab past the last tabbable element, skip 1753 // straight to the first tabbable element (and vice versa). 1754 if ( event.target === last[0] && ! event.shiftKey ) { 1755 first.focus( 1 ); 1756 return false; 1757 } else if ( event.target === first[0] && event.shiftKey ) { 1758 last.focus( 1 ); 1759 return false; 1760 } 1761 }, 1762 1763 // If the focus somehow escapes the modal, restores focus to the 1764 // first focusable element inside the modal. 1765 // 1766 // Captures the document's keydown event when the modal is open. 1767 _captureBodyKeydown: function() { 1768 if ( event.keyCode !== $.ui.keyCode.TAB ) 1769 return; 1770 1771 if ( ! $.contains( this.el, document.activeElement ) ) 1772 this.$(':tabbable').first().focus( 1 ); 1718 1773 } 1719 1774 }); 1720 1775 … … 2347 2402 * wp.media.view.Menu 2348 2403 */ 2349 2404 media.view.Menu = media.view.PriorityList.extend({ 2350 tagName: 'ul',2351 2405 className: 'media-menu', 2352 2406 2353 2407 toView: function( options, state ) { … … 2372 2426 }); 2373 2427 2374 2428 media.view.MenuItem = media.View.extend({ 2375 tagName: ' li',2429 tagName: 'a', 2376 2430 className: 'media-menu-item', 2377 2431 2432 attributes: { 2433 href: '#' 2434 }, 2435 2378 2436 events: { 2379 2437 'click': 'click' 2380 2438 }, 2381 2439 2382 click: function( ) {2440 click: function( event ) { 2383 2441 var options = this.options; 2384 2442 2443 event.preventDefault(); 2444 2385 2445 if ( options.click ) 2386 2446 options.click.call( this ); 2387 2447 else if ( options.state ) … … 2417 2477 2418 2478 events: { 2419 2479 'click .attachment-preview': 'toggleSelection', 2480 'keydown .attachment-preview': 'keydown', 2420 2481 'change [data-setting]': 'updateSetting', 2421 2482 'change [data-setting] input': 'updateSetting', 2422 2483 'change [data-setting] select': 'updateSetting', … … 2493 2554 this.$bar.width( this.model.get('percent') + '%' ); 2494 2555 }, 2495 2556 2496 toggleSelection: function( event ) { 2557 keydown: function( event ) { 2558 if ( $.ui.keyCode.ENTER === event.keyCode ) 2559 this.toggleSelection(); 2560 }, 2561 2562 toggleSelection: function() { 2497 2563 var selection = this.options.selection, 2498 2564 model = this.model; 2499 2565 -
wp-includes/media.php
1603 1603 </script> 1604 1604 1605 1605 <script type="text/html" id="tmpl-attachment"> 1606 <div class="attachment-preview type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}" >1606 <div class="attachment-preview type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}" tabindex="0"> 1607 1607 <# if ( data.uploading ) { #> 1608 1608 <div class="media-progress-bar"><div></div></div> 1609 1609 <# } else if ( 'image' === data.type ) { #> … … 1624 1624 <# } #> 1625 1625 1626 1626 <# if ( data.buttons.check ) { #> 1627 <a class="check" href="#" ><span>✓</span><span class="dash">–</span></a>1627 <a class="check" href="#" tabindex="-1"><span>✓</span><span class="dash">–</span></a> 1628 1628 <# } #> 1629 1629 </div> 1630 1630 <# if ( data.describe ) { #>