From 4a96fa19a4dd77c4e578b72a0906b7d95147febe Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Thu, 15 Nov 2012 03:09:35 +0000 Subject: [PATCH] Media: Only show the edit selection link for the media library. Make the upload attachments list sortable. Only retain the `silent` option when running `Attachments.validate()`. see #21390. git-svn-id: https://develop.svn.wordpress.org/trunk@22597 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/js/media-models.js | 5 +++++ wp-includes/js/media-views.js | 21 +++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/wp-includes/js/media-models.js b/wp-includes/js/media-models.js index b7ab0c4573..a50edf4210 100644 --- a/wp-includes/js/media-models.js +++ b/wp-includes/js/media-models.js @@ -358,6 +358,11 @@ window.wp = window.wp || {}; }, validate: function( attachment, options ) { + // Only retain the `silent` option. + options = { + silent: options && options.silent + }; + return this[ this.validator( attachment ) ? 'add' : 'remove' ]( attachment, options ); }, diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index 95f1aa6f76..e5b67d9ca5 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -458,9 +458,10 @@ // --------------------------- media.controller.Upload = media.controller.Library.extend({ defaults: _.defaults({ - id: 'upload', - upload: { text: l10n.uploadMoreFiles }, - searchable: false + id: 'upload', + upload: { text: l10n.uploadMoreFiles }, + searchable: false, + sortable: true }, media.controller.Library.prototype.defaults ), initialize: function() { @@ -471,10 +472,6 @@ // all uploading) attachments. if ( ! library ) { library = new Attachments(); - library.props.set({ - orderby: 'date', - order: 'ASC' - }); library.observe( wp.Uploader.queue ); this.set( 'library', library ); } @@ -995,7 +992,8 @@ // Main states. new media.controller.Library( _.defaults({ selection: options.selection, - library: media.query( options.library ) + library: media.query( options.library ), + editable: true }, main ) ), new media.controller.Upload( main ), @@ -1256,7 +1254,8 @@ // Toolbars mainAttachmentsToolbar: function() { this.toolbar.view( new media.view.Toolbar.Insert({ - controller: this + controller: this, + editable: this.state().get('editable') }) ); }, @@ -1770,7 +1769,9 @@ collection: selection, priority: -40, - editable: function() { + // If the selection is editable, pass the callback to + // switch the content mode. + editable: this.options.editable && function() { this.controller.content.mode('edit-selection'); } }).render(),