Ticket #22502: 22502.4.diff
File 22502.4.diff, 7.4 KB (added by , 12 years ago) |
---|
-
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 … … 3181 3247 clear: function( event ) { 3182 3248 event.preventDefault(); 3183 3249 this.collection.clear(); 3250 $( '.attachments .attachment-preview' ).first().focus(); 3184 3251 } 3185 3252 }); 3186 3253 … … 3257 3324 clear: function( event ) { 3258 3325 event.preventDefault(); 3259 3326 this.collection.clear(); 3327 $( '.attachments .attachment-preview' ).first().focus(); 3260 3328 } 3261 3329 }); 3262 3330 -
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="#" t itle="<?php _e('Deselect'); ?>"><div class="media-modal-icon"></div></a>1627 <a class="check" href="#" tabindex="-1"><div class="media-modal-icon"></div></a> 1628 1628 <# } #> 1629 1629 </div> 1630 1630 <# if ( data.describe ) { #> -
wp-includes/css/media-views.css
103 103 border: 1px dashed rgba( 255, 255, 255, 0.5 ); 104 104 } 105 105 106 .media-modal-title, 107 .media-modal-close { 106 .media-modal-title { 108 107 position: absolute; 109 108 height: 40px; 110 109 } … … 123 122 } 124 123 125 124 .media-modal-close { 125 position: absolute; 126 height: 15px; 126 127 top: -27px; 127 128 right: 0; 128 129 width: 15px; 129 130 background-position: -80px 0; 130 131 } 131 132 133 .media-modal-close:focus { 134 outline: thin dotted gray; 135 } 136 132 137 .media-modal-close:active { 133 138 outline: 0; 134 139 } … … 366 371 user-select: none; 367 372 } 368 373 369 .media-menu li { 374 .media-menu .media-menu-item { 375 display: block; 370 376 position: relative; 371 377 padding: 4px 20px; 372 378 margin: 0; 373 379 line-height: 18px; 374 380 font-size: 14px; 375 color: #21759B;376 381 text-shadow: 0 1px 0 #fff; 382 text-decoration: none; 377 383 } 378 384 379 .media-menu-item { 380 cursor: pointer; 381 } 382 383 .media-menu li:hover { 385 .media-menu .media-menu-item:hover, 386 .media-menu .media-menu-item:focus { 387 color: #21759B; 388 background: #f1f1f1; 384 389 background: rgba( 0, 0, 0, 0.04 ); 390 outline: none; 385 391 } 386 392 387 .media-menu . active,388 .media-menu . active:hover {393 .media-menu .media-menu-item.active, 394 .media-menu .media-menu-item.active:hover { 389 395 color: #333; 390 396 font-weight: bold; 391 397 } … … 517 523 cursor: pointer; 518 524 } 519 525 526 .attachment-preview:focus, 527 .media-selection .selected .attachment-preview:focus { 528 box-shadow: 529 0 0 0 1px #fff, 530 0 0 0 2px #999; 531 } 532 533 .selected .attachment-preview:focus, 534 .media-selection .selected.details .attachment-preview:focus { 535 box-shadow: 0 0 0 0; 536 } 537 520 538 .attachment .icon { 521 539 margin: 0 auto; 522 540 overflow: hidden; … … 1359 1377 width: 119px; 1360 1378 } 1361 1379 1362 .media-menu li{1380 .media-menu .media-menu-item { 1363 1381 padding: 4px 10px; 1364 1382 } 1365 1383