Changeset 45866
- Timestamp:
- 08/20/2019 10:41:02 PM (4 years ago)
- Location:
- branches/5.2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.2
-
branches/5.2/src/js/media/views/focus-manager.js
r45840 r45866 17 17 /** 18 18 * Moves focus to the first visible menu item in the modal. 19 * 20 * @since 3.5.0 21 * 22 * @returns {void} 19 23 */ 20 24 focus: function() { … … 22 26 }, 23 27 /** 24 * @param {Object} event 28 * Constrains navigation with the Tab key within the media view element. 29 * 30 * @since 4.0.0 31 * 32 * @param {Object} event A keydown jQuery event. 33 * 34 * @returns {void} 25 35 */ 26 36 constrainTabbing: function( event ) { … … 43 53 return false; 44 54 } 45 } 55 }, 46 56 57 /** 58 * Hides from assistive technologies all the body children except the 59 * provided element and other elements that should not be hidden. 60 * 61 * The reason why we use `aria-hidden` is that `aria-modal="true"` is buggy 62 * in Safari 11.1 and support is spotty in other browsers. In the future we 63 * should consider to remove this helper function and only use `aria-modal="true"`. 64 * 65 * @since 5.3.0 66 * 67 * @param {object} visibleElement The jQuery object representing the element that should not be hidden. 68 * 69 * @returns {void} 70 */ 71 setAriaHiddenOnBodyChildren: function( visibleElement ) { 72 var bodyChildren, 73 self = this; 74 75 if ( this.isBodyAriaHidden ) { 76 return; 77 } 78 79 // Get all the body children. 80 bodyChildren = document.body.children; 81 82 // Loop through the body children and hide the ones that should be hidden. 83 _.each( bodyChildren, function( element ) { 84 // Don't hide the modal element. 85 if ( element === visibleElement[0] ) { 86 return; 87 } 88 89 // Determine the body children to hide. 90 if ( self.elementShouldBeHidden( element ) ) { 91 element.setAttribute( 'aria-hidden', 'true' ); 92 // Store the hidden elements. 93 self.ariaHiddenElements.push( element ); 94 } 95 } ); 96 97 this.isBodyAriaHidden = true; 98 }, 99 100 /** 101 * Makes visible again to assistive technologies all body children 102 * previously hidden and stored in this.ariaHiddenElements. 103 * 104 * @since 5.3.0 105 * 106 * @returns {void} 107 */ 108 removeAriaHiddenFromBodyChildren: function() { 109 _.each( this.ariaHiddenElements, function( element ) { 110 element.removeAttribute( 'aria-hidden' ); 111 } ); 112 113 this.ariaHiddenElements = []; 114 this.isBodyAriaHidden = false; 115 }, 116 117 /** 118 * Determines if the passed element should not be hidden from assistive technologies. 119 * 120 * @since 5.3.0 121 * 122 * @param {object} element The DOM element that should be checked. 123 * 124 * @returns {boolean} Whether the element should not be hidden from assistive technologies. 125 */ 126 elementShouldBeHidden: function( element ) { 127 var role = element.getAttribute( 'role' ), 128 liveRegionsRoles = [ 'alert', 'status', 'log', 'marquee', 'timer' ]; 129 130 /* 131 * Don't hide scripts, elements that already have `aria-hidden`, and 132 * ARIA live regions. 133 */ 134 return ! ( 135 element.tagName === 'SCRIPT' || 136 element.hasAttribute( 'aria-hidden' ) || 137 element.hasAttribute( 'aria-live' ) || 138 liveRegionsRoles.indexOf( role ) !== -1 139 ); 140 }, 141 142 /** 143 * Whether the body children are hidden from assistive technologies. 144 * 145 * @since 5.3.0 146 */ 147 isBodyAriaHidden: false, 148 149 /** 150 * Stores an array of DOM elements that should be hidden from assistive 151 * technologies, for example when the media modal dialog opens. 152 * 153 * @since 5.3.0 154 */ 155 ariaHiddenElements: [] 47 156 }); 48 157 -
branches/5.2/src/js/media/views/modal.js
r45849 r45866 118 118 this.$( '.media-modal' ).focus(); 119 119 120 // Hide the page content from assistive technologies. 121 this.focusManager.setAriaHiddenOnBodyChildren( $el ); 122 120 123 return this.propagate('open'); 121 124 }, … … 135 138 // Hide modal and remove restricted media modal tab focus once it's closed 136 139 this.$el.hide().undelegate( 'keydown' ); 140 141 /* 142 * Make visible again to assistive technologies all body children that 143 * have been made hidden when the modal opened. 144 */ 145 this.focusManager.removeAriaHiddenFromBodyChildren(); 137 146 138 147 // Put focus back in useful location once modal is closed. -
branches/5.2/src/wp-includes/css/media-views.css
r45840 r45866 540 540 bottom: 0; 541 541 margin: 0; 542 padding: 10px 0;542 padding: 50px 0 10px; 543 543 background: #f3f3f3; 544 544 border-right-width: 1px; … … 2562 2562 /* Landscape specific header override */ 2563 2563 @media screen and (max-height: 400px) { 2564 .media-menu { 2565 padding: 0; 2564 .media-menu, 2565 .media-frame:not(.hide-menu) .media-menu { 2566 top: 44px; 2566 2567 } 2567 2568 … … 2581 2582 .embed-link-settings { 2582 2583 overflow: visible; 2584 } 2585 } 2586 2587 @media only screen and (min-width: 901px) and (max-height: 400px) { 2588 .media-menu, 2589 .media-frame:not(.hide-menu) .media-menu { 2590 top: 0; 2591 padding-top: 44px; 2583 2592 } 2584 2593 } … … 2610 2619 .media-frame:not(.hide-menu) .media-menu { 2611 2620 top: 40px; 2621 padding-top: 0; 2612 2622 } 2613 2623 -
branches/5.2/src/wp-includes/media-template.php
r45865 r45866 186 186 <![endif]--> 187 187 <script type="text/html" id="tmpl-media-frame"> 188 <div class="media-frame-title" id="media-frame-title"></div> 188 189 <div class="media-frame-menu"></div> 189 <div class="media-frame-title"></div>190 190 <div class="media-frame-router"></div> 191 191 <div class="media-frame-content"></div> … … 195 195 196 196 <script type="text/html" id="tmpl-media-modal"> 197 <div tabindex="0" class="<?php echo $class; ?>" >197 <div tabindex="0" class="<?php echo $class; ?>" role="dialog" aria-modal="true" aria-labelledby="media-frame-title"> 198 198 <# if ( data.hasCloseButton ) { #> 199 199 <button type="button" class="media-modal-close"><span class="media-modal-icon"><span class="screen-reader-text"><?php _e( 'Close dialog' ); ?></span></span></button> 200 200 <# } #> 201 <div class="media-modal-content" ></div>201 <div class="media-modal-content" role="document"></div> 202 202 </div> 203 203 <div class="media-modal-backdrop"></div>
Note: See TracChangeset
for help on using the changeset viewer.