3 * Included for back-compat.
4 * The default WindowManager in TinyMCE 4.0 supports three types of dialogs:
5 * - With HTML created from JS.
6 * - With inline HTML (like WPWindowManager).
7 * - Old type iframe based dialogs.
8 * For examples see the default plugins: https://github.com/tinymce/tinymce/tree/master/js/tinymce/plugins
10 tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) {
16 this.parent = editor.windowManager;
19 tinymce.extend( this, this.parent );
21 this.open = function( args, params ) {
26 if ( ! args.wpDialog ) {
27 return this.parent.open.apply( this, arguments );
28 } else if ( ! args.id ) {
32 if ( typeof jQuery === 'undefined' || ! jQuery.wp || ! jQuery.wp.wpdialog ) {
33 // wpdialog.js is not loaded
34 if ( window.console && window.console.error ) {
35 window.console.error('wpdialog.js is not loaded. Please set "wpdialogs" as dependency for your script when calling wp_enqueue_script(). You may also want to enqueue the "wp-jquery-ui-dialog" stylesheet.');
41 wp.$element = $element = jQuery( '#' + args.id );
43 if ( ! $element.length ) {
47 if ( window.console && window.console.log ) {
48 window.console.log('tinymce.WPWindowManager is deprecated. Use the default editor.windowManager to open dialogs with inline HTML.');
54 // Store selection. Takes a snapshot in the FocusManager of the selection before focus is moved to the dialog.
57 // Create the dialog if necessary
58 if ( ! $element.data('wpdialog') ) {
64 dialogClass: 'wp-dialog',
69 $element.wpdialog('open');
71 $element.on( 'wpdialogclose', function() {
72 if ( self.wp.$element ) {
78 this.close = function() {
79 if ( ! this.wp.features || ! this.wp.features.wpDialog ) {
80 return this.parent.close.apply( this, arguments );
83 this.wp.$element.wpdialog('close');
87 tinymce.PluginManager.add( 'wpdialogs', function( editor ) {
88 // Replace window manager
89 editor.on( 'init', function() {
90 editor.windowManager = new tinymce.WPWindowManager( editor );