Make WordPress Core

Ticket #31412: 31412.7.patch

File 31412.7.patch, 2.0 KB (added by iseulde, 10 years ago)
  • src/wp-includes/js/mce-view.js

     
    651651                        var media = wp.media[ this.type ],
    652652                                frame = media.edit( text );
    653653
    654                         this.stopPlayers && this.stopPlayers();
     654                        this.pausePlayers && this.pausePlayers();
    655655
    656656                        _.each( this.state, function( state ) {
    657657                                frame.state( state ).on( 'update', function( selection ) {
     
    728728                                self.render();
    729729                        } )
    730730                        .fail( function( response ) {
    731                                 if ( self.type === 'embedURL' ) {
     731                                if ( self.url ) {
    732732                                        self.removeMarkers();
    733733                                } else {
    734734                                        self.setError( response.message || response.statusText, 'admin-media' );
     
    737737
    738738                        this.getEditors( function( editor ) {
    739739                                editor.on( 'wpview-selected', function() {
    740                                         self.stopPlayers();
     740                                        self.pausePlayers();
    741741                                } );
    742742                        } );
    743743                },
    744744
    745                 stopPlayers: function( remove ) {
     745                pausePlayers: function() {
    746746                        this.getNodes( function( editor, node, content ) {
    747747                                var win = $( 'iframe.wpview-sandbox', content ).get( 0 );
    748748
    749749                                if ( win && ( win = win.contentWindow ) && win.mejs ) {
    750750                                        _.each( win.mejs.players, function( player ) {
    751751                                                try {
    752                                                         player[ remove ? 'remove' : 'pause' ]();
     752                                                        player.pause();
    753753                                                } catch ( e ) {}
    754754                                        } );
    755755                                }
     
    762762
    763763                edit: function( text, update ) {
    764764                        var media = wp.media.embed,
    765                                 isURL = 'embedURL' === this.type,
    766                                 frame = media.edit( text, isURL );
     765                                frame = media.edit( text, !! this.url ),
     766                                self = this;
    767767
    768                         this.stopPlayers();
     768                        this.pausePlayers();
    769769
    770770                        frame.state( 'embed' ).props.on( 'change:url', function( model, url ) {
    771771                                if ( url ) {
     
    774774                        } );
    775775
    776776                        frame.state( 'embed' ).on( 'select', function() {
    777                                 if ( isURL ) {
     777                                if ( self.url ) {
    778778                                        update( frame.state( 'embed' ).metadata.url );
    779779                                } else {
    780780                                        update( media.shortcode( frame.state( 'embed' ).metadata ).string() );