From a18943fd1b0e37f830c7b61f8688961d216c01b2 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sat, 4 Jan 2014 01:27:59 +0000 Subject: [PATCH] TinyMCE: 'wpdialogs' plugin, don't add the (external) UI dialogs element to the internal windows array, fix .close(). See #24067. git-svn-id: https://develop.svn.wordpress.org/trunk@26900 602fd350-edb4-49c9-b593-d223f7449a82 --- .../js/tinymce/plugins/wpdialogs/plugin.js | 31 ++++++++++--------- .../js/tinymce/plugins/wpeditimage/plugin.js | 2 +- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/wp-includes/js/tinymce/plugins/wpdialogs/plugin.js b/src/wp-includes/js/tinymce/plugins/wpdialogs/plugin.js index 7e18713c23..63a2d2109c 100644 --- a/src/wp-includes/js/tinymce/plugins/wpdialogs/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpdialogs/plugin.js @@ -8,22 +8,28 @@ * For examples see the default plugins: https://github.com/tinymce/tinymce/tree/master/js/tinymce/plugins */ tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) { + if ( this.wp ) { + return this; + } + this.wp = {}; this.parent = editor.windowManager; this.editor = editor; tinymce.extend( this, this.parent ); this.open = function( args, params ) { - var self = this, $element; + var $element, + self = this, + wp = this.wp; if ( ! args.wpDialog ) { - return this.parent.open( args, params ); + return this.parent.open.apply( this, arguments ); } else if ( ! args.id ) { return; } - self.element = $element = jQuery( '#' + args.id ); + wp.$element = $element = jQuery( '#' + args.id ); if ( ! $element.length ) { return; @@ -33,9 +39,8 @@ tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) { window.console.log('tinymce.WPWindowManager is deprecated. Use the default editor.windowManager to open dialogs with inline HTML.'); } - self.features = args; - self.params = params; - self.windows.push( $element ); + wp.features = args; + wp.params = params; // Store selection. Takes a snapshot in the FocusManager of the selection before focus is moved to the dialog. editor.nodeChanged(); @@ -55,24 +60,20 @@ tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) { $element.wpdialog('open'); $element.on( 'wpdialogclose', function() { - var i = self.windows.length; - - while ( i-- && i > -1 ) { - if ( self.windows[i] === self.element ) { - self.windows.splice( i, 1 ); - } + if ( self.wp.$element ) { + self.wp = {}; } }); }; this.close = function() { - if ( ! this.features.wpDialog ) { + if ( ! this.wp.features || ! this.wp.features.wpDialog ) { return this.parent.close.apply( this, arguments ); } - this.element.wpdialog('close'); + this.wp.$element.wpdialog('close'); }; -} +}; tinymce.PluginManager.add( 'wpdialogs', function( editor ) { // Replace window manager diff --git a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js index b3eae05d48..577a5cec90 100644 --- a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js @@ -57,7 +57,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { out = b.match( /
]+>([\s\S]+?)<\/dd>/i ); if ( out && out[1] ) { - return '

' + out[1] + '

' + return '

' + out[1] + '

'; } return '';