Ticket #36916: media-grid.js.patch
File media-grid.js.patch, 2.7 KB (added by , 7 years ago) |
---|
-
media-grid.js
118 118 toggleSelectionHandler: function() {}, 119 119 120 120 render: function() { 121 Details.prototype.render.apply( this, arguments ); 121 var that = this; 122 wp.media.view.Attachment.Details.prototype.render.apply( this, arguments ); 123 this.players = this.players || []; 122 124 123 wp.media.mixin.removeAllPlayers(); 124 this.$( 'audio, video' ).each( function (i, elem) { 125 wp.media.mixin.unsetPlayers.call( this ); 126 127 this.$( 'audio, video' ).each( function ( i, elem ) { 125 128 var el = wp.media.view.MediaDetails.prepareSrc( elem ); 126 new window.MediaElementPlayer( el, wp.media.mixin.mejsSettings);129 that.players.push( new window.MediaElementPlayer( el, wp.media.mixin.mejsSettings ) ); 127 130 } ); 128 131 } 129 132 }); … … 382 385 }); 383 386 384 387 this.controller = this.options.controller; 385 this.gridRouter = this.controller.gridRouter;386 388 this.library = this.options.library; 387 389 388 390 if ( this.options.model ) { … … 428 430 $( 'body' ).off( 'keydown.media-modal' ); /* remove the keydown event */ 429 431 // Restore the original focus item if possible 430 432 $( 'li.attachment[data-id="' + this.model.get( 'id' ) +'"]' ).focus(); 431 this.resetRoute();432 433 }, this ) ); 433 434 434 435 // Set this frame as the modal's content. … … 466 467 controller: this, 467 468 model: this.model 468 469 }) ); 469 470 // Update browser url when navigating media details471 if ( this.model ) {472 this.gridRouter.navigate( this.gridRouter.baseUrl( '?item=' + this.model.id ) );473 }474 470 }, 475 471 476 472 /** … … 573 569 if ( 37 === event.keyCode ) { 574 570 this.previousMediaItem(); 575 571 } 576 },577 578 resetRoute: function() {579 this.gridRouter.navigate( this.gridRouter.baseUrl( '' ) );580 572 } 581 573 }); 582 574 … … 780 772 * Open the Edit Attachment modal. 781 773 */ 782 774 openEditAttachmentModal: function( model ) { 783 // Create a new EditAttachment frame, passing along the library and the attachment model. 784 wp.media( { 775 this._frame = wp.media( { 785 776 frame: 'edit-attachments', 786 777 controller: this, 787 778 library: this.state().get('library'), 788 779 model: model 789 780 } ); 781 782 this._frame.modal.on( 'close', this.resetRoute, this ); 783 this._frame.on( 'content:create:edit-metadata', this.setRoute, this ); 790 784 }, 791 785 792 786 /** … … 845 839 pushState: true 846 840 } ); 847 841 } 842 }, 843 844 resetRoute: function() { 845 this.gridRouter.navigate( this.gridRouter.baseUrl( '' ) ); 846 }, 847 848 setRoute: function() { 849 // Update browser url when navigating media details 850 if ( this._frame.model ) { 851 this.gridRouter.navigate( this.gridRouter.baseUrl( '?item=' + this._frame.model.id ) ); 852 } 848 853 } 849 854 }); 850 855