Subversion Repositories Sites.tela-botanica.org

Rev

Rev 609 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
420 florian 1
/**
2
 * $Id: editor_plugin_src.js 268 2007-04-28 15:52:59Z spocke $
3
 *
4
 * @author Moxiecode
5
 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
6
 */
7
 
8
/* Import plugin specific language pack */
9
tinyMCE.importPluginLanguagePack('advlink');
10
 
11
var TinyMCE_AdvancedLinkPlugin = {
12
	getInfo : function() {
13
		return {
14
			longname : 'Advanced link',
15
			author : 'Moxiecode Systems AB',
16
			authorurl : 'http://tinymce.moxiecode.com',
17
			infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advlink',
18
			version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
19
		};
20
	},
21
 
22
	initInstance : function(inst) {
23
		inst.addShortcut('ctrl', 'k', 'lang_advlink_desc', 'mceAdvLink');
24
	},
25
 
26
	getControlHTML : function(cn) {
27
		switch (cn) {
28
			case "link":
29
				return tinyMCE.getButtonHTML(cn, 'lang_link_desc', '{$themeurl}/images/link.gif', 'mceAdvLink');
30
		}
31
 
32
		return "";
33
	},
34
 
35
	execCommand : function(editor_id, element, command, user_interface, value) {
36
		switch (command) {
37
			case "mceAdvLink":
38
				var inst = tinyMCE.getInstanceById(editor_id), anySelection = false;
39
				var focusElm = inst.getFocusElement(), selectedText = inst.selection.getSelectedText();
40
 
41
				if (tinyMCE.selectedElement)
42
					anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (selectedText && selectedText.length > 0);
43
 
44
				if (anySelection || (focusElm != null && focusElm.nodeName == "A")) {
45
					tinyMCE.openWindow({
46
						file : '../../plugins/advlink/link.htm',
47
						width : 480 + tinyMCE.getLang('lang_advlink_delta_width', 0),
48
						height : 400 + tinyMCE.getLang('lang_advlink_delta_height', 0)
49
					}, {
50
						editor_id : editor_id,
51
						inline : "yes"
52
					});
53
				}
54
 
55
				return true;
56
		}
57
 
58
		return false;
59
	},
60
 
61
	handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
62
		if (node == null)
63
			return;
64
 
65
		do {
66
			if (node.nodeName == "A" && tinyMCE.getAttrib(node, 'href') != "") {
67
				tinyMCE.switchClass(editor_id + '_advlink', 'mceButtonSelected');
68
				return true;
69
			}
70
		} while ((node = node.parentNode));
71
 
72
		if (any_selection) {
73
			tinyMCE.switchClass(editor_id + '_advlink', 'mceButtonNormal');
74
			return true;
75
		}
76
 
77
		tinyMCE.switchClass(editor_id + '_advlink', 'mceButtonDisabled');
78
 
79
		return true;
80
	}
81
};
82
 
83
tinyMCE.addPlugin("advlink", TinyMCE_AdvancedLinkPlugin);