Media: Don't add menu_order to newly uploaded attachments, to match 3.4 behavior. Reverts a bit of [22967]. props koopersmith. fixes #22607.

git-svn-id: http://core.svn.wordpress.org/trunk@22985 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2012-12-03 04:54:03 +00:00
parent b382901778
commit 6d711428b4

View File

@ -2813,8 +2813,7 @@
}, },
initSortable: function() { initSortable: function() {
var view = this, var collection = this.collection,
collection = this.collection,
from; from;
if ( ! this.options.sortable || ! $.fn.sortable ) if ( ! this.options.sortable || ! $.fn.sortable )
@ -2860,10 +2859,7 @@
// If the collection is sorted by menu order, // If the collection is sorted by menu order,
// update the menu order. // update the menu order.
view.saveMenuOrder(); collection.saveMenuOrder();
// Make sure any menu-order-related callbacks are bound.
view.refreshSortable();
} }
}); });
@ -2884,27 +2880,9 @@
// If the `collection` has a `comparator`, disable sorting. // If the `collection` has a `comparator`, disable sorting.
var collection = this.collection, var collection = this.collection,
orderby = collection.props.get('orderby'), orderby = collection.props.get('orderby'),
enabled = 'menuOrder' === orderby || ! collection.comparator, enabled = 'menuOrder' === orderby || ! collection.comparator;
hasMenuOrder;
this.$el.sortable( 'option', 'disabled', ! enabled ); this.$el.sortable( 'option', 'disabled', ! enabled );
// Check if any attachments have a specified menu order.
hasMenuOrder = this.collection.any( function( attachment ) {
return attachment.get('menuOrder');
});
// Always unbind the `saveMenuOrder` callback to prevent multiple
// callbacks stacking up.
this.collection.off( 'change:uploading', this.saveMenuOrder, this );
if ( hasMenuOrder )
this.collection.on( 'change:uploading', this.saveMenuOrder, this );
},
saveMenuOrder: function() {
this.collection.saveMenuOrder();
}, },
createAttachmentView: function( attachment ) { createAttachmentView: function( attachment ) {