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 201 2007-02-12 15:56:56Z 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('advhr');
10
 
11
var TinyMCE_AdvancedHRPlugin = {
12
	getInfo : function() {
13
		return {
14
			longname : 'Advanced HR',
15
			author : 'Moxiecode Systems AB',
16
			authorurl : 'http://tinymce.moxiecode.com',
17
			infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advhr',
18
			version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
19
		}
20
	},
21
 
22
	getControlHTML : function(cn) {
23
		switch (cn) {
24
			case "advhr":
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);