1 /** |
1 /** |
2 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ |
2 * $Id: editor_plugin_src.js 372 2007-11-11 18:38:50Z 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('advhr'); |
9 tinymce.create('tinymce.plugins.AdvancedHRPlugin', { |
|
10 init : function(ed, url) { |
|
11 // Register commands |
|
12 ed.addCommand('mceAdvancedHr', function() { |
|
13 ed.windowManager.open({ |
|
14 file : url + '/rule.htm', |
|
15 width : 250 + ed.getLang('advhr.delta_width', 0), |
|
16 height : 160 + ed.getLang('advhr.delta_height', 0), |
|
17 inline : 1 |
|
18 }, { |
|
19 plugin_url : url |
|
20 }); |
|
21 }); |
10 |
22 |
11 var TinyMCE_AdvancedHRPlugin = { |
23 // Register buttons |
12 getInfo : function() { |
24 ed.addButton('advhr', { |
13 return { |
25 title : 'advhr.advhr_desc', |
14 longname : 'Advanced HR', |
26 cmd : 'mceAdvancedHr' |
15 author : 'Moxiecode Systems AB', |
27 }); |
16 authorurl : 'http://tinymce.moxiecode.com', |
28 |
17 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advhr', |
29 ed.onNodeChange.add(function(ed, cm, n) { |
18 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion |
30 cm.setActive('advhr', n.nodeName == 'HR'); |
|
31 }); |
|
32 |
|
33 ed.onClick.add(function(ed, e) { |
|
34 e = e.target; |
|
35 |
|
36 if (e.nodeName === 'HR') |
|
37 ed.selection.select(e); |
|
38 }); |
|
39 }, |
|
40 |
|
41 getInfo : function() { |
|
42 return { |
|
43 longname : 'Advanced HR', |
|
44 author : 'Moxiecode Systems AB', |
|
45 authorurl : 'http://tinymce.moxiecode.com', |
|
46 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advhr', |
|
47 version : tinymce.majorVersion + "." + tinymce.minorVersion |
|
48 }; |
19 } |
49 } |
20 }, |
50 }); |
21 |
51 |
22 getControlHTML : function(cn) { |
52 // Register plugin |
23 switch (cn) { |
53 tinymce.PluginManager.add('advhr', tinymce.plugins.AdvancedHRPlugin); |
24 case "advhr": |
54 })(); |
25 return tinyMCE.getButtonHTML(cn, 'lang_insert_advhr_desc', '{$pluginurl}/images/advhr.gif', 'mceAdvancedHr'); |
|
26 } |
|
27 |
|
28 return ""; |
|
29 }, |
|
30 |
|
31 /** |
|
32 * Executes the mceAdvanceHr command. |
|
33 */ |
|
34 execCommand : function(editor_id, element, command, user_interface, value) { |
|
35 // Handle commands |
|
36 switch (command) { |
|
37 case "mceAdvancedHr": |
|
38 var template = new Array(); |
|
39 |
|
40 template['file'] = '../../plugins/advhr/rule.htm'; // Relative to theme |
|
41 template['width'] = 250; |
|
42 template['height'] = 160; |
|
43 |
|
44 template['width'] += tinyMCE.getLang('lang_advhr_delta_width', 0); |
|
45 template['height'] += tinyMCE.getLang('lang_advhr_delta_height', 0); |
|
46 |
|
47 var size = "", width = "", noshade = ""; |
|
48 if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "hr") { |
|
49 tinyMCE.hrElement = tinyMCE.selectedElement; |
|
50 |
|
51 if (tinyMCE.hrElement) { |
|
52 size = tinyMCE.hrElement.getAttribute('size') ? tinyMCE.hrElement.getAttribute('size') : ""; |
|
53 width = tinyMCE.hrElement.getAttribute('width') ? tinyMCE.hrElement.getAttribute('width') : ""; |
|
54 noshade = tinyMCE.hrElement.getAttribute('noshade') ? tinyMCE.hrElement.getAttribute('noshade') : ""; |
|
55 } |
|
56 |
|
57 tinyMCE.openWindow(template, {editor_id : editor_id, size : size, width : width, noshade : noshade, mceDo : 'update'}); |
|
58 } else { |
|
59 if (tinyMCE.isMSIE) { |
|
60 tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false,'<hr />'); |
|
61 } else { |
|
62 tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", size : size, width : width, noshade : noshade, mceDo : 'insert'}); |
|
63 } |
|
64 } |
|
65 |
|
66 return true; |
|
67 } |
|
68 |
|
69 // Pass to next handler in chain |
|
70 return false; |
|
71 }, |
|
72 |
|
73 handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { |
|
74 if (node == null) |
|
75 return; |
|
76 |
|
77 do { |
|
78 if (node.nodeName == "HR") { |
|
79 tinyMCE.switchClass(editor_id + '_advhr', 'mceButtonSelected'); |
|
80 return true; |
|
81 } |
|
82 } while ((node = node.parentNode)); |
|
83 |
|
84 tinyMCE.switchClass(editor_id + '_advhr', 'mceButtonNormal'); |
|
85 |
|
86 return true; |
|
87 } |
|
88 }; |
|
89 |
|
90 tinyMCE.addPlugin("advhr", TinyMCE_AdvancedHRPlugin); |
|