|
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 tinymce.create('tinymce.plugins.WPDialogs', { |
|
13 init : function(ed, url) { |
|
14 tinymce.create('tinymce.WPWindowManager:tinymce.InlineWindowManager', { |
|
15 WPWindowManager : function(ed) { |
|
16 this.parent(ed); |
|
17 }, |
|
18 |
|
19 open : function(f, p) { |
|
20 var t = this, element; |
|
21 |
|
22 if ( ! f.wpDialog ) |
|
23 return this.parent( f, p ); |
|
24 else if ( ! f.id ) |
|
25 return; |
|
26 |
|
27 element = jQuery('#' + f.id); |
|
28 if ( ! element.length ) |
|
29 return; |
|
30 |
|
31 t.features = f; |
|
32 t.params = p; |
|
33 t.onOpen.dispatch(t, f, p); |
|
34 t.element = t.windows[ f.id ] = element; |
|
35 |
|
36 // Store selection |
|
37 t.bookmark = t.editor.selection.getBookmark(1); |
|
38 |
|
39 // Create the dialog if necessary |
|
40 if ( ! element.data('wpdialog') ) { |
|
41 element.wpdialog({ |
|
42 title: f.title, |
|
43 width: f.width, |
|
44 height: f.height, |
|
45 modal: true, |
|
46 dialogClass: 'wp-dialog', |
|
47 zIndex: 300000 |
|
48 }); |
|
49 } |
|
50 |
|
51 element.wpdialog('open'); |
|
52 }, |
|
53 close : function() { |
|
54 if ( ! this.features.wpDialog ) |
|
55 return this.parent.apply( this, arguments ); |
|
56 |
|
57 this.element.wpdialog('close'); |
|
58 } |
|
59 }); |
|
60 |
|
61 // Replace window manager |
|
62 ed.onBeforeRenderUI.add(function() { |
|
63 ed.windowManager = new tinymce.WPWindowManager(ed); |
|
64 }); |
|
65 }, |
|
66 |
|
67 getInfo : function() { |
|
68 return { |
|
69 longname : 'WPDialogs', |
|
70 author : 'WordPress', |
|
71 authorurl : 'http://wordpress.org', |
|
72 infourl : 'http://wordpress.org', |
|
73 version : '0.1' |
|
74 }; |
|
75 } |
|
76 }); |
|
77 |
|
78 // Register plugin |
|
79 tinymce.PluginManager.add('wpdialogs', tinymce.plugins.WPDialogs); |
|
80 })(); |