From 5e8787d0deb4c735203c957243ad7e490018e6f8 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Tue, 25 Feb 2014 21:02:22 +0000 Subject: [PATCH] When closing the various "edit" media modals, remove the related views elements from the DOM. Props gcorne, fixes #27204. git-svn-id: https://develop.svn.wordpress.org/trunk@27276 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/media-views.js | 4 ++++ src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js | 4 ++-- src/wp-includes/js/tinymce/plugins/wpgallery/plugin.js | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js index 47e527eefc..db5ea30153 100644 --- a/src/wp-includes/js/media-views.js +++ b/src/wp-includes/js/media-views.js @@ -2768,6 +2768,10 @@ } this.controller.on( 'activate', this.refresh, this ); + + this.controller.on( 'detach', function() { + this.$browser.remove(); + }, this ); }, refresh: function() { diff --git a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js index f62509779b..9129dd204d 100644 --- a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js @@ -288,14 +288,14 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { callback = function( imageData ) { updateImage( img, imageData ); editor.focus(); + frame.detach(); }; frame.state('image-details').on( 'update', callback ); frame.state('replace-image').on( 'replace', callback ); frame.on( 'close', function() { editor.focus(); - // editor.selection.select( img ); - // editor.nodeChanged(); + frame.detach(); }); frame.open(); diff --git a/src/wp-includes/js/tinymce/plugins/wpgallery/plugin.js b/src/wp-includes/js/tinymce/plugins/wpgallery/plugin.js index 0233133289..def97d6faf 100644 --- a/src/wp-includes/js/tinymce/plugins/wpgallery/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpgallery/plugin.js @@ -73,6 +73,7 @@ tinymce.PluginManager.add('wpgallery', function( editor ) { frame.state('gallery-edit').on( 'update', function( selection ) { var shortcode = gallery.shortcode( selection ).string(); editor.dom.setAttrib( node, 'data-wp-media', window.encodeURIComponent( shortcode ) ); + frame.detach(); }); } else if ( editor.dom.hasClass( node, 'wp-playlist' ) && wp.media.playlist ) { data = window.decodeURIComponent( editor.dom.getAttrib( node, 'data-wp-media' ) ); @@ -81,6 +82,7 @@ tinymce.PluginManager.add('wpgallery', function( editor ) { frame.state('playlist-edit').on( 'update', function( selection ) { var shortcode = wp.media.playlist.shortcode( selection ).string(); editor.dom.setAttrib( node, 'data-wp-media', window.encodeURIComponent( shortcode ) ); + frame.detach(); }); } else if ( editor.dom.hasClass( node, 'wp-video-playlist' ) && wp.media['video-playlist'] ) { data = window.decodeURIComponent( editor.dom.getAttrib( node, 'data-wp-media' ) ); @@ -89,6 +91,7 @@ tinymce.PluginManager.add('wpgallery', function( editor ) { frame.state('video-playlist-edit').on( 'update', function( selection ) { var shortcode = wp.media['video-playlist'].shortcode( selection ).string(); editor.dom.setAttrib( node, 'data-wp-media', window.encodeURIComponent( shortcode ) ); + frame.detach(); }); } else { // temp