2
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
* Copyright (C) 2003-2007 Frederico Caldeira Knabben
7
* Licensed under the terms of any of the following licenses at your
10
* - GNU General Public License Version 2 or later (the "GPL")
11
* http://www.gnu.org/licenses/gpl.html
13
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14
* http://www.gnu.org/licenses/lgpl.html
16
* - Mozilla Public License Version 1.1 or later (the "MPL")
17
* http://www.mozilla.org/MPL/MPL-1.1.html
21
* FCKContextMenu Class: renders an control a context menu.
24
var FCKContextMenu = function( parentWindow, langDir )
26
var oPanel = this._Panel = new FCKPanel( parentWindow, true ) ;
27
oPanel.AppendStyleSheet( FCKConfig.SkinPath + 'fck_editor.css' ) ;
28
oPanel.IsContextMenu = true ;
30
// The FCKTools.DisableSelection doesn't seems to work to avoid dragging of the icons in Mozilla
31
// so we stop the start of the dragging
32
if ( FCKBrowserInfo.IsGecko )
33
oPanel.Document.addEventListener( 'draggesture', function(e) {e.preventDefault(); return false;}, true ) ;
35
var oMenuBlock = this._MenuBlock = new FCKMenuBlock() ;
36
oMenuBlock.Panel = oPanel ;
37
oMenuBlock.OnClick = FCKTools.CreateEventListener( FCKContextMenu_MenuBlock_OnClick, this ) ;
43
FCKContextMenu.prototype.SetMouseClickWindow = function( mouseClickWindow )
45
if ( !FCKBrowserInfo.IsIE )
47
this._Document = mouseClickWindow.document ;
48
this._Document.addEventListener( 'contextmenu', FCKContextMenu_Document_OnContextMenu, false ) ;
52
FCKContextMenu.prototype.AddItem = function( name, label, iconPathOrStripInfoArrayOrIndex, isDisabled )
54
var oItem = this._MenuBlock.AddItem( name, label, iconPathOrStripInfoArrayOrIndex, isDisabled) ;
59
FCKContextMenu.prototype.AddSeparator = function()
61
this._MenuBlock.AddSeparator() ;
65
FCKContextMenu.prototype.RemoveAllItems = function()
67
this._MenuBlock.RemoveAllItems() ;
71
FCKContextMenu.prototype.AttachToElement = function( element )
73
if ( FCKBrowserInfo.IsIE )
74
FCKTools.AddEventListenerEx( element, 'contextmenu', FCKContextMenu_AttachedElement_OnContextMenu, this ) ;
76
element._FCKContextMenu = this ;
78
// element.onmouseup = FCKContextMenu_AttachedElement_OnMouseUp ;
81
function FCKContextMenu_Document_OnContextMenu( e )
87
if ( el._FCKContextMenu )
89
FCKTools.CancelEvent( e ) ;
90
FCKContextMenu_AttachedElement_OnContextMenu( e, el._FCKContextMenu, el ) ;
96
function FCKContextMenu_AttachedElement_OnContextMenu( ev, fckContextMenu, el )
98
// var iButton = e ? e.which - 1 : event.button ;
100
// if ( iButton != 2 )
103
var eTarget = el || this ;
105
if ( fckContextMenu.OnBeforeOpen )
106
fckContextMenu.OnBeforeOpen.call( fckContextMenu, eTarget ) ;
108
if ( fckContextMenu._MenuBlock.Count() == 0 )
111
if ( fckContextMenu._Redraw )
113
fckContextMenu._MenuBlock.Create( fckContextMenu._Panel.MainNode ) ;
114
fckContextMenu._Redraw = false ;
117
// This will avoid that the content of the context menu can be dragged in IE
118
// as the content of the panel is recreated we need to do it every time
119
FCKTools.DisableSelection( fckContextMenu._Panel.Document.body ) ;
121
fckContextMenu._Panel.Show(
122
ev.pageX || ev.screenX,
123
ev.pageY || ev.screenY,
124
ev.currentTarget || null
130
function FCKContextMenu_MenuBlock_OnClick( menuItem, contextMenu )
132
contextMenu._Panel.Hide() ;
133
FCKTools.RunFunction( contextMenu.OnItemClick, contextMenu, menuItem ) ;
b'\\ No newline at end of file'