d290ec840d2b3d892a619a61a23eaf8bcad72754
[citadel.git] / webcit / tiny_mce / plugins / advlink / editor_plugin_src.js
1 /* Import plugin specific language pack */
2 tinyMCE.importPluginLanguagePack('advlink', 'en,de,sv,zh_cn,cs,fa,fr_ca,fr,pl,pt_br,nl');
3
4 function TinyMCE_advlink_getInfo() {
5         return {
6                 longname : 'Advanced link',
7                 author : 'Moxiecode Systems',
8                 authorurl : 'http://tinymce.moxiecode.com',
9                 infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_advlink.html',
10                 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
11         };
12 };
13
14 function TinyMCE_advlink_getControlHTML(control_name) {
15         switch (control_name) {
16                 case "link":
17                         return '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceAdvLink\');" onmousedown="return false;"><img id="{$editor_id}_advlink" src="{$themeurl}/images/link.gif" title="{$lang_link_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreClass(this);" /></a>';
18         }
19
20         return "";
21 }
22
23 function TinyMCE_advlink_execCommand(editor_id, element, command, user_interface, value) {
24         switch (command) {
25                 case "mceAdvLink":
26                         var anySelection = false;
27                         var inst = tinyMCE.getInstanceById(editor_id);
28                         var focusElm = inst.getFocusElement();
29
30                         if (tinyMCE.selectedElement)
31                                 anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (selectedText && selectedText.length > 0);
32
33                         if (anySelection || (focusElm != null && focusElm.nodeName == "A")) {
34                                 var template = new Array();
35
36                                 template['file']   = '../../plugins/advlink/link.htm';
37                                 template['width']  = 480;
38                                 template['height'] = 400;
39
40                                 // Language specific width and height addons
41                                 template['width']  += tinyMCE.getLang('lang_advlink_delta_width', 0);
42                                 template['height'] += tinyMCE.getLang('lang_advlink_delta_height', 0);
43
44                                 tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"});
45                         }
46
47                         return true;
48         }
49
50         return false;
51 }
52
53 function TinyMCE_advlink_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
54         tinyMCE.switchClassSticky(editor_id + '_advlink', 'mceButtonDisabled', true);
55
56         if (node == null)
57                 return;
58
59         if (any_selection)
60                 tinyMCE.switchClassSticky(editor_id + '_advlink', 'mceButtonNormal', false);
61
62         do {
63                 if (node.nodeName == "A" && tinyMCE.getAttrib(node, 'href') != "")
64                         tinyMCE.switchClassSticky(editor_id + '_advlink', 'mceButtonSelected', false);
65         } while ((node = node.parentNode));
66
67         return true;
68 }