From aa10b9f67b145076d9f7a205d7b43b444e3ecbc6 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 16 Jul 2014 19:31:30 +0000 Subject: [PATCH] Cleanup after [29179]: Don't attach nodes to the view instance and check if the iframe still exists before resizing. Props avryl. See #28905. git-svn-id: https://develop.svn.wordpress.org/trunk@29193 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/mce-view.js | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/wp-includes/js/mce-view.js b/src/wp-includes/js/mce-view.js index 9dcb8ba793..1065d69daa 100644 --- a/src/wp-includes/js/mce-view.js +++ b/src/wp-includes/js/mce-view.js @@ -162,7 +162,8 @@ window.wp = window.wp || {}; iframeDoc.close(); resize = function() { - $( iframe ).height( $( iframeDoc.body ).height() ); + // Make sure the iframe still exists. + iframe.contentWindow && $( iframe ).height( $( iframeDoc.body ).height() ); }; if ( MutationObserver ) { @@ -515,10 +516,7 @@ window.wp = window.wp || {}; $( document ).on( 'media:edit', this.pausePlayers ); }, - setNode: function ( event, editor, node ) { - if ( node ) { - this.node = node; - } + setNode: function ( event, editor ) { editor.on( 'hide', this.pausePlayers ); if ( this.parsed ) { @@ -576,21 +574,27 @@ window.wp = window.wp || {}; }, pausePlayers: function() { - var p, win = $( 'iframe', this.node ).get(0).contentWindow; - if ( win && win.mejs ) { - for ( p in win.mejs.players ) { - win.mejs.players[p].pause(); + this.getNodes( function( editor, node ) { + var p, win = $( 'iframe', node ).get(0).contentWindow; + + if ( win && win.mejs ) { + for ( p in win.mejs.players ) { + win.mejs.players[p].pause(); + } } - } + }); }, unsetPlayers: function() { - var p, win = $( 'iframe', this.node ).get(0).contentWindow; - if ( win && win.mejs ) { - for ( p in win.mejs.players ) { - win.mejs.players[p].remove(); + this.getNodes( function( editor, node ) { + var p, win = $( 'iframe', node ).get(0).contentWindow; + + if ( win && win.mejs ) { + for ( p in win.mejs.players ) { + win.mejs.players[p].remove(); + } } - } + }); }, unbind: function() {