Make WordPress Core

Changeset 29272


Ignore:
Timestamp:
07/22/2014 09:48:41 PM (12 years ago)
Author:
azaozz
Message:

wpView: consolidate pausePlayers() and unsetPlayers(), they are almost the same. Prevent errors when instead of a player ME.js shows only a "Download File" placeholder (in IE). See #28905.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/mce-view.js

    r29202 r29272  
    505505                                this.shortcode = options.shortcode;
    506506
    507                                 _.bindAll( this, 'setIframes', 'setNodes', 'fetch', 'pausePlayers' );
     507                                _.bindAll( this, 'setIframes', 'setNodes', 'fetch', 'stopPlayers' );
    508508                                $( this ).on( 'ready', this.setNodes );
    509509
    510                                 $( document ).on( 'media:edit', this.pausePlayers );
     510                                $( document ).on( 'media:edit', this.stopPlayers );
    511511
    512512                                this.fetch();
    513513
    514514                                this.getEditors( function( editor ) {
    515                                         editor.on( 'hide', self.pausePlayers );
     515                                        editor.on( 'hide', self.stopPlayers );
    516516                                });
    517517                        },
    … …  
    554554                        },
    555555
    556                         pausePlayers: function() {
     556                        stopPlayers: function( remove ) {
     557                                var rem = remove === 'remove';
     558
    557559                                this.getNodes( function( editor, node, content ) {
    558560                                        var p, win,
    … …  
    560562
    561563                                        if ( iframe && ( win = iframe.contentWindow ) && win.mejs ) {
    562                                                 for ( p in win.mejs.players ) {
    563                                                         win.mejs.players[p].pause();
    564                                                 }
     564                                                // Sometimes ME.js may show a "Download File" placeholder and player.remove() doesn't exist there.
     565                                                try {
     566                                                        for ( p in win.mejs.players ) {
     567                                                                win.mejs.players[p].pause();
     568
     569                                                                if ( rem ) {
     570                                                                        win.mejs.players[p].remove();
     571                                                                }
     572                                                        }
     573                                                } catch( er ) {}
    565574                                        }
    566575                                });
    567576                        },
    568577
    569                         unsetPlayers: function() {
    570                                 this.getNodes( function( editor, node, content ) {
    571                                         var p, win,
    572                                                 iframe = $( 'iframe.wpview-sandbox', content ).get(0);
    573 
    574                                         if ( iframe && ( win = iframe.contentWindow ) && win.mejs ) {
    575                                                 for ( p in win.mejs.players ) {
    576                                                         win.mejs.players[p].remove();
    577                                                 }
    578                                         }
    579                                 });
    580                         },
    581 
    582578                        unbind: function() {
    583                                 this.pausePlayers();
    584                                 this.unsetPlayers();
     579                                this.stopPlayers( 'remove' );
    585580                        }
    586581                },
Note: See TracChangeset for help on using the changeset viewer.