4 * Copyright 2009, Moxiecode Systems AB
5 * Released under LGPL License.
7 * License: http://tinymce.moxiecode.com/license
8 * Contributing: http://tinymce.moxiecode.com/contributing
12 var wpDialogFn = function( fn ) {
14 if ( this.features.wpDialog )
15 return fn.apply( this, arguments );
17 return this.parent.apply( this, arguments );
21 tinymce.create('tinymce.plugins.WPDialogs', {
22 init : function(ed, url) {
23 // Replace window manager
24 ed.onBeforeRenderUI.add(function() {
25 ed.windowManager = new tinymce.WPWindowManager(ed);
29 getInfo : function() {
31 longname : 'WPDialogs',
33 authorurl : 'http://wordpress.org',
34 infourl : 'http://wordpress.org',
40 $(document).ready(function() {
41 $.widget("wp.wpdialog", $.ui.dialog, {
43 // Initialize tinyMCEPopup if it exists.
47 $.ui.dialog.prototype.open.apply( this, arguments );
48 // WebKit leaves focus in the TinyMCE editor unless we shift focus.
50 this._trigger('refresh');
55 tinymce.create('tinymce.WPWindowManager:tinymce.InlineWindowManager', {
56 WPWindowManager : function(ed) {
60 open : function(f, p) {
61 var t = this, element;
62 // Can't use wpDialogFn here; this.features isn't set yet.
64 return this.parent( f, p );
68 element = $('#' + f.id);
69 if ( ! element.length )
74 t.onOpen.dispatch(t, f, p);
75 t.element = t.windows[ f.id ] = element;
78 t.bookmark = t.editor.selection.getBookmark(1);
85 dialogClass: 'wp-dialog',
89 close : wpDialogFn(function() {
90 this.element.wpdialog('close');
95 tinymce.PluginManager.add('wpdialogs', tinymce.plugins.WPDialogs);