Ticket #43169: 43169.diff
File 43169.diff, 27.7 KB (added by , 7 years ago) |
---|
-
src/wp-admin/css/media.css
697 697 content: "\f345"; 698 698 } 699 699 700 .edit-attachment-frame .edit-media-header .left.disabled, 701 .edit-attachment-frame .edit-media-header .right.disabled, 702 .edit-attachment-frame .edit-media-header .left.disabled:hover, 703 .edit-attachment-frame .edit-media-header .right.disabled:hover { 700 .edit-attachment-frame .edit-media-header [disabled], 701 .edit-attachment-frame .edit-media-header [disabled]:hover { 704 702 color: #ccc; 705 703 background: inherit; 706 704 cursor: default; 707 pointer-events: none;708 705 } 709 706 710 707 .edit-attachment-frame .media-frame-content, -
src/wp-includes/js/media/views/attachment/details.js
42 42 rerenderOnModelChange: false 43 43 }); 44 44 45 this.on( 'ready', this.initialFocus );46 45 // Call 'initialize' directly on the parent class. 47 46 Attachment.prototype.initialize.apply( this, arguments ); 48 47 }, 49 48 50 initialFocus: function() { 51 if ( ! wp.media.isTouchDevice ) { 52 /* 53 Previously focused the first ':input' (the readonly URL text field). 54 Since the first ':input' is now a button (delete/trash): when pressing 55 spacebar on an attachment, Firefox fires deleteAttachment/trashAttachment 56 as soon as focus is moved. Explicitly target the first text field for now. 57 @todo change initial focus logic, also for accessibility. 58 */ 59 this.$( 'input[type="text"]' ).eq( 0 ).focus(); 49 /** 50 * Get the previous and next attachments of the edited attachment. 51 * 52 * @since 5.0.0 53 */ 54 getPreviousNextAttachments: function() { 55 var editedAttachment = $( 'li[data-id="' + this.model.id + '"]' ); 56 this.previousAttachment = editedAttachment.prev(); 57 this.nextAttachment = editedAttachment.next();; 58 }, 59 60 /** 61 * Move focus to the previous attachment in the grid, or to the next 62 * one if the deleted attachment was the first one. Fallbacks to the grid 63 * list when there are no attachments. 64 * 65 * @since 5.0.0 66 */ 67 focusAttachment: function() { 68 if ( this.previousAttachment.length ) { 69 this.previousAttachment.focus(); 70 } else if ( this.nextAttachment.length ) { 71 this.nextAttachment.focus(); 72 } else { 73 $( '.attachments-browser' ).find( '.attachments' ).focus(); 60 74 } 61 75 }, 62 76 /** … … 65 79 deleteAttachment: function( event ) { 66 80 event.preventDefault(); 67 81 82 this.getPreviousNextAttachments(); 83 68 84 if ( window.confirm( l10n.warnDelete ) ) { 69 85 this.model.destroy(); 70 // Keep focus inside media modal 71 // after image is deleted 72 this.controller.modal.focusManager.focus(); 86 this.focusAttachment(); 73 87 } 74 88 }, 75 89 /** … … 79 93 var library = this.controller.library; 80 94 event.preventDefault(); 81 95 96 this.getPreviousNextAttachments(); 97 98 // When in the Media Library. 82 99 if ( wp.media.view.settings.mediaTrash && 83 100 'edit-metadata' === this.controller.content.mode() ) { 84 101 … … 85 102 this.model.set( 'status', 'trash' ); 86 103 this.model.save().done( function() { 87 104 library._requery( true ); 105 /* 106 * @todo we need to move focus back to the previous, next, or first 107 * attachment but the librady gets re-queried and refreshed. Thus, 108 * the references to the previous elements are lost, we need an 109 * alternate method. Note: `this` is different within this callback. 110 */ 88 111 } ); 89 112 } else { 90 113 this.model.destroy(); 114 this.focusAttachment(); 91 115 } 92 116 }, 93 117 /** -
src/wp-includes/js/media/views/attachments/browser.js
83 83 }, 84 84 85 85 editSelection: function( modal ) { 86 // When editing a selection, move focus to the "Return to library" button. 86 87 modal.$( '.media-button-backToLibrary' ).focus(); 87 88 }, 88 89 -
src/wp-includes/js/media/views/attachments.js
82 82 83 83 this.collection.on( 'reset', this.render, this ); 84 84 85 this. listenTo( this.controller, 'library:selection:add', this.attachmentFocus );85 this.controller.on( 'library:selection:add', this.attachmentFocus, this ); 86 86 87 87 // Throttle the scroll handler and bind this. 88 88 this.scroll = _.chain( this.scroll ).bind( this ).throttle( this.options.refreshSensitivity ).value(); … … 130 130 * @returns {void} 131 131 */ 132 132 attachmentFocus: function() { 133 this.$( 'li:first' ).focus(); 133 /* 134 * @todo when uploading new attachments, this tries to move focus to the 135 * first attachment in the grid. Actually, a progress bar gets initially 136 * displayed and then updated when uploading completes, so focus is lost. 137 * Additionally: this view is used for both the attachments list and the 138 * list of selected attachments in the bottom media toolbar. Thus, when 139 * uploading attachments, it runs twice returning two different `this`. 140 * To evaluate: move focus to the attachments list instead? 141 */ 142 if ( this.columns ) { 143 // Experimental: move focus to the grid list. 144 this.$el.focus(); 145 } 134 146 }, 135 147 136 148 /** 137 149 * Restores focus to the selected item in the collection. 138 150 * 151 * Moves focus back to the first selected attachment in the grid. Used when 152 * tabbing backwards from the attachment details sidebar. 153 * 139 154 * @since 4.0.0 140 155 * 141 156 * @returns {void} -
src/wp-includes/js/media/views/edit-image.js
26 26 }, 27 27 28 28 loadEditor: function() { 29 var dfd = this.editor.open( this.model.get('id'), this.model.get('nonces').edit, this ); 30 dfd.done( _.bind( this.focus, this ) ); 29 this.editor.open( this.model.get('id'), this.model.get('nonces').edit, this ); 31 30 }, 32 31 33 focus: function() {34 this.$( '.imgedit-submit .button' ).eq( 0 ).focus();35 },36 37 32 back: function() { 38 33 var lastState = this.controller.lastState(); 39 34 this.controller.setState( lastState ); -
src/wp-includes/js/media/views/embed/url.js
55 55 return this; 56 56 }, 57 57 58 ready: function() {59 if ( ! wp.media.isTouchDevice ) {60 this.focus();61 }62 },63 64 58 url: function( event ) { 65 59 this.model.set( 'url', $.trim( event.target.value ) ); 66 },67 68 /**69 * If the input is visible, focus and select its contents.70 */71 focus: function() {72 var $input = this.$input;73 if ( $input.is(':visible') ) {74 $input.focus()[0].select();75 }76 60 } 77 61 }); 78 62 -
src/wp-includes/js/media/views/focus-manager.js
14 14 'keydown': 'constrainTabbing' 15 15 }, 16 16 17 focus: function() { // Reset focus on first left menu item 17 /** 18 * Move focus to the first item in the modal menu. 19 */ 20 focus: function() { 18 21 this.$('.media-menu-item').first().focus(); 19 22 }, 20 23 /** -
src/wp-includes/js/media/views/frame/edit-attachments.js
91 91 // Completely destroy the modal DOM element when closing it. 92 92 this.modal.on( 'close', _.bind( function() { 93 93 $( 'body' ).off( 'keydown.media-modal' ); /* remove the keydown event */ 94 // Restore the original focus item if possible94 // Move focus back to the original item in the grid if possible. 95 95 $( 'li.attachment[data-id="' + this.model.get( 'id' ) +'"]' ).focus(); 96 96 this.resetRoute(); 97 97 }, this ) ); … … 172 172 }, 173 173 174 174 toggleNav: function() { 175 this.$( '.left').toggleClass( 'disabled', ! this.hasPrevious() );176 this.$( '.right').toggleClass( 'disabled', ! this.hasNext() );175 this.$( '.left' ).prop( 'disabled', ! this.hasPrevious() ); 176 this.$( '.right' ).prop( 'disabled', ! this.hasNext() ); 177 177 }, 178 178 179 179 /** … … 200 200 * Click handler to switch to the previous media item. 201 201 */ 202 202 previousMediaItem: function() { 203 var which = ''; 204 203 205 if ( ! this.hasPrevious() ) { 204 206 return; 205 207 } 206 208 this.trigger( 'refresh', this.library.at( this.getCurrentIndex() - 1 ) ); 207 this.$( '.left' ).focus(); 209 // When there are no previous items, the left button is disabled. 210 this.focusNavButton( which = this.hasPrevious() ? '.left' : '.right' ); 208 211 }, 209 212 210 213 /** … … 211 214 * Click handler to switch to the next media item. 212 215 */ 213 216 nextMediaItem: function() { 217 var which = ''; 218 214 219 if ( ! this.hasNext() ) { 215 220 return; 216 221 } 217 222 this.trigger( 'refresh', this.library.at( this.getCurrentIndex() + 1 ) ); 218 this.$( '.right' ).focus(); 223 // When there are no next items, the right button is disabled. 224 this.focusNavButton( which = this.hasNext() ? '.right' : '.left' ); 219 225 }, 220 226 227 /** 228 * Set focus to the navigation buttons depending on the browsing direction. 229 * 230 * @param {string} which A CSS selector to target the button to focus. 231 */ 232 focusNavButton: function( which ) { 233 this.$( which ).focus(); 234 }, 235 221 236 getCurrentIndex: function() { 222 237 return this.library.indexOf( this.model ); 223 238 }, -
src/wp-includes/js/media/views/frame/post.js
290 290 frame.close(); 291 291 } 292 292 293 // Keep focus inside media modal 294 // after canceling a gallery 293 // Move focus to the modal first left menu item. 295 294 this.controller.modal.focusManager.focus(); 296 295 } 297 296 }, … … 358 357 }).render(); 359 358 360 359 this.content.set( view ); 361 362 if ( ! wp.media.isTouchDevice ) {363 view.url.focus();364 }365 360 }, 366 361 367 362 editSelectionContent: function() { … … 483 478 multiple: true 484 479 }) ); 485 480 486 this.controller.setState('gallery-edit'); 481 // Jump to gallery edit view. 482 this.controller.setState( 'gallery-edit' ); 487 483 488 // Keep focus inside media modal 489 // after jumping to gallery view 484 // Move focus to the modal first left menu item. 490 485 this.controller.modal.focusManager.focus(); 491 486 } 492 487 }); … … 513 508 multiple: true 514 509 }) ); 515 510 516 this.controller.setState('playlist-edit'); 511 // Jump to audio playlist edit view. 512 this.controller.setState( 'playlist-edit' ); 517 513 518 // Keep focus inside media modal 519 // after jumping to playlist view 514 // Move focus to the modal first left menu item. 520 515 this.controller.modal.focusManager.focus(); 521 516 } 522 517 }); … … 543 538 multiple: true 544 539 }) ); 545 540 546 this.controller.setState('video-playlist-edit'); 541 // Jump to video playlist edit view. 542 this.controller.setState( 'video-playlist-edit' ); 547 543 548 // Keep focus inside media modal 549 // after jumping to video playlist view 544 // Move focus to the modal first left menu item. 550 545 this.controller.modal.focusManager.focus(); 551 546 } 552 547 }); -
src/wp-includes/js/media/views/image-details.js
71 71 }, 72 72 73 73 postRender: function() { 74 setTimeout( _.bind( this. resetFocus, this ), 10 );74 setTimeout( _.bind( this.scrollToTop, this ), 10 ); 75 75 this.toggleLinkSettings(); 76 76 if ( window.getUserSetting( 'advImgDetails' ) === 'show' ) { 77 77 this.toggleAdvanced( true ); … … 79 79 this.trigger( 'post-render' ); 80 80 }, 81 81 82 resetFocus: function() { 83 this.$( '.link-to-custom' ).blur(); 82 scrollToTop: function() { 84 83 this.$( '.embed-media-settings' ).scrollTop( 0 ); 85 84 }, 86 85 -
src/wp-includes/js/media/views/media-details.js
129 129 AttachmentDisplay.prototype.render.apply( this, arguments ); 130 130 131 131 setTimeout( _.bind( function() { 132 this. resetFocus();132 this.scrollToTop(); 133 133 }, this ), 10 ); 134 134 135 135 this.settings = _.defaults( { … … 139 139 return this.setMedia(); 140 140 }, 141 141 142 resetFocus: function() {142 scrollToTop: function() { 143 143 this.$( '.embed-media-settings' ).scrollTop( 0 ); 144 144 } 145 145 },/** @lends wp.media.view.MediaDetails */{ -
src/wp-includes/js/media/views/menu-item.js
1 var $ = jQuery, 2 MenuItem; 1 var MenuItem; 3 2 4 3 /** 5 4 * wp.media.view.MenuItem … … 37 36 } else { 38 37 this.click(); 39 38 } 40 41 // When selecting a tab along the left side,42 // focus should be transferred into the main panel43 if ( ! wp.media.isTouchDevice ) {44 $('.media-frame-content input').first().focus();45 }46 39 }, 47 40 48 41 click: function() { -
src/wp-includes/js/media/views/modal.js
125 125 } 126 126 } 127 127 128 // Set initial focus on the media modal. 128 129 this.$el.focus(); 129 130 130 131 return this.propagate('open'); -
src/wp-includes/js/media/views/selection.js
74 74 event.preventDefault(); 75 75 this.collection.reset(); 76 76 77 // Keep focus inside media modal 78 // after clear link is selected 77 // Move focus to the modal first left menu item. 79 78 this.controller.modal.focusManager.focus(); 80 79 } 81 80 }); -
src/wp-includes/js/media/views/settings/attachment-display.js
83 83 } 84 84 85 85 $input.removeClass( 'hidden' ); 86 87 // If the input is visible, focus and select its contents.88 if ( ! wp.media.isTouchDevice && $input.is(':visible') ) {89 $input.focus()[0].select();90 }91 86 } 92 87 }); 93 88 -
src/wp-includes/js/media-audiovideo.js
969 969 AttachmentDisplay.prototype.render.apply( this, arguments ); 970 970 971 971 setTimeout( _.bind( function() { 972 this. resetFocus();972 this.scrollToTop(); 973 973 }, this ), 10 ); 974 974 975 975 this.settings = _.defaults( { … … 979 979 return this.setMedia(); 980 980 }, 981 981 982 resetFocus: function() {982 scrollToTop: function() { 983 983 this.$( '.embed-media-settings' ).scrollTop( 0 ); 984 984 } 985 985 },/** @lends wp.media.view.MediaDetails */{ -
src/wp-includes/js/media-grid.js
685 685 // Completely destroy the modal DOM element when closing it. 686 686 this.modal.on( 'close', _.bind( function() { 687 687 $( 'body' ).off( 'keydown.media-modal' ); /* remove the keydown event */ 688 // Restore the original focus item if possible688 // Move focus back to the original item in the grid if possible. 689 689 $( 'li.attachment[data-id="' + this.model.get( 'id' ) +'"]' ).focus(); 690 690 this.resetRoute(); 691 691 }, this ) ); … … 766 766 }, 767 767 768 768 toggleNav: function() { 769 this.$( '.left').toggleClass( 'disabled', ! this.hasPrevious() );770 this.$( '.right').toggleClass( 'disabled', ! this.hasNext() );769 this.$( '.left' ).prop( 'disabled', ! this.hasPrevious() ); 770 this.$( '.right' ).prop( 'disabled', ! this.hasNext() ); 771 771 }, 772 772 773 773 /** … … 794 794 * Click handler to switch to the previous media item. 795 795 */ 796 796 previousMediaItem: function() { 797 var which = ''; 798 797 799 if ( ! this.hasPrevious() ) { 798 800 return; 799 801 } 800 802 this.trigger( 'refresh', this.library.at( this.getCurrentIndex() - 1 ) ); 801 this.$( '.left' ).focus(); 803 // When there are no previous items, the left button is disabled. 804 this.focusNavButton( which = this.hasPrevious() ? '.left' : '.right' ); 802 805 }, 803 806 804 807 /** … … 805 808 * Click handler to switch to the next media item. 806 809 */ 807 810 nextMediaItem: function() { 811 var which = ''; 812 808 813 if ( ! this.hasNext() ) { 809 814 return; 810 815 } 811 816 this.trigger( 'refresh', this.library.at( this.getCurrentIndex() + 1 ) ); 812 this.$( '.right' ).focus(); 817 // When there are no next items, the right button is disabled. 818 this.focusNavButton( which = this.hasNext() ? '.right' : '.left' ); 813 819 }, 814 820 821 /** 822 * Set focus to the navigation buttons depending on the browsing direction. 823 * 824 * @param {string} which A CSS selector to target the button to focus. 825 */ 826 focusNavButton: function( which ) { 827 this.$( which ).focus(); 828 }, 829 815 830 getCurrentIndex: function() { 816 831 return this.library.indexOf( this.model ); 817 832 }, -
src/wp-includes/js/media-views.js
3594 3594 frame.close(); 3595 3595 } 3596 3596 3597 // Keep focus inside media modal 3598 // after canceling a gallery 3597 // Move focus to the modal first left menu item. 3599 3598 this.controller.modal.focusManager.focus(); 3600 3599 } 3601 3600 }, … … 3662 3661 }).render(); 3663 3662 3664 3663 this.content.set( view ); 3665 3666 if ( ! wp.media.isTouchDevice ) {3667 view.url.focus();3668 }3669 3664 }, 3670 3665 3671 3666 editSelectionContent: function() { … … 3787 3782 multiple: true 3788 3783 }) ); 3789 3784 3790 this.controller.setState('gallery-edit'); 3785 // Jump to gallery edit view. 3786 this.controller.setState( 'gallery-edit' ); 3791 3787 3792 // Keep focus inside media modal 3793 // after jumping to gallery view 3788 // Move focus to the modal first left menu item. 3794 3789 this.controller.modal.focusManager.focus(); 3795 3790 } 3796 3791 }); … … 3817 3812 multiple: true 3818 3813 }) ); 3819 3814 3820 this.controller.setState('playlist-edit'); 3815 // Jump to audio playlist edit view. 3816 this.controller.setState( 'playlist-edit' ); 3821 3817 3822 // Keep focus inside media modal 3823 // after jumping to playlist view 3818 // Move focus to the modal first left menu item. 3824 3819 this.controller.modal.focusManager.focus(); 3825 3820 } 3826 3821 }); … … 3847 3842 multiple: true 3848 3843 }) ); 3849 3844 3850 this.controller.setState('video-playlist-edit'); 3845 // Jump to video playlist edit view. 3846 this.controller.setState( 'video-playlist-edit' ); 3851 3847 3852 // Keep focus inside media modal 3853 // after jumping to video playlist view 3848 // Move focus to the modal first left menu item. 3854 3849 this.controller.modal.focusManager.focus(); 3855 3850 } 3856 3851 }); … … 4356 4351 } 4357 4352 } 4358 4353 4354 // Set initial focus on the media modal. 4359 4355 this.$el.focus(); 4360 4356 4361 4357 return this.propagate('open'); … … 4472 4468 'keydown': 'constrainTabbing' 4473 4469 }, 4474 4470 4475 focus: function() { // Reset focus on first left menu item 4471 /** 4472 * Move focus to the first item in the modal menu. 4473 */ 4474 focus: function() { 4476 4475 this.$('.media-menu-item').first().focus(); 4477 4476 }, 4478 4477 /** … … 5699 5698 /* 64 */ 5700 5699 /***/ (function(module, exports) { 5701 5700 5702 var $ = jQuery, 5703 MenuItem; 5701 var MenuItem; 5704 5702 5705 5703 /** 5706 5704 * wp.media.view.MenuItem … … 5738 5736 } else { 5739 5737 this.click(); 5740 5738 } 5741 5742 // When selecting a tab along the left side,5743 // focus should be transferred into the main panel5744 if ( ! wp.media.isTouchDevice ) {5745 $('.media-frame-content input').first().focus();5746 }5747 5739 }, 5748 5740 5749 5741 click: function() { … … 6710 6702 6711 6703 this.collection.on( 'reset', this.render, this ); 6712 6704 6713 this. listenTo( this.controller, 'library:selection:add', this.attachmentFocus );6705 this.controller.on( 'library:selection:add', this.attachmentFocus, this ); 6714 6706 6715 6707 // Throttle the scroll handler and bind this. 6716 6708 this.scroll = _.chain( this.scroll ).bind( this ).throttle( this.options.refreshSensitivity ).value(); … … 6758 6750 * @returns {void} 6759 6751 */ 6760 6752 attachmentFocus: function() { 6761 this.$( 'li:first' ).focus(); 6753 /* 6754 * @todo when uploading new attachments, this tries to move focus to the 6755 * first attachment in the grid. Actually, a progress bar gets initially 6756 * displayed and then updated when uploading completes, so focus is lost. 6757 * Additionally: this view is used for both the attachments list and the 6758 * list of selected attachments in the bottom media toolbar. Thus, when 6759 * uploading attachments, it runs twice returning two different `this`. 6760 * To evaluate: move focus to the attachments list instead? 6761 */ 6762 if ( this.columns ) { 6763 // Experimental: move focus to the grid list. 6764 this.$el.focus(); 6765 } 6762 6766 }, 6763 6767 6764 6768 /** 6765 6769 * Restores focus to the selected item in the collection. 6766 6770 * 6771 * Moves focus back to the first selected attachment in the grid. Used when 6772 * tabbing backwards from the attachment details sidebar. 6773 * 6767 6774 * @since 4.0.0 6768 6775 * 6769 6776 * @returns {void} … … 7495 7502 }, 7496 7503 7497 7504 editSelection: function( modal ) { 7505 // When editing a selection, move focus to the "Return to library" button. 7498 7506 modal.$( '.media-button-backToLibrary' ).focus(); 7499 7507 }, 7500 7508 … … 7968 7976 event.preventDefault(); 7969 7977 this.collection.reset(); 7970 7978 7971 // Keep focus inside media modal 7972 // after clear link is selected 7979 // Move focus to the modal first left menu item. 7973 7980 this.controller.modal.focusManager.focus(); 7974 7981 } 7975 7982 }); … … 8282 8289 } 8283 8290 8284 8291 $input.removeClass( 'hidden' ); 8285 8286 // If the input is visible, focus and select its contents.8287 if ( ! wp.media.isTouchDevice && $input.is(':visible') ) {8288 $input.focus()[0].select();8289 }8290 8292 } 8291 8293 }); 8292 8294 … … 8387 8389 rerenderOnModelChange: false 8388 8390 }); 8389 8391 8390 this.on( 'ready', this.initialFocus );8391 8392 // Call 'initialize' directly on the parent class. 8392 8393 Attachment.prototype.initialize.apply( this, arguments ); 8393 8394 }, 8394 8395 8395 initialFocus: function() { 8396 if ( ! wp.media.isTouchDevice ) { 8397 /* 8398 Previously focused the first ':input' (the readonly URL text field). 8399 Since the first ':input' is now a button (delete/trash): when pressing 8400 spacebar on an attachment, Firefox fires deleteAttachment/trashAttachment 8401 as soon as focus is moved. Explicitly target the first text field for now. 8402 @todo change initial focus logic, also for accessibility. 8403 */ 8404 this.$( 'input[type="text"]' ).eq( 0 ).focus(); 8396 /** 8397 * Get the previous and next attachments of the edited attachment. 8398 * 8399 * @since 5.0.0 8400 */ 8401 getPreviousNextAttachments: function() { 8402 var editedAttachment = $( 'li[data-id="' + this.model.id + '"]' ); 8403 this.previousAttachment = editedAttachment.prev(); 8404 this.nextAttachment = editedAttachment.next();; 8405 }, 8406 8407 /** 8408 * Move focus to the previous attachment in the grid, or to the next 8409 * one if the deleted attachment was the first one. Fallbacks to the grid 8410 * list when there are no attachments. 8411 * 8412 * @since 5.0.0 8413 */ 8414 focusAttachment: function() { 8415 if ( this.previousAttachment.length ) { 8416 this.previousAttachment.focus(); 8417 } else if ( this.nextAttachment.length ) { 8418 this.nextAttachment.focus(); 8419 } else { 8420 $( '.attachments-browser' ).find( '.attachments' ).focus(); 8405 8421 } 8406 8422 }, 8407 8423 /** … … 8410 8426 deleteAttachment: function( event ) { 8411 8427 event.preventDefault(); 8412 8428 8429 this.getPreviousNextAttachments(); 8430 8413 8431 if ( window.confirm( l10n.warnDelete ) ) { 8414 8432 this.model.destroy(); 8415 // Keep focus inside media modal 8416 // after image is deleted 8417 this.controller.modal.focusManager.focus(); 8433 this.focusAttachment(); 8418 8434 } 8419 8435 }, 8420 8436 /** … … 8424 8440 var library = this.controller.library; 8425 8441 event.preventDefault(); 8426 8442 8443 this.getPreviousNextAttachments(); 8444 8445 // When in the Media Library. 8427 8446 if ( wp.media.view.settings.mediaTrash && 8428 8447 'edit-metadata' === this.controller.content.mode() ) { 8429 8448 … … 8430 8449 this.model.set( 'status', 'trash' ); 8431 8450 this.model.save().done( function() { 8432 8451 library._requery( true ); 8452 /* 8453 * @todo we need to move focus back to the previous, next, or first 8454 * attachment but the librady gets re-queried and refreshed. Thus, 8455 * the references to the previous elements are lost, we need an 8456 * alternate method. Note: `this` is different within this callback. 8457 */ 8433 8458 } ); 8434 8459 } else { 8435 8460 this.model.destroy(); 8461 this.focusAttachment(); 8436 8462 } 8437 8463 }, 8438 8464 /** … … 8767 8793 return this; 8768 8794 }, 8769 8795 8770 ready: function() {8771 if ( ! wp.media.isTouchDevice ) {8772 this.focus();8773 }8774 },8775 8776 8796 url: function( event ) { 8777 8797 this.model.set( 'url', $.trim( event.target.value ) ); 8778 },8779 8780 /**8781 * If the input is visible, focus and select its contents.8782 */8783 focus: function() {8784 var $input = this.$input;8785 if ( $input.is(':visible') ) {8786 $input.focus()[0].select();8787 }8788 8798 } 8789 8799 }); 8790 8800 … … 9010 9020 }, 9011 9021 9012 9022 postRender: function() { 9013 setTimeout( _.bind( this. resetFocus, this ), 10 );9023 setTimeout( _.bind( this.scrollToTop, this ), 10 ); 9014 9024 this.toggleLinkSettings(); 9015 9025 if ( window.getUserSetting( 'advImgDetails' ) === 'show' ) { 9016 9026 this.toggleAdvanced( true ); … … 9018 9028 this.trigger( 'post-render' ); 9019 9029 }, 9020 9030 9021 resetFocus: function() { 9022 this.$( '.link-to-custom' ).blur(); 9031 scrollToTop: function() { 9023 9032 this.$( '.embed-media-settings' ).scrollTop( 0 ); 9024 9033 }, 9025 9034 … … 9351 9360 }, 9352 9361 9353 9362 loadEditor: function() { 9354 var dfd = this.editor.open( this.model.get('id'), this.model.get('nonces').edit, this ); 9355 dfd.done( _.bind( this.focus, this ) ); 9363 this.editor.open( this.model.get('id'), this.model.get('nonces').edit, this ); 9356 9364 }, 9357 9365 9358 focus: function() {9359 this.$( '.imgedit-submit .button' ).eq( 0 ).focus();9360 },9361 9362 9366 back: function() { 9363 9367 var lastState = this.controller.lastState(); 9364 9368 this.controller.setState( lastState ); -
src/wp-includes/media-template.php
305 305 306 306 <script type="text/html" id="tmpl-edit-attachment-frame"> 307 307 <div class="edit-media-header"> 308 <button class="left dashicons <# if ( ! data.hasPrevious ) { #> disabled <# } #>"><span class="screen-reader-text"><?php _e( 'Edit previous media item' ); ?></span></button>309 <button class="right dashicons <# if ( ! data.hasNext ) { #> disabled <# } #>"><span class="screen-reader-text"><?php _e( 'Edit next media item' ); ?></span></button>308 <button class="left dashicons"<# if ( ! data.hasPrevious ) { #> disabled<# } #>><span class="screen-reader-text"><?php _e( 'Edit previous media item' ); ?></span></button> 309 <button class="right dashicons"<# if ( ! data.hasNext ) { #> disabled<# } #>><span class="screen-reader-text"><?php _e( 'Edit next media item' ); ?></span></button> 310 310 </div> 311 311 <div class="media-frame-title"></div> 312 312 <div class="media-frame-content"></div>