Вход Регистрация
Файл: fckeditor/editor/_source/classes/fckcontextmenu.js
Строк: 380
<?php

/*
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 * Copyright (C) 2003-2008 Frederico Caldeira Knabben
 *
 * == BEGIN LICENSE ==
 *
 * Licensed under the terms of any of the following licenses at your
 * choice:
 *
 *  - GNU General Public License Version 2 or later (the "GPL")
 *    http://www.gnu.org/licenses/gpl.html
 *
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 *    http://www.gnu.org/licenses/lgpl.html
 *
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
 *    http://www.mozilla.org/MPL/MPL-1.1.html
 *
 * == END LICENSE ==
 *
 * FCKContextMenu Class: renders an control a context menu.
 */

var FCKContextMenu = function( parentWindowlangDir )
{
    
this.CtrlDisable false ;

    var 
oPanel this._Panel = new FCKPanelparentWindow ) ;
    
oPanel.AppendStyleSheetFCKConfig.SkinEditorCSS ) ;
    
oPanel.IsContextMenu true ;

    
// The FCKTools.DisableSelection doesn't seems to work to avoid dragging of the icons in Mozilla
    // so we stop the start of the dragging
    
if ( FCKBrowserInfo.IsGecko )
        
oPanel.Document.addEventListener'draggesture', function(e) {e.preventDefault(); return false;}, true ) ;

    var 
oMenuBlock this._MenuBlock = new FCKMenuBlock() ;
    
oMenuBlock.Panel oPanel ;
    
oMenuBlock.OnClick FCKTools.CreateEventListenerFCKContextMenu_MenuBlock_OnClickthis ) ;

    
this._Redraw true ;
}


FCKContextMenu.prototype.SetMouseClickWindow = function( mouseClickWindow )
{
    if ( !
FCKBrowserInfo.IsIE )
    {
        
this._Document mouseClickWindow.document ;
        if ( 
FCKBrowserInfo.IsOpera && !( 'oncontextmenu' in document.createElement('foo') ) )
        {
            
this._Document.addEventListener'mousedown'FCKContextMenu_Document_OnMouseDownfalse ) ;
            
this._Document.addEventListener'mouseup'FCKContextMenu_Document_OnMouseUpfalse ) ;
        }
        
this._Document.addEventListener'contextmenu'FCKContextMenu_Document_OnContextMenufalse ) ;
    }
}

/**
 The customData parameter is just a value that will be send to the command that is executed,
 so it's possible to reuse the same command for several items just by assigning different data for each one.
*/
FCKContextMenu.prototype.AddItem = function( namelabeliconPathOrStripInfoArrayOrIndexisDisabledcustomData )
{
    var 
oItem this._MenuBlock.AddItemnamelabeliconPathOrStripInfoArrayOrIndexisDisabledcustomData ) ;
    
this._Redraw true ;
    return 
oItem ;
}

FCKContextMenu.prototype.AddSeparator = function()
{
    
this._MenuBlock.AddSeparator() ;
    
this._Redraw true ;
}

FCKContextMenu.prototype.RemoveAllItems = function()
{
    
this._MenuBlock.RemoveAllItems() ;
    
this._Redraw true ;
}

FCKContextMenu.prototype.AttachToElement = function( element )
{
    if ( 
FCKBrowserInfo.IsIE )
        
FCKTools.AddEventListenerExelement'contextmenu'FCKContextMenu_AttachedElement_OnContextMenuthis ) ;
    else
        
element._FCKContextMenu this ;
}

function 
FCKContextMenu_Document_OnContextMenu)
{
    if ( 
FCKConfig.BrowserContextMenu )
        return 
true ;

    var 
el e.target ;

    while ( 
el )
    {
        if ( 
el._FCKContextMenu )
        {
            if ( 
el._FCKContextMenu.CtrlDisable && ( e.ctrlKey || e.metaKey ) )
                return 
true ;

            
FCKTools.CancelEvent) ;
            
FCKContextMenu_AttachedElement_OnContextMenueel._FCKContextMenuel ) ;
            return 
false ;
        }
        
el el.parentNode ;
    }
    return 
true ;
}

var 
FCKContextMenu_OverrideButton ;

function 
FCKContextMenu_Document_OnMouseDown)
{
    if( !
|| e.button != )
        return 
false ;

    if ( 
FCKConfig.BrowserContextMenu )
        return 
true ;

    var 
el e.target ;

    while ( 
el )
    {
        if ( 
el._FCKContextMenu )
        {
            if ( 
el._FCKContextMenu.CtrlDisable && ( e.ctrlKey || e.metaKey ) )
                return 
true ;

            var 
overrideButton FCKContextMenu_OverrideButton ;
            if( !
overrideButton )
            {
                var 
doc FCKTools.GetElementDocumente.target ) ;
                
overrideButton FCKContextMenu_OverrideButton doc.createElement('input') ;
                
overrideButton.type 'button' ;
                var 
buttonHolder doc.createElement('p') ;
                
doc.body.appendChildbuttonHolder ) ;
                
buttonHolder.appendChildoverrideButton ) ;
            }

            
overrideButton.style.cssText 'position:absolute;top:' + ( e.clientY ) +
                
'px;left:' + ( e.clientX ) +
                
'px;width:5px;height:5px;opacity:0.01' ;
        }
        
el el.parentNode ;
    }
    return 
false ;
}

function 
FCKContextMenu_Document_OnMouseUp)
{
    if ( 
FCKConfig.BrowserContextMenu )
        return 
true ;

    var 
overrideButton FCKContextMenu_OverrideButton ;

    if ( 
overrideButton )
    {
        var 
parent overrideButton.parentNode ;
        
parent.parentNode.removeChildparent ) ;
        
FCKContextMenu_OverrideButton undefined ;

        if( 
&& e.button == )
        {
            
FCKContextMenu_Document_OnContextMenu) ;
            return 
false ;
        }
    }
    return 
true ;
}

function 
FCKContextMenu_AttachedElement_OnContextMenuevfckContextMenuel )
{
    if ( ( 
fckContextMenu.CtrlDisable && ( ev.ctrlKey || ev.metaKey ) ) || FCKConfig.BrowserContextMenu )
        return 
true ;

    var 
eTarget el || this ;

    if ( 
fckContextMenu.OnBeforeOpen )
        
fckContextMenu.OnBeforeOpen.callfckContextMenueTarget ) ;

    if ( 
fckContextMenu._MenuBlock.Count() == )
        return 
false ;

    if ( 
fckContextMenu._Redraw )
    {
        
fckContextMenu._MenuBlock.CreatefckContextMenu._Panel.MainNode ) ;
        
fckContextMenu._Redraw false ;
    }

    
// This will avoid that the content of the context menu can be dragged in IE
    // as the content of the panel is recreated we need to do it every time
    
FCKTools.DisableSelectionfckContextMenu._Panel.Document.body ) ;

    var 
;
    var 
;
    if ( 
FCKBrowserInfo.IsIE )
    {
        
ev.screenX ;
        
ev.screenY ;
    }
    else if ( 
FCKBrowserInfo.IsSafari )
    {
        
ev.clientX ;
        
ev.clientY ;
    }
    else
    {
        
ev.pageX ;
        
ev.pageY ;
    }
    
fckContextMenu._Panel.Showxyev.currentTarget || null ) ;

    return 
false ;
}

function 
FCKContextMenu_MenuBlock_OnClickmenuItemcontextMenu )
{
    
contextMenu._Panel.Hide() ;
    
FCKTools.RunFunctioncontextMenu.OnItemClickcontextMenumenuItem ) ;
}
?>
Онлайн: 1
Реклама