Make sure that media/views.js doesn't load Models that already exist in media/models.js.

See #28510.


git-svn-id: https://develop.svn.wordpress.org/trunk@31379 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-02-09 04:13:38 +00:00
parent b136100978
commit 1c9874a7f2
13 changed files with 195 additions and 3712 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -33,7 +33,7 @@
* @param {string} attributes.type The collection's media type. (e.g. 'video').
* @param {string} attributes.collectionType The collection type. (e.g. 'playlist').
*/
var Selection = require( '../models/selection.js' ),
var Selection = wp.media.model.Selection,
Library = require( './library.js' ),
CollectionAdd;

View File

@@ -34,8 +34,7 @@
* @param {string} attributes.type The collection's media type. (e.g. 'video').
* @param {string} attributes.collectionType The collection type. (e.g. 'playlist').
*/
var Selection = require( '../models/selection.js' ),
Library = require( './library.js' ),
var Library = require( './library.js' ),
View = require( '../views/view.js' ),
EditLibraryView = require( '../views/attachment/edit-library.js' ),
l10n = wp.media.view.l10n,
@@ -72,7 +71,7 @@ CollectionEdit = Library.extend({
// If we haven't been provided a `library`, create a `Selection`.
if ( ! this.get('library') ) {
this.set( 'library', new Selection() );
this.set( 'library', new wp.media.model.Selection() );
}
// The single `Attachment` view to be used in the `Attachments` view.
if ( ! this.get('AttachmentView') ) {

View File

@@ -31,7 +31,7 @@
* @param {boolean} [attributes.contentUserSetting=true] Whether the content region's mode should be set and persisted per user.
* @param {boolean} [attributes.syncSelection=true] Whether the Attachments selection should be persisted from the last state.
*/
var Attachment = require( '../models/attachment.js' ),
var Attachment = wp.media.model.Attachment,
Library = require( './library.js' ),
l10n = wp.media.view.l10n,
FeaturedImage;

View File

@@ -29,7 +29,7 @@
* @param {boolean} [attributes.syncSelection=false] Whether the Attachments selection should be persisted from the last state.
* Defaults to false because for this state, because the library of the Edit Gallery state is the selection.
*/
var Selection = require( '../models/selection.js' ),
var Selection = wp.media.model.Selection,
Library = require( './library.js' ),
l10n = wp.media.view.l10n,
GalleryAdd;

View File

@@ -31,8 +31,7 @@
* @param {view} [attributes.AttachmentView] The single `Attachment` view to be used in the `Attachments`.
* If none supplied, defaults to wp.media.view.Attachment.EditLibrary.
*/
var Selection = require( '../models/selection.js' ),
Library = require( './library.js' ),
var Library = require( './library.js' ),
EditLibraryView = require( '../views/attachment/edit-library.js' ),
GallerySettingsView = require( '../views/settings/gallery.js' ),
l10n = wp.media.view.l10n,
@@ -63,7 +62,7 @@ GalleryEdit = Library.extend({
initialize: function() {
// If we haven't been provided a `library`, create a `Selection`.
if ( ! this.get('library') )
this.set( 'library', new Selection() );
this.set( 'library', new wp.media.model.Selection() );
// The single `Attachment` view to be used in the `Attachments` view.
if ( ! this.get('AttachmentView') )

View File

@@ -35,7 +35,6 @@
* @param {boolean} [attributes.syncSelection=true] Whether the Attachments selection should be persisted from the last state.
*/
var selectionSync = require( '../utils/selection-sync.js' ),
Selection = require( '../models/selection.js' ),
State = require( './state.js' ),
l10n = wp.media.view.l10n,
Library;
@@ -80,7 +79,7 @@ Library = State.extend({
props = _.omit( props, 'orderby', 'query' );
}
this.set( 'selection', new Selection( null, {
this.set( 'selection', new wp.media.model.Selection( null, {
multiple: this.get('multiple'),
props: props
}) );

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -17,8 +17,6 @@
*/
var Select = require( './select.js' ),
Toolbar = require( '../toolbar.js' ),
PostImage = require( '../../models/post-image.js' ),
Selection = require( '../../models/selection.js' ),
ImageDetailsController = require( '../../controllers/image-details.js' ),
ReplaceImageController = require( '../../controllers/replace-image.js' ),
EditImageController = require( '../../controllers/edit-image.js' ),
@@ -40,8 +38,8 @@ ImageDetails = Select.extend({
},
initialize: function( options ) {
this.image = new PostImage( options.metadata );
this.options.selection = new Selection( this.image.attachment, { multiple: false } );
this.image = new wp.media.model.PostImage( options.metadata );
this.options.selection = new wp.media.model.Selection( this.image.attachment, { multiple: false } );
Select.prototype.initialize.apply( this, arguments );
},

View File

@@ -15,8 +15,6 @@
var View = require( '../view.js' ),
Toolbar = require( '../toolbar.js' ),
Select = require( './select.js' ),
Selection = require( '../../models/selection.js' ),
PostMedia = require( '../../models/post-media.js' ),
l10n = wp.media.view.l10n,
MediaDetails;
@@ -36,8 +34,8 @@ MediaDetails = Select.extend({
this.cancelText = options.cancelText;
this.addText = options.addText;
this.media = new PostMedia( options.metadata );
this.options.selection = new Selection( this.media.attachment, { multiple: false } );
this.media = new wp.media.model.PostMedia( options.metadata );
this.options.selection = new wp.media.model.Selection( this.media.attachment, { multiple: false } );
Select.prototype.initialize.apply( this, arguments );
},

View File

@@ -24,7 +24,6 @@ var View = require( '../view.js' ),
ToolbarEmbed = require( '../toolbar/embed.js' ),
PlaylistSettings = require( '../settings/playlist.js' ),
AttachmentsBrowser = require( '../attachments/browser.js' ),
SelectionModel = require( '../../models/selection.js' ),
SelectionView = require( '../selection.js' ),
EmbedController = require( '../../controllers/embed.js' ),
EditImageController = require( '../../controllers/edit-image.js' ),
@@ -493,7 +492,7 @@ Post = Select.extend({
edit = controller.state('gallery-edit'),
models = selection.where({ type: 'image' });
edit.set( 'library', new SelectionModel( models, {
edit.set( 'library', new wp.media.model.Selection( models, {
props: selection.props.toJSON(),
multiple: true
}) );
@@ -523,7 +522,7 @@ Post = Select.extend({
edit = controller.state('playlist-edit'),
models = selection.where({ type: 'audio' });
edit.set( 'library', new SelectionModel( models, {
edit.set( 'library', new wp.media.model.Selection( models, {
props: selection.props.toJSON(),
multiple: true
}) );
@@ -553,7 +552,7 @@ Post = Select.extend({
edit = controller.state('video-playlist-edit'),
models = selection.where({ type: 'video' });
edit.set( 'library', new SelectionModel( models, {
edit.set( 'library', new wp.media.model.Selection( models, {
props: selection.props.toJSON(),
multiple: true
}) );

View File

@@ -16,8 +16,6 @@
var MediaFrame = require( '../media-frame.js' ),
Library = require( '../../controllers/library.js' ),
AttachmentsModel = require( '../../models/attachments.js' ),
SelectionModel = require( '../../models/selection.js' ),
AttachmentsBrowser = require( '../attachments/browser.js' ),
UploaderInline = require( '../uploader/inline.js' ),
ToolbarSelect = require( '../toolbar/select.js' ),
@@ -53,14 +51,14 @@ Select = MediaFrame.extend({
createSelection: function() {
var selection = this.options.selection;
if ( ! (selection instanceof SelectionModel) ) {
this.options.selection = new SelectionModel( selection, {
if ( ! (selection instanceof wp.media.model.Selection) ) {
this.options.selection = new wp.media.model.Selection( selection, {
multiple: this.options.multiple
});
}
this._selection = {
attachments: new AttachmentsModel(),
attachments: new wp.media.model.Attachments(),
difference: []
};
},