Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
431 ddelon 1
/*
2
 * FCKeditor - The text editor for internet
3
 * Copyright (C) 2003-2005 Frederico Caldeira Knabben
4
 *
5
 * Licensed under the terms of the GNU Lesser General Public License:
6
 * 		http://www.opensource.org/licenses/lgpl-license.php
7
 *
8
 * For further information visit:
9
 * 		http://www.fckeditor.net/
10
 *
11
 * File Name: fckcontextmenuitem.js
12
 * 	FCKContextMenuItem Class: represents a item in the context menu.
13
 *
14
 * File Authors:
15
 * 		Frederico Caldeira Knabben (fredck@fckeditor.net)
16
 */
17
 
18
var FCKContextMenuItem = function( contextMenu, commandName, label, hasIcon )
19
{
20
	this.ContextMenu	= contextMenu ;
21
	this.Command		= FCKCommands.GetCommand( commandName ) ;
22
	this.Label			= label ? label : commandName ;
23
	this.HasIcon		= hasIcon ? true : false ;
24
}
25
 
26
function FCKContextMenuItem_OnMouseOver()
27
{
28
	if ( this.className != 'CM_Disabled' )
29
		this.className = 'CM_Over' ;
30
}
31
 
32
function FCKContextMenuItem_OnMouseOut()
33
{
34
	if ( this.className != 'CM_Disabled' )
35
		this.className = 'CM_Option' ;
36
}
37
 
38
function FCKContextMenuItem_OnClick()
39
{
40
	if ( this.className != 'CM_Disabled' )
41
	{
42
		this.FCKContextMenuItem.ContextMenu.Hide() ;
43
		this.FCKContextMenuItem.Command.Execute() ;
44
	}
45
	return false ;
46
}
47
 
48
FCKContextMenuItem.prototype.CreateTableRow = function( targetTable )
49
{
50
	// Creates the <TR> element.
51
	this._Row = targetTable.insertRow(-1) ;
52
	this._Row.className = 'CM_Disabled' ;
53
	this._Row.FCKContextMenuItem = this ;
54
 
55
	this._Row.onmouseover	= FCKContextMenuItem_OnMouseOver ;
56
	this._Row.onmouseout	= FCKContextMenuItem_OnMouseOut ;
57
	this._Row.onclick		= FCKContextMenuItem_OnClick ;
58
 
59
	var oCell = this._Row.insertCell(-1) ;
60
	oCell.className = 'CM_Icon' ;
61
 
62
	if ( this.HasIcon ) oCell.innerHTML = '<img alt="" src="' + FCKConfig.SkinPath + 'toolbar/' + this.Command.Name.toLowerCase() + '.gif" width="21" height="20" unselectable="on">' ;
63
 
64
	oCell = this._Row.insertCell(-1) ;
65
	oCell.className		= 'CM_Label' ;
66
	oCell.unselectable	= 'on' ;
67
	oCell.noWrap		= true ;
68
	oCell.innerHTML		= this.Label ;
69
}
70
 
71
FCKContextMenuItem.prototype.SetVisible = function( isVisible )
72
{
73
	this._Row.style.display = isVisible ? '' : 'none' ;
74
}
75
 
76
FCKContextMenuItem.prototype.RefreshState = function()
77
{
78
	switch ( this.Command.GetState() )
79
	{
80
		case FCK_TRISTATE_ON :
81
		case FCK_TRISTATE_OFF :
82
			this._Row.className = 'CM_Option' ;
83
			break ;
84
		default :
85
			this._Row.className = 'CM_Disabled' ;
86
			break ;
87
	}
88
}
89
 
90
/*
91
Sample output.
92
-----------------------------------------
93
<tr class="CM_Disabled">
94
	<td class="CM_Icon"><img alt="" src="icons/cut.gif" width="21" height="20" unselectable="on"></td>
95
	<td class="CM_Label" unselectable="on">Cut</td>
96
</tr>
97
-----------------------------------------
98
<tr class="CM_Option" onmouseover="OnOver(this);" onmouseout="OnOut(this);">
99
	<td class="CM_Icon"></td>
100
	<td class="CM_Label">Do Something</td>
101
</tr>
102
*/