CLICK HERE TO BUY IT TODAY! OR GET IT FREE VIA TRIALPAY  

PHP Demo Application - Source Code

/Framework/Model/Vendor/CkEditor/_source/plugins/contextmenu/plugin.js



/*
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.plugins.add'contextmenu',
{
	    requires : [ 'menu' ],
	    beforeInit : function( editor )
	    {
		        editor.contextMenu = new CKEDITOR.plugins.contextMenueditor );
		        editor.addCommand'contextMenu',
		            {
			                exec : function()
			                    {
				                        editor.contextMenu.showeditor.document.getBody() );
				                    }
			            });
		    }
	});
CKEDITOR.plugins.contextMenu CKEDITOR.tools.createClass(
{
	    $ : function( editor )
	    {
		        this.id 'cke_' CKEDITOR.tools.getNextNumber();
		        this.editor editor;
		        this._.listeners [];
		        this._.functionId CKEDITOR.tools.addFunction( function( commandName )
		            {
			                this._.panel.hide();
			                editor.focus();
			                editor.execCommandcommandName );
			            },
		            this);
		        this.definition =
		        {
			            panel:
			            {
				                className editor.skinClass ' cke_contextmenu',
				                attributes :
				                {
					                    'aria-label' editor.lang.contextmenu.options
					                }
				            }
			        };
		    },
	    :
	    {
		        onMenu : function( offsetParentcorneroffsetXoffsetY )
		        {
			            var menu this._.menu,
			                editor this.editor;
			            if ( menu )
			            {
				                menu.hide();
				                menu.removeAll();
				            }
			            else
			            {
				                menu this._.menu = new CKEDITOR.menueditorthis.definition );
				                menu.onClick CKEDITOR.tools.bind( function( item )
				                {
					                    menu.hide();
					                    if ( item.onClick )
					                        item.onClick();
					                    else if ( item.command )
					                        editor.execCommanditem.command );
					                }, this );
				                menu.onEscape = function( keystroke )
				                {
					                    var parent this.parent;
					                    // 1. If it's sub-menu, restore the last focused item
					                    // of upper level menu.
					                    // 2. In case of a top-menu, close it.
					                    if ( parent )
					                    {
						                        parent._.panel.hideChild();
						                        // Restore parent block item focus.
						                        var parentBlock parent._.panel._.panel._.currentBlock,
						                            parentFocusIndex =  parentBlock._.focusIndex;
						                        parentBlock._.markItemparentFocusIndex );
						                    }
					                    else if ( keystroke == 27 )
					                    {
						                        this.hide();
						                        editor.focus();
						                    }
					                    return false;
					                };
				            }
			            var listeners this._.listeners,
			                includedItems [];
			            var selection this.editor.getSelection(),
			                element selection && selection.getStartElement();
			            menu.onHide CKEDITOR.tools.bind( function()
			                {
				                    menu.onHide null;
				                    if ( CKEDITOR.env.ie )
				                    {
					                        var selection editor.getSelection();
					                        selection && selection.unlock();
					                    }
				                    this.onHide && this.onHide();
				                },
			                this );
			            // Call all listeners, filling the list of items to be displayed.
			            for ( var ;
			 listeners.length ;
			 i++ )
			            {
				                var listenerItems listeners]( elementselection );
				                if ( listenerItems )
				                {
					                    for ( var itemName in listenerItems )
					                    {
						                        var item this.editor.getMenuItemitemName );
						                        if ( item )
						                        {
							                            item.state listenerItemsitemName ];
							                            menu.additem );
							                        }
						                    }
					                }
				            }
			            // Don't show context menu with zero items.
			            menu.items.length && menu.showoffsetParentcorner || ( editor.lang.dir == 'rtl' ), offsetXoffsetY );
			        }
		    },
	    proto :
	    {
		        addTarget : function( elementnativeContextMenuOnCtrl )
		        {
			            // Opera doesn't support 'contextmenu' event, we have duo approaches employed here:
			            // 1. Inherit the 'button override' hack we introduced in v2 (#4530), while this require the Opera browser
			            //  option 'Allow script to detect context menu/right click events' to be always turned on.
			            // 2. Considering the fact that ctrl/meta key is not been occupied
			            //  for multiple range selecting (like Gecko), we use this key
			            //  combination as a fallback for triggering context-menu. (#4530)
			            if ( CKEDITOR.env.opera )
			            {
				                var contextMenuOverrideButton;
				                element.on'mousedown', function( evt )
				                {
					                    evt evt.data;
					                    if ( evt.$.button != )
					                    {
						                        if ( evt.getKeystroke() == CKEDITOR.CTRL )
						                            element.fire'contextmenu'evt );
						                        return;
						                    }
					                    if ( nativeContextMenuOnCtrl
					                         && ( CKEDITOR.env.mac evt.$.metaKey evt.$.ctrlKey ) )
					                        return;
					                    var target evt.getTarget();
					                    if ( !contextMenuOverrideButton )
					                    {
						                        var ownerDoc =  target.getDocument();
						                        contextMenuOverrideButton ownerDoc.createElement'input' ) ;
						                        contextMenuOverrideButton.$.type 'button' ;
						                        ownerDoc.getBody().appendcontextMenuOverrideButton ) ;
						                    }
					                    contextMenuOverrideButton.setAttribute'style''position:absolute;
					top:' + ( evt.$.clientY ) +
					                        'px;
					left:' + ( evt.$.clientX ) +
					                        'px;
					width:5px;
					height:5px;
					opacity:0.01' );
					                } );
				                element.on'mouseup', function ( evt )
				                {
					                    if ( contextMenuOverrideButton )
					                    {
						                        contextMenuOverrideButton.remove();
						                        contextMenuOverrideButton undefined;
						                        // Simulate 'contextmenu' event.
						                        element.fire'contextmenu'evt.data );
						                    }
					                } );
				            }
			            element.on'contextmenu', function( event )
			                {
				                    var domEvent event.data;
				                    if ( nativeContextMenuOnCtrl &&
				                         // Safari on Windows always show 'ctrlKey' as true in 'contextmenu' event,
				                        // which make this property unreliable. (#4826)
				                         CKEDITOR.env.webkit holdCtrlKey : ( CKEDITOR.env.mac domEvent.$.metaKey domEvent.$.ctrlKey ) ) )
				                        return;
				                    // Cancel the browser context menu.
				                    domEvent.preventDefault();
				                    var offsetParent domEvent.getTarget().getDocument().getDocumentElement(),
				                        offsetX domEvent.$.clientX,
				                        offsetY domEvent.$.clientY;
				                    CKEDITOR.tools.setTimeout( function()
				                        {
					                            this.showoffsetParentnulloffsetXoffsetY );
					                        },
				                        0this );
				                },
			                this );
			            if ( CKEDITOR.env.webkit )
			            {
				                var holdCtrlKey,
				                    onKeyDown = function( event )
				                    {
					                        holdCtrlKey CKEDITOR.env.mac event.data.$.metaKey event.data.$.ctrlKey ;
					                    },
				                    resetOnKeyUp = function()
				                    {
					                        holdCtrlKey 0;
					                    };
				                element.on'keydown'onKeyDown );
				                element.on'keyup'resetOnKeyUp );
				                element.on'contextmenu'resetOnKeyUp );
				            }
			        },
		        addListener : function( listenerFn )
		        {
			            this._.listeners.pushlistenerFn );
			        },
		        show : function( offsetParentcorneroffsetXoffsetY )
		        {
			            this.editor.focus();
			            // Selection will be unavailable after context menu shows up
			            // in IE, lock it now.
			            if ( CKEDITOR.env.ie )
			            {
				                var selection this.editor.getSelection();
				                selection && selection.lock();
				            }
			            this._.onMenuoffsetParent || CKEDITOR.document.getDocumentElement(), corneroffsetX || 0offsetY || );
			        }
		    }
	});
/**
 * Whether to show the browser native context menu when the CTRL or the
 * META (Mac) key is pressed while opening the context menu.
 * @name CKEDITOR.config.browserContextMenuOnCtrl
 * @since 3.0.2
 * @type Boolean
 * @default true
 * @example
 * config.browserContextMenuOnCtrl = false;
 */





PHP Demo Source Code Index