Media: In the main media library in the insert media dialog, only show attachment display settings when one attachment is selected. see #21390.

git-svn-id: http://core.svn.wordpress.org/trunk@22482 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Daryl Koopersmith 2012-11-09 02:11:37 +00:00
parent 56c1b7c7ff
commit dd504180f7
1 changed files with 20 additions and 7 deletions

View File

@ -302,7 +302,7 @@
wp.Uploader.queue.on( 'add', this.selectUpload, this ); wp.Uploader.queue.on( 'add', this.selectUpload, this );
selection.on( 'selection:single selection:unsingle', this.sidebar, this ); selection.on( 'selection:single selection:unsingle', this.sidebar, this );
selection.on( 'add remove reset', this.refreshToolbar, this ); selection.on( 'add remove reset', this.refreshSelection, this );
this._updateEmpty(); this._updateEmpty();
this.get('library').on( 'add remove reset', this._updateEmpty, this ); this.get('library').on( 'add remove reset', this._updateEmpty, this );
@ -363,8 +363,9 @@
this.set( 'empty', ! library.length && ! library.props.get('search') ); this.set( 'empty', ! library.length && ! library.props.get('search') );
}, },
refreshToolbar: function() { refreshSelection: function() {
this.frame.toolbar.view().refresh(); this.frame.toolbar.view().refresh();
this.trigger( 'refresh:selection', this, this.get('selection') );
}, },
selectUpload: function( attachment ) { selectUpload: function( attachment ) {
@ -643,9 +644,12 @@
editing: false editing: false
}); });
this.bindHandlers();
this.createSelection(); this.createSelection();
this.createStates(); this.createStates();
this.bindHandlers();
// Set the default state.
this.state( this.options.state );
}, },
bindHandlers: function() { bindHandlers: function() {
@ -684,6 +688,19 @@
}, this ); }, this );
}, this ); }, this );
_.each(['library', 'upload'], function( id ) {
this.get( id ).on( 'refresh:selection', function( state, selection ) {
var sidebar = this.sidebar;
if ( ! selection.length )
sidebar.mode('clear');
else if ( selection.length === 1 )
sidebar.mode('attachment-settings');
else
sidebar.mode('settings');
}, this );
}, this );
this.sidebar.on( 'gallery-settings', this.onSidebarGallerySettings, this ); this.sidebar.on( 'gallery-settings', this.onSidebarGallerySettings, this );
}, },
@ -705,7 +722,6 @@
main = { main = {
multiple: this.options.multiple, multiple: this.options.multiple,
menu: 'main', menu: 'main',
sidebar: 'attachment-settings',
// Update user settings when users adjust the // Update user settings when users adjust the
// attachment display settings. // attachment display settings.
@ -772,9 +788,6 @@
id: 'batch-upload' id: 'batch-upload'
}, batch ) ) }, batch ) )
]); ]);
// Set the default state.
this.state( options.state );
}, },
// Menus // Menus