Changeset 28607
- Timestamp:
- 05/29/2014 03:38:31 AM (10 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/css/media-views.css
r28581 r28607 479 479 } 480 480 481 .media-router > a:active, 482 .media-router > a:focus { 481 .media-router > a:active { 483 482 outline: none; 484 483 } … … 695 694 -ms-user-select: none; 696 695 user-select: none; 696 } 697 698 .attachment:focus { 699 -webkit-box-shadow: 700 0 0 0 1px #5b9dd9, 701 0 0 2px 2px #5b9dd9; 702 box-shadow: 703 0 0 0 1px #5b9dd9, 704 0 0 2px 2px #5b9dd9; 705 outline: none; 697 706 } 698 707 … … 926 935 bottom: 0; 927 936 overflow: auto; 937 outline: none; 928 938 } 929 939 -
trunk/src/wp-includes/js/media-views.js
r28581 r28607 2314 2314 frame.close(); 2315 2315 } 2316 2317 // Keep focus inside media modal 2318 // after canceling a gallery 2319 new media.view.FocusManager({ 2320 el: this.el 2321 }).focus(); 2316 2322 } 2317 2323 }, … … 2496 2502 2497 2503 this.controller.setState('gallery-edit'); 2504 2505 // Keep focus inside media modal 2506 // after jumping to gallery view 2507 new media.view.FocusManager({ 2508 el: this.el 2509 }).focus(); 2498 2510 } 2499 2511 }); … … 2522 2534 2523 2535 this.controller.setState('playlist-edit'); 2536 2537 // Keep focus inside media modal 2538 // after jumping to playlist view 2539 new media.view.FocusManager({ 2540 el: this.el 2541 }).focus(); 2524 2542 } 2525 2543 }); … … 2548 2566 2549 2567 this.controller.setState('video-playlist-edit'); 2568 2569 // Keep focus inside media modal 2570 // after jumping to video playlist view 2571 new media.view.FocusManager({ 2572 el: this.el 2573 }).focus(); 2550 2574 } 2551 2575 }); … … 2957 2981 freeze: true 2958 2982 }); 2983 2984 this.focusManager = new media.view.FocusManager({ 2985 el: this.el 2986 }); 2959 2987 }, 2960 2988 /** … … 3038 3066 } 3039 3067 3040 this.$el.hide(); 3068 // Hide modal and remove restricted media modal tab focus once it's closed 3069 this.$el.hide().undelegate( 'keydown' ); 3070 3071 // Put focus back in useful location once modal is closed 3072 $('#wpbody-content').focus(); 3073 3041 3074 this.propagate('close'); 3042 3075 … … 3099 3132 this.escape(); 3100 3133 event.stopImmediatePropagation(); 3134 } else { 3135 // Keep focus inside the media modal 3136 this.focusManager; 3101 3137 } 3102 3138 } … … 3118 3154 3119 3155 focus: function() { 3120 if ( _.isUndefined( this.index ) ) { 3121 return; 3122 } 3123 3124 // Update our collection of `$tabbables`. 3125 this.$tabbables = this.$(':tabbable'); 3126 3127 // If tab is saved, focus it. 3128 this.$tabbables.eq( this.index ).focus(); 3156 // Reset focus on first left menu item 3157 $('.media-menu-item').first().focus(); 3129 3158 }, 3130 3159 /** … … 3137 3166 } 3138 3167 3139 // First try to update the index. 3140 if ( _.isUndefined( this.index ) ) { 3141 this.updateIndex( event ); 3142 } 3143 3144 // If we still don't have an index, bail. 3145 if ( _.isUndefined( this.index ) ) { 3146 return; 3147 } 3148 3149 var index = this.index + ( event.shiftKey ? -1 : 1 ); 3150 3151 if ( index >= 0 && index < this.$tabbables.length ) { 3152 this.index = index; 3153 } else { 3154 delete this.index; 3168 // Keep tab focus within media modal while it's open 3169 if ( event.target === this.tabbableLast[0] && !event.shiftKey ) { 3170 this.tabbableFirst.focus(); 3171 return false; 3172 } else if ( event.target === this.tabbableFirst[0] && event.shiftKey ) { 3173 this.tabbableLast.focus(); 3174 return false; 3155 3175 } 3156 3176 }, … … 3159 3179 */ 3160 3180 updateIndex: function( event ) { 3161 this.$tabbables = this.$(':tabbable'); 3162 3163 var index = this.$tabbables.index( event.target ); 3164 3165 if ( -1 === index ) { 3166 delete this.index; 3167 } else { 3168 this.index = index; 3169 } 3181 // Resets tabbable elements 3182 this.tabbables = $( ':tabbable', this.$el ); 3183 this.tabbableFirst = this.tabbables.filter( ':first' ); 3184 this.tabbableLast = this.tabbables.filter( ':last' ); 3170 3185 } 3171 3186 }); … … 4398 4413 template: media.template('attachment'), 4399 4414 4415 attributes: { 4416 tabIndex: 0, 4417 role: 'checkbox' 4418 }, 4419 4400 4420 events: { 4401 4421 'click .attachment-preview': 'toggleSelectionHandler', … … 4406 4426 'click .close': 'removeFromLibrary', 4407 4427 'click .check': 'removeFromSelection', 4408 'click a': 'preventDefault' 4428 'click a': 'preventDefault', 4429 'keydown': 'toggleSelectionHandler' 4409 4430 }, 4410 4431 … … 4414 4435 var selection = this.options.selection; 4415 4436 4437 this.$el.attr('aria-label', this.model.attributes.title).attr('aria-checked', false); 4416 4438 this.model.on( 'change:sizes change:uploading', this.render, this ); 4417 4439 this.model.on( 'change:title', this._syncTitle, this ); … … 4518 4540 var method; 4519 4541 4542 // Catch enter and space events 4543 if ( 'keydown' === event.type && 13 !== event.keyCode && 32 !== event.keyCode ) { 4544 return; 4545 } 4520 4546 if ( event.shiftKey ) { 4521 4547 method = 'between'; … … 4574 4600 } 4575 4601 4602 // Fixes bug that loses focus when selecting a featured image 4603 if ( !method ) { 4604 method = 'add'; 4605 } 4576 4606 if ( method !== 'add' ) { 4577 4607 method = 'reset'; … … 4618 4648 } 4619 4649 4620 this.$el.addClass('selected') ;4650 this.$el.addClass('selected').attr('aria-checked', true); 4621 4651 }, 4622 4652 /** … … 4633 4663 return; 4634 4664 } 4635 this.$el.removeClass('selected') ;4665 this.$el.removeClass('selected').attr('aria-checked', false); 4636 4666 }, 4637 4667 /** … … 4865 4895 tagName: 'ul', 4866 4896 className: 'attachments', 4897 4898 attributes: { 4899 tabIndex: -1 4900 }, 4867 4901 4868 4902 cssTemplate: media.template('attachments-css'), … … 5580 5614 event.preventDefault(); 5581 5615 this.collection.reset(); 5616 5617 // Keep focus inside media modal 5618 // after clear link is selected 5619 new media.view.FocusManager({ 5620 el: this.el 5621 }).focus(); 5582 5622 } 5583 5623 }); … … 5905 5945 initialize: function() { 5906 5946 /** 5907 * @member {wp.media.view.FocusManager}5908 */5909 this.focusManager = new media.view.FocusManager({5910 el: this.el5911 });5912 /**5913 5947 * call 'initialize' directly on the parent class 5914 5948 */ … … 5923 5957 */ 5924 5958 media.view.Attachment.prototype.render.apply( this, arguments ); 5925 this.focusManager.focus();5926 5959 return this; 5927 5960 }, … … 5934 5967 if ( confirm( l10n.warnDelete ) ) { 5935 5968 this.model.destroy(); 5969 // Keep focus inside media modal 5970 // after image is deleted 5971 new media.view.FocusManager({ 5972 el: this.el 5973 }).focus(); 5936 5974 } 5937 5975 }, … … 5989 6027 5990 6028 initialize: function() { 5991 /**5992 * @member {wp.media.view.FocusManager}5993 */5994 this.focusManager = new media.view.FocusManager({5995 el: this.el5996 });5997 5998 6029 this.model.on( 'change:compat', this.render, this ); 5999 6030 }, … … 6022 6053 this.$el.html( compat.item ); 6023 6054 this.views.render(); 6024 6025 this.focusManager.focus();6026 6055 return this; 6027 6056 }, -
trunk/src/wp-includes/media-template.php
r28581 r28607 120 120 $class .= ' ie7'; 121 121 ?> 122 <!--[if lte IE 8]> 123 <style> 124 .attachment:focus { 125 outline: #1e8cbe solid; 126 } 127 .selected.attachment { 128 outline: #1e8cbe solid; 129 } 130 </style> 131 <![endif]--> 122 132 <script type="text/html" id="tmpl-media-frame"> 123 133 <div class="media-frame-menu"></div> … … 239 249 <div class="thumbnail"> 240 250 <div class="centered"> 241 <img src="{{ data.size.url }}" draggable="false" />251 <img src="{{ data.size.url }}" draggable="false" alt="" /> 242 252 </div> 243 253 </div> … … 254 264 255 265 <# if ( data.buttons.check ) { #> 256 <a class="check" href="#" title="<?php esc_attr_e('Deselect'); ?>" ><div class="media-modal-icon"></div></a>266 <a class="check" href="#" title="<?php esc_attr_e('Deselect'); ?>" tabindex="-1"><div class="media-modal-icon"></div></a> 257 267 <# } #> 258 268 </div>
Note: See TracChangeset
for help on using the changeset viewer.