TinyMCE: back-compat, refresh and re-enable the 'wpdialogs' plugin, and mark it as deprecated. See #24067.

Built from https://develop.svn.wordpress.org/trunk@26899


git-svn-id: http://core.svn.wordpress.org/trunk@26782 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2014-01-03 02:33:10 +00:00
parent 915607ca0d
commit b7999f453a
4 changed files with 42 additions and 18 deletions

View File

@ -234,6 +234,7 @@ final class _WP_Editors {
'wpeditimage',
'wpgallery',
'wplink',
'wpdialogs',
) ) );
if ( ! empty( $mce_external_plugins ) ) {

View File

@ -1,36 +1,48 @@
/* global tinymce */
tinymce.WPWindowManager = function( editor ) {
var element;
/**
* Included for back-compat.
* The default WindowManager in TinyMCE 4.0 supports three types of dialogs:
* - With HTML created from JS.
* - With inline HTML (like WPWindowManager).
* - Old type iframe based dialogs.
* For examples see the default plugins: https://github.com/tinymce/tinymce/tree/master/js/tinymce/plugins
*/
tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) {
this.parent = editor.windowManager;
this.editor = editor;
tinymce.extend( this, this.parent )
tinymce.extend( this, this.parent );
this.open = function( args, params ) {
var self = this, element;
var self = this, $element;
if ( ! args.wpDialog )
if ( ! args.wpDialog ) {
return this.parent.open( args, params );
else if ( ! args.id )
} else if ( ! args.id ) {
return;
}
self.element = element = jQuery('#' + args.id);
if ( ! element.length )
self.element = $element = jQuery( '#' + args.id );
if ( ! $element.length ) {
return;
}
if ( window && window.console ) {
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.onOpen.dispatch( self, args, params );
self.windows.push( element );
self.windows.push( $element );
// Store selection
// self.bookmark = self.editor.selection.getBookmark(1);
// Store selection. Takes a snapshot in the FocusManager of the selection before focus is moved to the dialog.
editor.nodeChanged();
// Create the dialog if necessary
if ( ! element.data('wpdialog') ) {
element.wpdialog({
if ( ! $element.data('wpdialog') ) {
$element.wpdialog({
title: args.title,
width: args.width,
height: args.height,
@ -40,12 +52,23 @@ tinymce.WPWindowManager = function( editor ) {
});
}
element.wpdialog('open');
$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 );
}
}
});
};
this.close = function() {
if ( ! this.features.wpDialog )
if ( ! this.features.wpDialog ) {
return this.parent.close.apply( this, arguments );
}
this.element.wpdialog('close');
};

View File

@ -1 +1 @@
tinymce.WPWindowManager=function(a){this.parent=a.windowManager,this.editor=a,tinymce.extend(this,this.parent),this.open=function(a,b){var c,d=this;return a.wpDialog?(a.id&&(d.element=c=jQuery("#"+a.id),c.length&&(d.features=a,d.params=b,d.onOpen.dispatch(d,a,b),d.windows.push(c),c.data("wpdialog")||c.wpdialog({title:a.title,width:a.width,height:a.height,modal:!0,dialogClass:"wp-dialog",zIndex:3e5}),c.wpdialog("open"))),void 0):this.parent.open(a,b)},this.close=function(){return this.features.wpDialog?(this.element.wpdialog("close"),void 0):this.parent.close.apply(this,arguments)}},tinymce.PluginManager.add("wpdialogs",function(a){a.on("init",function(){a.windowManager=new tinymce.WPWindowManager(a)})});
tinymce.WPWindowManager=tinymce.InlineWindowManager=function(a){this.parent=a.windowManager,this.editor=a,tinymce.extend(this,this.parent),this.open=function(b,c){var d,e=this;return b.wpDialog?(b.id&&(e.element=d=jQuery("#"+b.id),d.length&&(window&&window.console&&window.console.log("tinymce.WPWindowManager is deprecated. Use the default editor.windowManager to open dialogs with inline HTML."),e.features=b,e.params=c,e.windows.push(d),a.nodeChanged(),d.data("wpdialog")||d.wpdialog({title:b.title,width:b.width,height:b.height,modal:!0,dialogClass:"wp-dialog",zIndex:3e5}),d.wpdialog("open"),d.on("wpdialogclose",function(){for(var a=e.windows.length;a--&&a>-1;)e.windows[a]===e.element&&e.windows.splice(a,1)}))),void 0):this.parent.open(b,c)},this.close=function(){return this.features.wpDialog?(this.element.wpdialog("close"),void 0):this.parent.close.apply(this,arguments)}},tinymce.PluginManager.add("wpdialogs",function(a){a.on("init",function(){a.windowManager=new tinymce.WPWindowManager(a)})});