* @since 3.9.0
*/
activate: function() {
- this.listenTo( this.frame, 'toolbar:render:edit-image', this.toolbar );
+ this.frame.on( 'toolbar:render:edit-image', _.bind( this.toolbar, this ) );
},
/**
* @since 3.9.0
*/
deactivate: function() {
- this.stopListening( this.frame );
+ this.frame.off( 'toolbar:render:edit-image' );
},
/**
initSortable: function() {
var collection = this.collection;
- if ( wp.media.isTouchDevice || ! this.options.sortable || ! $.fn.sortable ) {
+ if ( ! this.options.sortable || ! $.fn.sortable ) {
return;
}
},
refreshSortable: function() {
- if ( wp.media.isTouchDevice || ! this.options.sortable || ! $.fn.sortable ) {
+ if ( ! this.options.sortable || ! $.fn.sortable ) {
return;
}
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 ) {
});
// Add keydown listener to the instance of the Attachments view
- this.attachments.listenTo( this.controller, 'attachment:keydown:arrow', this.attachments.arrowEvent );
- this.attachments.listenTo( this.controller, 'attachment:details:shift-tab', this.attachments.restoreFocus );
+ this.controller.on( 'attachment:keydown:arrow', _.bind( this.attachments.arrowEvent, this.attachments ) );
+ this.controller.on( 'attachment:details:shift-tab', _.bind( this.attachments.restoreFocus, this.attachments ) );
this.views.add( this.attachments );
'keydown': 'keydown'
},
+ clickedOpenerEl: null,
+
initialize: function() {
_.defaults( this.options, {
container: document.body,
return this;
}
+ this.clickedOpenerEl = document.activeElement;
+
if ( ! this.views.attached ) {
this.attach();
}
// 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');
attributes: {
type: 'search',
- placeholder: l10n.search
+ placeholder: l10n.searchMediaPlaceholder
},
events: {