Make WordPress Core

Ticket #31412: 31412.9.patch

File 31412.9.patch, 4.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() );
     
    808808        views.register( 'embedURL', _.extend( {}, embed, {
    809809                match: function( content ) {
    810810                        var re = /(^|<p>)(https?:\/\/[^\s"]+?)(<\/p>\s*|$)/gi,
    811                                 match = re.exec( tinymce.trim( content ) );
     811                                match = re.exec( content );
    812812
    813813                        if ( match ) {
    814814                                return {
  • src/wp-includes/js/tinymce/plugins/wpview/plugin.js

     
    3434                return false;
    3535        }
    3636
    37         /**
    38          * Get the text/shortcode string for a view.
    39          *
    40          * @param view The view wrapper's node
    41          * @returns string The text/shoercode string of the view
    42          */
    43         function getViewText( view ) {
    44                 if ( view = getView( view ) ) {
    45                         return window.decodeURIComponent( editor.dom.getAttrib( view, 'data-wpview-text' ) || '' );
    46                 }
    47 
    48                 return '';
    49         }
    50 
    51         /**
    52          * Set the view's original text/shortcode string
    53          *
    54          * @param view The view wrapper's HTML id or node
    55          * @param text The text string to be set
    56          */
    57         function setViewText( view, text ) {
    58                 view = getView( view );
    59 
    60                 if ( view ) {
    61                         editor.dom.setAttrib( view, 'data-wpview-text', window.encodeURIComponent( text || '' ) );
    62                         return true;
    63                 }
    64 
    65                 return false;
    66         }
    67 
    6837        function _stop( event ) {
    6938                event.stopPropagation();
    7039        }
     
    138107                clipboard = dom.create( 'div', {
    139108                        'class': 'wpview-clipboard',
    140109                        'contenteditable': 'true'
    141                 }, getViewText( viewNode ) );
     110                }, decodeURIComponent( editor.dom.getAttrib( viewNode, 'data-wpview-text' ) ) );
    142111
    143112                editor.dom.select( '.wpview-body', viewNode )[0].appendChild( clipboard );
    144113
     
    197166        // Check if the `wp.mce` API exists.
    198167        if ( typeof wp === 'undefined' || ! wp.mce ) {
    199168                return {
    200                         getViewText: _noop,
    201                         setViewText: _noop,
    202169                        getView: _noop
    203170                };
    204171        }
     
    721688        });
    722689
    723690        return {
    724                 getViewText: getViewText,
    725                 setViewText: setViewText,
    726691                getView: getView
    727692        };
    728693});