]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.dev.js
Wordpress 3.1
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / plugins / wpdialogs / editor_plugin.dev.js
1 /**
2  * editor_plugin_src.js
3  *
4  * Copyright 2009, Moxiecode Systems AB
5  * Released under LGPL License.
6  *
7  * License: http://tinymce.moxiecode.com/license
8  * Contributing: http://tinymce.moxiecode.com/contributing
9  */
10
11 (function($) {
12         var wpDialogFn = function( fn ) {
13                 return function() {
14                         if ( this.features.wpDialog )
15                                 return fn.apply( this, arguments );
16                         else
17                                 return this.parent.apply( this, arguments );
18                 };
19         };
20
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);
26                         });
27                 },
28
29                 getInfo : function() {
30                         return {
31                                 longname : 'WPDialogs',
32                                 author : 'WordPress',
33                                 authorurl : 'http://wordpress.org',
34                                 infourl : 'http://wordpress.org',
35                                 version : '0.1'
36                         };
37                 }
38         });
39         
40         $(document).ready(function() {
41                 $.widget("wp.wpdialog", $.ui.dialog, {
42                         open: function() {
43                                 // Initialize tinyMCEPopup if it exists.
44                                 if ( tinyMCEPopup )
45                                         tinyMCEPopup.init();
46                                 // Open the dialog.
47                                 $.ui.dialog.prototype.open.apply( this, arguments );
48                                 // WebKit leaves focus in the TinyMCE editor unless we shift focus.
49                                 this.element.focus();
50                                 this._trigger('refresh');
51                         }
52                 });
53         });
54
55         tinymce.create('tinymce.WPWindowManager:tinymce.InlineWindowManager', {
56                 WPWindowManager : function(ed) {
57                         this.parent(ed);
58                 },
59
60                 open : function(f, p) {
61                         var t = this, element;
62                         // Can't use wpDialogFn here; this.features isn't set yet.
63                         if ( ! f.wpDialog )
64                                 return this.parent( f, p );
65                         else if ( ! f.id )
66                                 return;
67                         
68                         element = $('#' + f.id);
69                         if ( ! element.length )
70                                 return;
71                         
72                         t.features = f;
73                         t.params = p;
74                         t.onOpen.dispatch(t, f, p);
75                         t.element = t.windows[ f.id ] = element;
76                         
77                         // Store selection
78                         t.bookmark = t.editor.selection.getBookmark(1);
79                         
80                         element.wpdialog({
81                                 title: f.title,
82                                 width: f.width,
83                                 height: f.height,
84                                 modal: true,
85                                 dialogClass: 'wp-dialog',
86                                 zIndex: 300000
87                         });
88                 },
89                 close : wpDialogFn(function() {
90                         this.element.wpdialog('close');
91                 })
92         });
93
94         // Register plugin
95         tinymce.PluginManager.add('wpdialogs', tinymce.plugins.WPDialogs);
96 })(jQuery);
97