Media: Allow all galleries to be sortable. fixes #22488, see #21390.

git-svn-id: http://core.svn.wordpress.org/trunk@22713 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Daryl Koopersmith 2012-11-20 14:04:59 +00:00
parent 6fb316b1fb
commit e25565f4b7
2 changed files with 19 additions and 0 deletions

View File

@ -320,6 +320,15 @@ var tb_position;
selection.gallery = attachments.gallery;
// Fetch the query's attachments, and then break ties from the
// query to allow for sorting.
selection.more().done( function() {
// Break ties with the query.
selection.props.set({ query: false });
selection.unmirror();
selection.props.unset('orderby');
});
return wp.media({
frame: 'post',
state: 'gallery-edit',

View File

@ -2540,6 +2540,7 @@
this.scroll = _.chain( this.scroll ).bind( this ).throttle( this.options.refreshSensitivity ).value();
this.initSortable();
this.collection.props.on( 'change:orderby', this.refreshSortable, this );
_.bindAll( this, 'css' );
this.model.on( 'change:edge change:gutter', this.css, this );
@ -2549,6 +2550,7 @@
},
destroy: function() {
this.collection.props.off( null, null, this );
this.collection.off( 'add remove reset', null, this );
this.model.off( 'change:edge change:gutter', this.css, this );
$(window).off( 'resize.attachments', this._resizeCss );
@ -2628,6 +2630,14 @@
}, this );
},
refreshSortable: function() {
if ( ! this.options.sortable || ! $.fn.sortable )
return;
// If the `collection` has a `comparator`, disable sorting.
this.$el.sortable( 'option', 'disabled', !! this.collection.comparator );
},
render: function() {
// If there are no elements, load some.
if ( ! this.collection.length ) {