From f071e710c28825161c7815e931d5881b52bb6833 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 16 Jul 2014 16:13:47 +0000 Subject: [PATCH] Cleanup after [29179]: * Cleanup players when the editor is hidden - window scope is unique to each frame * Add the editor body class to each iframe sandbox * Remove unneeded code from `wp-mediaelement.js` See #28905. git-svn-id: https://develop.svn.wordpress.org/trunk@29189 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/mce-view.js | 23 +++++++++++++++---- .../js/mediaelement/wp-mediaelement.js | 4 ---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/wp-includes/js/mce-view.js b/src/wp-includes/js/mce-view.js index 9454f2850d..4754895726 100644 --- a/src/wp-includes/js/mce-view.js +++ b/src/wp-includes/js/mce-view.js @@ -130,7 +130,9 @@ window.wp = window.wp || {}; node = $( node ).find( '.wpview-content' )[0]; - node.innerHTML = ''; + if ( node ) { + node.innerHTML = ''; + } iframe = dom.add( node, 'iframe', { src: tinymce.Env.ie ? 'javascript:""' : '', @@ -152,7 +154,7 @@ window.wp = window.wp || {}; '' + '' + '' + - '' + + '' + content + '' + '' @@ -507,11 +509,14 @@ window.wp = window.wp || {}; this.shortcode = options.shortcode; this.fetching = false; - _.bindAll( this, 'createIframe', 'setNode', 'fetch' ); + _.bindAll( this, 'createIframe', 'setNode', 'fetch', 'pausePlayers' ); $( this ).on( 'ready', this.setNode ); }, - setNode: function () { + setNode: function ( event, editor, node ) { + this.node = node; + editor.on( 'hide', this.pausePlayers ); + if ( this.parsed ) { this.createIframe( this.parsed ); } else if ( ! this.fetching ) { @@ -564,6 +569,16 @@ window.wp = window.wp || {}; return ' '; } return this.parsed; + }, + + pausePlayers: function() { + var p, win = $( 'iframe', this.node ).get(0).contentWindow; + if ( win.mejs ) { + for ( p in win.mejs.players ) { + win.mejs.players[p].pause(); + win.mejs.players[p].remove(); + } + } } }, diff --git a/src/wp-includes/js/mediaelement/wp-mediaelement.js b/src/wp-includes/js/mediaelement/wp-mediaelement.js index 2caa81592b..6e20b90058 100644 --- a/src/wp-includes/js/mediaelement/wp-mediaelement.js +++ b/src/wp-includes/js/mediaelement/wp-mediaelement.js @@ -7,10 +7,6 @@ $(function () { var settings = {}; - if ( $( document.body ).hasClass( 'mce-content-body' ) ) { - return; - } - if ( typeof _wpmejsSettings !== 'undefined' ) { settings = _wpmejsSettings; }