Changeset 29602
- Timestamp:
- 08/25/2014 06:22:34 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/media-views.js
r29601 r29602 2499 2499 // Keep focus inside media modal 2500 2500 // after canceling a gallery 2501 new media.view.FocusManager({ 2502 el: this.el 2503 }).focus(); 2501 this.controller.modal.focusManager.focus(); 2504 2502 } 2505 2503 }, … … 2690 2688 // Keep focus inside media modal 2691 2689 // after jumping to gallery view 2692 new media.view.FocusManager({ 2693 el: this.el 2694 }).focus(); 2690 this.controller.modal.focusManager.focus(); 2695 2691 } 2696 2692 }); … … 2722 2718 // Keep focus inside media modal 2723 2719 // after jumping to playlist view 2724 new media.view.FocusManager({ 2725 el: this.el 2726 }).focus(); 2720 this.controller.modal.focusManager.focus(); 2727 2721 } 2728 2722 }); … … 2754 2748 // Keep focus inside media modal 2755 2749 // after jumping to video playlist view 2756 new media.view.FocusManager({ 2757 el: this.el 2758 }).focus(); 2750 this.controller.modal.focusManager.focus(); 2759 2751 } 2760 2752 }); … … 3254 3246 } 3255 3247 3256 this.$ ( '.media-modal-close' ).focus();3248 this.$el.focus(); 3257 3249 3258 3250 return this.propagate('open'); … … 3352 3344 */ 3353 3345 media.view.FocusManager = media.View.extend({ 3346 3354 3347 events: { 3355 keydown: 'recordTab', 3356 focusin: 'updateIndex' 3357 }, 3358 3359 focus: function() { 3360 // Reset focus on first left menu item 3361 $('.media-menu-item').first().focus(); 3348 'keydown': 'constrainTabbing' 3349 }, 3350 3351 focus: function() { // Reset focus on first left menu item 3352 this.$('.media-menu-item').first().focus(); 3362 3353 }, 3363 3354 /** 3364 3355 * @param {Object} event 3365 3356 */ 3366 recordTab: function( event ) { 3357 constrainTabbing: function( event ) { 3358 var tabbables; 3359 3367 3360 // Look for the tab key. 3368 3361 if ( 9 !== event.keyCode ) { … … 3370 3363 } 3371 3364 3365 tabbables = this.$( ':tabbable' ); 3366 3372 3367 // Keep tab focus within media modal while it's open 3373 if ( event.target === this.tabbableLast[0] && !event.shiftKey ) {3374 t his.tabbableFirst.focus();3368 if ( tabbables.last()[0] === event.target && ! event.shiftKey ) { 3369 tabbables.first().focus(); 3375 3370 return false; 3376 } else if ( event.target === this.tabbableFirst[0]&& event.shiftKey ) {3377 t his.tabbableLast.focus();3371 } else if ( tabbables.first()[0] === event.target && event.shiftKey ) { 3372 tabbables.last().focus(); 3378 3373 return false; 3379 3374 } 3380 },3381 /**3382 * @param {Object} event3383 */3384 updateIndex: function() {3385 // Resets tabbable elements3386 this.tabbables = $( ':tabbable', this.$el );3387 this.tabbableFirst = this.tabbables.filter( ':first' );3388 this.tabbableLast = this.tabbables.filter( ':last' );3389 3375 } 3376 3390 3377 }); 3391 3378 … … 6166 6153 // Keep focus inside media modal 6167 6154 // after clear link is selected 6168 new media.view.FocusManager({ 6169 el: this.el 6170 }).focus(); 6155 this.controller.modal.focusManager.focus(); 6171 6156 } 6172 6157 }); … … 6521 6506 // Keep focus inside media modal 6522 6507 // after image is deleted 6523 new media.view.FocusManager({ 6524 el: this.el 6525 }).focus(); 6508 this.controller.modal.focusManager.focus(); 6526 6509 } 6527 6510 },
Note: See TracChangeset
for help on using the changeset viewer.