[ Index ] |
|
Code source de FCKeditor 2.4 |
1 /* 2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net 3 * Copyright (C) 2003-2007 Frederico Caldeira Knabben 4 * 5 * == BEGIN LICENSE == 6 * 7 * Licensed under the terms of any of the following licenses at your 8 * choice: 9 * 10 * - GNU General Public License Version 2 or later (the "GPL") 11 * http://www.gnu.org/licenses/gpl.html 12 * 13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") 14 * http://www.gnu.org/licenses/lgpl.html 15 * 16 * - Mozilla Public License Version 1.1 or later (the "MPL") 17 * http://www.mozilla.org/MPL/MPL-1.1.html 18 * 19 * == END LICENSE == 20 * 21 * File Name: fckcontextmenu.js 22 * FCKContextMenu Class: renders an control a context menu. 23 * 24 * File Authors: 25 * Frederico Caldeira Knabben (www.fckeditor.net) 26 */ 27 28 var FCKContextMenu = function( parentWindow, langDir ) 29 { 30 var oPanel = this._Panel = new FCKPanel( parentWindow, true ) ; 31 oPanel.AppendStyleSheet( FCKConfig.SkinPath + 'fck_editor.css' ) ; 32 oPanel.IsContextMenu = true ; 33 34 var oMenuBlock = this._MenuBlock = new FCKMenuBlock() ; 35 oMenuBlock.Panel = oPanel ; 36 oMenuBlock.OnClick = FCKTools.CreateEventListener( FCKContextMenu_MenuBlock_OnClick, this ) ; 37 38 this._Redraw = true ; 39 } 40 41 42 FCKContextMenu.prototype.SetMouseClickWindow = function( mouseClickWindow ) 43 { 44 if ( !FCKBrowserInfo.IsIE ) 45 { 46 this._Document = mouseClickWindow.document ; 47 this._Document.addEventListener( 'contextmenu', FCKContextMenu_Document_OnContextMenu, false ) ; 48 } 49 } 50 51 FCKContextMenu.prototype.AddItem = function( name, label, iconPathOrStripInfoArrayOrIndex, isDisabled ) 52 { 53 var oItem = this._MenuBlock.AddItem( name, label, iconPathOrStripInfoArrayOrIndex, isDisabled) ; 54 this._Redraw = true ; 55 return oItem ; 56 } 57 58 FCKContextMenu.prototype.AddSeparator = function() 59 { 60 this._MenuBlock.AddSeparator() ; 61 this._Redraw = true ; 62 } 63 64 FCKContextMenu.prototype.RemoveAllItems = function() 65 { 66 this._MenuBlock.RemoveAllItems() ; 67 this._Redraw = true ; 68 } 69 70 FCKContextMenu.prototype.AttachToElement = function( element ) 71 { 72 if ( FCKBrowserInfo.IsIE ) 73 FCKTools.AddEventListenerEx( element, 'contextmenu', FCKContextMenu_AttachedElement_OnContextMenu, this ) ; 74 else 75 element._FCKContextMenu = this ; 76 77 // element.onmouseup = FCKContextMenu_AttachedElement_OnMouseUp ; 78 } 79 80 function FCKContextMenu_Document_OnContextMenu( e ) 81 { 82 var el = e.target ; 83 84 while ( el ) 85 { 86 if ( el._FCKContextMenu ) 87 { 88 FCKTools.CancelEvent( e ) ; 89 FCKContextMenu_AttachedElement_OnContextMenu( e, el._FCKContextMenu, el ) ; 90 } 91 el = el.parentNode ; 92 } 93 } 94 95 function FCKContextMenu_AttachedElement_OnContextMenu( ev, fckContextMenu, el ) 96 { 97 // var iButton = e ? e.which - 1 : event.button ; 98 99 // if ( iButton != 2 ) 100 // return ; 101 102 var eTarget = el || this ; 103 104 if ( fckContextMenu.OnBeforeOpen ) 105 fckContextMenu.OnBeforeOpen.call( fckContextMenu, eTarget ) ; 106 107 if ( fckContextMenu._MenuBlock.Count() == 0 ) 108 return false ; 109 110 if ( fckContextMenu._Redraw ) 111 { 112 fckContextMenu._MenuBlock.Create( fckContextMenu._Panel.MainNode ) ; 113 fckContextMenu._Redraw = false ; 114 } 115 116 fckContextMenu._Panel.Show( 117 ev.pageX || ev.screenX, 118 ev.pageY || ev.screenY, 119 ev.currentTarget || null 120 ) ; 121 122 return false ; 123 } 124 125 function FCKContextMenu_MenuBlock_OnClick( menuItem, contextMenu ) 126 { 127 contextMenu._Panel.Hide() ; 128 FCKTools.RunFunction( contextMenu.OnItemClick, contextMenu, menuItem ) ; 129 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 15:28:05 2007 | par Balluche grâce à PHPXref 0.7 |