diff --git a/wp-includes/js/mce-view.js b/wp-includes/js/mce-view.js index 9454f2850d..4754895726 100644 --- a/wp-includes/js/mce-view.js +++ b/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/wp-includes/js/mce-view.min.js b/wp-includes/js/mce-view.min.js index ca4b6666d5..03e92cbe0c 100644 --- a/wp-includes/js/mce-view.min.js +++ b/wp-includes/js/mce-view.min.js @@ -1 +1 @@ -window.wp=window.wp||{},function(a){"use strict";var b={},c={},d=wp.media,e=["encodedText"];wp.mce=wp.mce||{},wp.mce.View=function(a){a=a||{},this.type=a.type,_.extend(this,_.pick(a,e)),this.initialize.apply(this,arguments)},_.extend(wp.mce.View.prototype,{initialize:function(){},getHtml:function(){return""},loadingPlaceholder:function(){return'
',function(b,c,d){a(b).trigger("ready",[c,d])},"wrap")},unbind:function(){},getNodes:function(b){var c=[];return _.each(tinymce.editors,function(d){d.plugins.wpview&&a(d.getBody()).find('[data-wpview-text="'+this.encodedText+'"]').each(function(a,e){b&&b(d,e),c.push(e)})},this),c},setContent:function(b,c,d){var e=this;this.getNodes(function(f,g){var h=a(g).find(".wpview-content"),i=g;h.length&&"wrap"!==d&&(g=h=h[0]),_.isString(b)?"replace"===d?g=f.dom.replace(f.dom.createFragment(b),i):f.dom.setHTML(g,b):"replace"===d?g=f.dom.replace(b,i):a(g).empty().append(b),_.isFunction(c)&&c(e,f,a(g).find(".wpview-content")[0])})},createIframe:function(b){var c=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;-1!==b.indexOf("