X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/4feeb71a9d812a9ae371c28a3d8b442a4394ded7..refs/tags/wordpress-4.7-scripts:/wp-includes/js/media-views.js?ds=sidebyside diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index 60f9b936..b421158f 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -3588,7 +3588,7 @@ Attachments = View.extend({ initSortable: function() { var collection = this.collection; - if ( wp.media.isTouchDevice || ! this.options.sortable || ! $.fn.sortable ) { + if ( ! this.options.sortable || ! $.fn.sortable ) { return; } @@ -3647,7 +3647,7 @@ Attachments = View.extend({ }, refreshSortable: function() { - if ( wp.media.isTouchDevice || ! this.options.sortable || ! $.fn.sortable ) { + if ( ! this.options.sortable || ! $.fn.sortable ) { return; } @@ -3772,11 +3772,11 @@ AttachmentsBrowser = View.extend({ this.controller.on( 'toggle:upload:attachment', this.toggleUploader, this ); this.controller.on( 'edit:selection', this.editSelection ); this.createToolbar(); + this.createUploader(); + this.createAttachments(); if ( this.options.sidebar ) { this.createSidebar(); } - this.createUploader(); - this.createAttachments(); this.updateContent(); if ( ! this.options.sidebar || 'errors' === this.options.sidebar ) { @@ -6698,6 +6698,8 @@ Modal = wp.media.View.extend({ 'keydown': 'keydown' }, + clickedOpenerEl: null, + initialize: function() { _.defaults( this.options, { container: document.body, @@ -6765,6 +6767,8 @@ Modal = wp.media.View.extend({ return this; } + this.clickedOpenerEl = document.activeElement; + if ( ! this.views.attached ) { this.attach(); } @@ -6815,8 +6819,12 @@ Modal = wp.media.View.extend({ // Hide modal and remove restricted media modal tab focus once it's closed this.$el.hide().undelegate( 'keydown' ); - // Put focus back in useful location once modal is closed - $('#wpbody-content').focus(); + // Put focus back in useful location once modal is closed. + if ( null !== this.clickedOpenerEl ) { + this.clickedOpenerEl.focus(); + } else { + $( '#wpbody-content' ).focus(); + } this.propagate('close'); @@ -7061,7 +7069,7 @@ Search = wp.media.View.extend({ attributes: { type: 'search', - placeholder: l10n.search + placeholder: l10n.searchMediaPlaceholder }, events: {