* Upgraded TinyMCE to version 2.0RC3. This fixes a conflict with
[citadel.git] / webcit / tiny_mce / plugins / advhr / editor_plugin_src.js
1 /* Import plugin specific language pack */
2 tinyMCE.importPluginLanguagePack('advhr', 'en,de,sv,zh_cn,cs,fa,fr_ca,fr,pl,pt_br,nl,da,he,no,hu');
3
4 function TinyMCE_advhr_getInfo() {
5         return {
6                 longname : 'Advanced HR',
7                 author : 'Moxiecode Systems',
8                 authorurl : 'http://tinymce.moxiecode.com',
9                 infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_advhr.html',
10                 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
11         };
12 };
13
14 function TinyMCE_advhr_getControlHTML(control_name) {
15     switch (control_name) {
16         case "advhr":
17             return '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceAdvancedHr\');" target="_self" onmousedown="return false;"><img id="{$editor_id}_advhr" src="{$pluginurl}/images/advhr.gif" title="{$lang_insert_advhr_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';
18     }
19
20     return "";
21 }
22
23 /**
24  * Executes the mceAdvanceHr command.
25  */
26 function TinyMCE_advhr_execCommand(editor_id, element, command, user_interface, value) {
27     // Handle commands
28     switch (command) {
29         case "mceAdvancedHr":
30             var template = new Array();
31
32             template['file']   = '../../plugins/advhr/rule.htm'; // Relative to theme
33             template['width']  = 270;
34             template['height'] = 180;
35
36                         template['width']  += tinyMCE.getLang('lang_advhr_delta_width', 0);
37                         template['height'] += tinyMCE.getLang('lang_advhr_delta_height', 0);
38
39             var size = "", width = "", noshade = "";
40             if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "hr"){
41                 tinyMCE.hrElement = tinyMCE.selectedElement;
42                 if (tinyMCE.hrElement) {
43                     size    = tinyMCE.hrElement.getAttribute('size') ? tinyMCE.hrElement.getAttribute('size') : "";
44                     width   = tinyMCE.hrElement.getAttribute('width') ? tinyMCE.hrElement.getAttribute('width') : "";
45                     noshade = tinyMCE.hrElement.getAttribute('noshade') ? tinyMCE.hrElement.getAttribute('noshade') : "";
46                 }
47                 tinyMCE.openWindow(template, {editor_id : editor_id, size : size, width : width, noshade : noshade, mceDo : 'update'});
48             } else {
49                 if (tinyMCE.isMSIE) {
50                     tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false,'<hr />');
51                 } else {
52                     tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", size : size, width : width, noshade : noshade, mceDo : 'insert'});
53                 }
54             }
55                     
56        return true;
57    }
58    // Pass to next handler in chain
59    return false;
60 }
61
62 function TinyMCE_advhr_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
63         tinyMCE.switchClassSticky(editor_id + '_advhr', 'mceButtonNormal');
64
65         if (node == null)
66                 return;
67
68         do {
69                 if (node.nodeName.toLowerCase() == "hr")
70                         tinyMCE.switchClassSticky(editor_id + '_advhr', 'mceButtonSelected');
71         } while ((node = node.parentNode));
72
73         return true;
74 }