1 /** |
1 /** |
2 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ |
2 * $Id: editor_plugin_src.js 402 2007-11-17 15:48:49Z spocke $ |
3 * |
3 * |
4 * @author Moxiecode |
4 * @author Moxiecode |
5 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. |
5 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. |
6 */ |
6 */ |
7 |
7 |
8 /* Import plugin specific language pack */ |
8 (function() { |
9 tinyMCE.importPluginLanguagePack('style'); |
9 tinymce.create('tinymce.plugins.StylePlugin', { |
|
10 init : function(ed, url) { |
|
11 // Register commands |
|
12 ed.addCommand('mceStyleProps', function() { |
|
13 ed.windowManager.open({ |
|
14 file : url + '/props.htm', |
|
15 width : 480 + ed.getLang('style.delta_width', 0), |
|
16 height : 320 + ed.getLang('style.delta_height', 0), |
|
17 inline : 1 |
|
18 }, { |
|
19 plugin_url : url |
|
20 }); |
|
21 }); |
10 |
22 |
11 var TinyMCE_StylePlugin = { |
23 ed.addCommand('mceSetElementStyle', function(ui, v) { |
12 getInfo : function() { |
24 if (e = ed.selection.getNode()) { |
13 return { |
25 ed.dom.setAttrib(e, 'style', v); |
14 longname : 'Style', |
26 ed.execCommand('mceRepaint'); |
15 author : 'Moxiecode Systems AB', |
27 } |
16 authorurl : 'http://tinymce.moxiecode.com', |
28 }); |
17 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/style', |
|
18 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion |
|
19 }; |
|
20 }, |
|
21 |
29 |
22 getControlHTML : function(cn) { |
30 // Register buttons |
23 switch (cn) { |
31 ed.addButton('styleprops', {title : 'style.desc', cmd : 'mceStyleProps'}); |
24 case "styleprops": |
32 }, |
25 return tinyMCE.getButtonHTML(cn, 'lang_style_styleinfo_desc', '{$pluginurl}/images/styleprops.gif', 'mceStyleProps', true); |
33 |
|
34 getInfo : function() { |
|
35 return { |
|
36 longname : 'Style', |
|
37 author : 'Moxiecode Systems AB', |
|
38 authorurl : 'http://tinymce.moxiecode.com', |
|
39 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/style', |
|
40 version : tinymce.majorVersion + "." + tinymce.minorVersion |
|
41 }; |
26 } |
42 } |
|
43 }); |
27 |
44 |
28 return ""; |
45 // Register plugin |
29 }, |
46 tinymce.PluginManager.add('style', tinymce.plugins.StylePlugin); |
30 |
47 })(); |
31 execCommand : function(editor_id, element, command, user_interface, value) { |
|
32 var e, inst; |
|
33 |
|
34 // Handle commands |
|
35 switch (command) { |
|
36 case "mceStyleProps": |
|
37 TinyMCE_StylePlugin._styleProps(); |
|
38 return true; |
|
39 |
|
40 case "mceSetElementStyle": |
|
41 inst = tinyMCE.getInstanceById(editor_id); |
|
42 e = inst.selection.getFocusElement(); |
|
43 |
|
44 if (e) { |
|
45 e.style.cssText = value; |
|
46 inst.repaint(); |
|
47 } |
|
48 |
|
49 return true; |
|
50 } |
|
51 |
|
52 // Pass to next handler in chain |
|
53 return false; |
|
54 }, |
|
55 |
|
56 handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { |
|
57 if (node.nodeName == 'BODY') |
|
58 tinyMCE.switchClass(editor_id + '_styleprops', 'mceButtonDisabled'); |
|
59 else |
|
60 tinyMCE.switchClass(editor_id + '_styleprops', 'mceButtonNormal'); |
|
61 }, |
|
62 |
|
63 // Private plugin specific methods |
|
64 |
|
65 _styleProps : function() { |
|
66 var e = tinyMCE.selectedInstance.selection.getFocusElement(); |
|
67 |
|
68 if (!e || e.nodeName == 'BODY') |
|
69 return; |
|
70 |
|
71 tinyMCE.openWindow({ |
|
72 file : '../../plugins/style/props.htm', |
|
73 width : 480 + tinyMCE.getLang('lang_style_props_delta_width', 0), |
|
74 height : 320 + tinyMCE.getLang('lang_style_props_delta_height', 0) |
|
75 }, { |
|
76 editor_id : tinyMCE.selectedInstance.editorId, |
|
77 inline : "yes", |
|
78 style_text : e.style.cssText |
|
79 }); |
|
80 } |
|
81 }; |
|
82 |
|
83 tinyMCE.addPlugin("style", TinyMCE_StylePlugin); |
|