+++ /dev/null
-/*\r
- * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
- * Copyright (C) 2003-2009 Frederico Caldeira Knabben\r
- *\r
- * == BEGIN LICENSE ==\r
- *\r
- * Licensed under the terms of any of the following licenses at your\r
- * choice:\r
- *\r
- * - GNU General Public License Version 2 or later (the "GPL")\r
- * http://www.gnu.org/licenses/gpl.html\r
- *\r
- * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
- * http://www.gnu.org/licenses/lgpl.html\r
- *\r
- * - Mozilla Public License Version 1.1 or later (the "MPL")\r
- * http://www.mozilla.org/MPL/MPL-1.1.html\r
- *\r
- * == END LICENSE ==\r
- *\r
- * Defines and renders a menu items in a menu block.\r
- */\r
-\r
-var FCKMenuItem = function( parentMenuBlock, name, label, iconPathOrStripInfoArray, isDisabled, customData )\r
-{\r
- this.Name = name ;\r
- this.Label = label || name ;\r
- this.IsDisabled = isDisabled ;\r
-\r
- this.Icon = new FCKIcon( iconPathOrStripInfoArray ) ;\r
-\r
- this.SubMenu = new FCKMenuBlockPanel() ;\r
- this.SubMenu.Parent = parentMenuBlock ;\r
- this.SubMenu.OnClick = FCKTools.CreateEventListener( FCKMenuItem_SubMenu_OnClick, this ) ;\r
- this.CustomData = customData ;\r
-\r
- if ( FCK.IECleanup )\r
- FCK.IECleanup.AddItem( this, FCKMenuItem_Cleanup ) ;\r
-}\r
-\r
-\r
-FCKMenuItem.prototype.AddItem = function( name, label, iconPathOrStripInfoArrayOrIndex, isDisabled, customData )\r
-{\r
- this.HasSubMenu = true ;\r
- return this.SubMenu.AddItem( name, label, iconPathOrStripInfoArrayOrIndex, isDisabled, customData ) ;\r
-}\r
-\r
-FCKMenuItem.prototype.AddSeparator = function()\r
-{\r
- this.SubMenu.AddSeparator() ;\r
-}\r
-\r
-FCKMenuItem.prototype.Create = function( parentTable )\r
-{\r
- var bHasSubMenu = this.HasSubMenu ;\r
-\r
- var oDoc = FCKTools.GetElementDocument( parentTable ) ;\r
-\r
- // Add a row in the table to hold the menu item.\r
- var r = this.MainElement = parentTable.insertRow(-1) ;\r
- r.className = this.IsDisabled ? 'MN_Item_Disabled' : 'MN_Item' ;\r
-\r
- // Set the row behavior.\r
- if ( !this.IsDisabled )\r
- {\r
- FCKTools.AddEventListenerEx( r, 'mouseover', FCKMenuItem_OnMouseOver, [ this ] ) ;\r
- FCKTools.AddEventListenerEx( r, 'click', FCKMenuItem_OnClick, [ this ] ) ;\r
-\r
- if ( !bHasSubMenu )\r
- FCKTools.AddEventListenerEx( r, 'mouseout', FCKMenuItem_OnMouseOut, [ this ] ) ;\r
- }\r
-\r
- // Create the icon cell.\r
- var eCell = r.insertCell(-1) ;\r
- eCell.className = 'MN_Icon' ;\r
- eCell.appendChild( this.Icon.CreateIconElement( oDoc ) ) ;\r
-\r
- // Create the label cell.\r
- eCell = r.insertCell(-1) ;\r
- eCell.className = 'MN_Label' ;\r
- eCell.noWrap = true ;\r
- eCell.appendChild( oDoc.createTextNode( this.Label ) ) ;\r
-\r
- // Create the arrow cell and setup the sub menu panel (if needed).\r
- eCell = r.insertCell(-1) ;\r
- if ( bHasSubMenu )\r
- {\r
- eCell.className = 'MN_Arrow' ;\r
-\r
- // The arrow is a fixed size image.\r
- var eArrowImg = eCell.appendChild( oDoc.createElement( 'IMG' ) ) ;\r
- eArrowImg.src = FCK_IMAGES_PATH + 'arrow_' + FCKLang.Dir + '.gif' ;\r
- eArrowImg.width = 4 ;\r
- eArrowImg.height = 7 ;\r
-\r
- this.SubMenu.Create() ;\r
- this.SubMenu.Panel.OnHide = FCKTools.CreateEventListener( FCKMenuItem_SubMenu_OnHide, this ) ;\r
- }\r
-}\r
-\r
-FCKMenuItem.prototype.Activate = function()\r
-{\r
- this.MainElement.className = 'MN_Item_Over' ;\r
-\r
- if ( this.HasSubMenu )\r
- {\r
- // Show the child menu block. The ( +2, -2 ) correction is done because\r
- // of the padding in the skin. It is not a good solution because one\r
- // could change the skin and so the final result would not be accurate.\r
- // For now it is ok because we are controlling the skin.\r
- this.SubMenu.Show( this.MainElement.offsetWidth + 2, -2, this.MainElement ) ;\r
- }\r
-\r
- FCKTools.RunFunction( this.OnActivate, this ) ;\r
-}\r
-\r
-FCKMenuItem.prototype.Deactivate = function()\r
-{\r
- this.MainElement.className = 'MN_Item' ;\r
-\r
- if ( this.HasSubMenu )\r
- this.SubMenu.Hide() ;\r
-}\r
-\r
-/* Events */\r
-\r
-function FCKMenuItem_SubMenu_OnClick( clickedItem, listeningItem )\r
-{\r
- FCKTools.RunFunction( listeningItem.OnClick, listeningItem, [ clickedItem ] ) ;\r
-}\r
-\r
-function FCKMenuItem_SubMenu_OnHide( menuItem )\r
-{\r
- menuItem.Deactivate() ;\r
-}\r
-\r
-function FCKMenuItem_OnClick( ev, menuItem )\r
-{\r
- if ( menuItem.HasSubMenu )\r
- menuItem.Activate() ;\r
- else\r
- {\r
- menuItem.Deactivate() ;\r
- FCKTools.RunFunction( menuItem.OnClick, menuItem, [ menuItem ] ) ;\r
- }\r
-}\r
-\r
-function FCKMenuItem_OnMouseOver( ev, menuItem )\r
-{\r
- menuItem.Activate() ;\r
-}\r
-\r
-function FCKMenuItem_OnMouseOut( ev, menuItem )\r
-{\r
- menuItem.Deactivate() ;\r
-}\r
-\r
-function FCKMenuItem_Cleanup()\r
-{\r
- this.MainElement = null ;\r
-}\r