Changeset 29490 for trunk/src/wp-includes/js/media-grid.js
- Timestamp:
- 08/14/2014 06:30:49 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/media-grid.js
r29489 r29490 184 184 wp.media( { 185 185 frame: 'edit-attachments', 186 gridRouter: this.gridRouter,186 controller: this, 187 187 library: this.state().get('library'), 188 188 model: model … … 231 231 232 232 bindDeferred: function() { 233 if ( ! this.browserView.dfd ) { 234 return; 235 } 233 236 this.browserView.dfd.done( _.bind( this.startHistory, this ) ); 234 237 }, … … 353 356 354 357 events: { 355 'click': 'collapse',356 'click .delete-media-item': 'deleteMediaItem',357 358 'click .left': 'previousMediaItem', 358 359 'click .right': 'nextMediaItem' … … 360 361 361 362 initialize: function() { 362 var self = this;363 364 363 media.view.Frame.prototype.initialize.apply( this, arguments ); 365 364 … … 369 368 }); 370 369 371 this. gridRouter = this.options.gridRouter;372 370 this.controller = this.options.controller; 371 this.gridRouter = this.controller.gridRouter; 373 372 this.library = this.options.library; 374 373 … … 376 375 this.model = this.options.model; 377 376 } else { 377 // this is a hack 378 378 this.model = this.library.at( 0 ); 379 379 } 380 380 381 this.bindHandlers(); 382 this.createStates(); 383 this.createModal(); 384 385 this.title.mode( 'default' ); 386 387 this.options.hasPrevious = this.hasPrevious(); 388 this.options.hasNext = this.hasNext(); 389 }, 390 391 bindHandlers: function() { 392 // Bind default title creation. 393 this.on( 'title:create:default', this.createTitle, this ); 394 381 395 // Close the modal if the attachment is deleted. 382 this.listenTo( this.model, 'destroy', this.close, this ); 383 384 this.createStates(); 396 this.listenTo( this.model, 'change:status destroy', this.close, this ); 385 397 386 398 this.on( 'content:create:edit-metadata', this.editMetadataMode, this ); … … 388 400 this.on( 'content:render:edit-image', this.editImageModeRender, this ); 389 401 this.on( 'close', this.detach ); 390 391 // Bind default title creation. 392 this.on( 'title:create:default', this.createTitle, this ); 393 this.title.mode( 'default' ); 394 395 this.options.hasPrevious = this.hasPrevious(); 396 this.options.hasNext = this.hasNext(); 402 }, 403 404 createModal: function() { 405 var self = this; 397 406 398 407 // Initialize modal container view. … … 610 619 initialize: function() { 611 620 media.view.Button.prototype.initialize.apply( this, arguments ); 621 if ( this.options.filters ) { 622 this.listenTo( this.options.filters.model, 'change', this.filterChange ); 623 } 612 624 this.listenTo( this.controller, 'selection:toggle', this.toggleDisabled ); 613 625 }, 614 626 627 filterChange: function( model ) { 628 if ( 'trash' === model.get( 'status' ) ) { 629 this.model.set( 'text', l10n.untrashSelected ); 630 } else if ( media.view.settings.mediaTrash ) { 631 this.model.set( 'text', l10n.trashSelected ); 632 } else { 633 this.model.set( 'text', l10n.deleteSelected ); 634 } 635 }, 636 615 637 toggleDisabled: function() { 616 this. $el.attr( 'disabled', ! this.controller.state().get( 'selection' ).length );638 this.model.set( 'disabled', ! this.controller.state().get( 'selection' ).length ); 617 639 }, 618 640 619 641 render: function() { 620 642 media.view.Button.prototype.render.apply( this, arguments ); 621 this.$el.addClass( 'delete-selected-button hidden' ); 643 if ( this.controller.isModeActive( 'select' ) ) { 644 this.$el.addClass( 'delete-selected-button' ); 645 } else { 646 this.$el.addClass( 'delete-selected-button hidden' ); 647 } 622 648 return this; 623 649 }
Note: See TracChangeset
for help on using the changeset viewer.