[ 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: fckmenublock.js 22 * Renders a list of menu items. 23 * 24 * File Authors: 25 * Frederico Caldeira Knabben (www.fckeditor.net) 26 */ 27 28 29 var FCKMenuBlock = function() 30 { 31 this._Items = new Array() ; 32 } 33 34 35 FCKMenuBlock.prototype.Count = function() 36 { 37 return this._Items.length ; 38 } 39 40 FCKMenuBlock.prototype.AddItem = function( name, label, iconPathOrStripInfoArrayOrIndex, isDisabled ) 41 { 42 var oItem = new FCKMenuItem( this, name, label, iconPathOrStripInfoArrayOrIndex, isDisabled ) ; 43 44 oItem.OnClick = FCKTools.CreateEventListener( FCKMenuBlock_Item_OnClick, this ) ; 45 oItem.OnActivate = FCKTools.CreateEventListener( FCKMenuBlock_Item_OnActivate, this ) ; 46 47 this._Items.push( oItem ) ; 48 49 return oItem ; 50 } 51 52 FCKMenuBlock.prototype.AddSeparator = function() 53 { 54 this._Items.push( new FCKMenuSeparator() ) ; 55 } 56 57 FCKMenuBlock.prototype.RemoveAllItems = function() 58 { 59 this._Items = new Array() ; 60 61 var eItemsTable = this._ItemsTable ; 62 if ( eItemsTable ) 63 { 64 while ( eItemsTable.rows.length > 0 ) 65 eItemsTable.deleteRow( 0 ) ; 66 } 67 } 68 69 FCKMenuBlock.prototype.Create = function( parentElement ) 70 { 71 if ( !this._ItemsTable ) 72 { 73 if ( FCK.IECleanup ) 74 FCK.IECleanup.AddItem( this, FCKMenuBlock_Cleanup ) ; 75 76 this._Window = FCKTools.GetElementWindow( parentElement ) ; 77 78 var oDoc = FCKTools.GetElementDocument( parentElement ) ; 79 80 var eTable = parentElement.appendChild( oDoc.createElement( 'table' ) ) ; 81 eTable.cellPadding = 0 ; 82 eTable.cellSpacing = 0 ; 83 84 FCKTools.DisableSelection( eTable ) ; 85 86 var oMainElement = eTable.insertRow(-1).insertCell(-1) ; 87 oMainElement.className = 'MN_Menu' ; 88 89 var eItemsTable = this._ItemsTable = oMainElement.appendChild( oDoc.createElement( 'table' ) ) ; 90 eItemsTable.cellPadding = 0 ; 91 eItemsTable.cellSpacing = 0 ; 92 } 93 94 for ( var i = 0 ; i < this._Items.length ; i++ ) 95 this._Items[i].Create( this._ItemsTable ) ; 96 } 97 98 /* Events */ 99 100 function FCKMenuBlock_Item_OnClick( clickedItem, menuBlock ) 101 { 102 FCKTools.RunFunction( menuBlock.OnClick, menuBlock, [ clickedItem ] ) ; 103 } 104 105 function FCKMenuBlock_Item_OnActivate( menuBlock ) 106 { 107 var oActiveItem = menuBlock._ActiveItem ; 108 109 if ( oActiveItem && oActiveItem != this ) 110 { 111 // Set the focus to this menu block window (to fire OnBlur on opened panels). 112 if ( !FCKBrowserInfo.IsIE && oActiveItem.HasSubMenu && !this.HasSubMenu ) 113 menuBlock._Window.focus() ; 114 115 oActiveItem.Deactivate() ; 116 } 117 118 menuBlock._ActiveItem = this ; 119 } 120 121 function FCKMenuBlock_Cleanup() 122 { 123 this._Window = null ; 124 this._ItemsTable = null ; 125 } 126 127 // ################# // 128 129 var FCKMenuSeparator = function() 130 {} 131 132 FCKMenuSeparator.prototype.Create = function( parentTable ) 133 { 134 var oDoc = FCKTools.GetElementDocument( parentTable ) ; 135 136 var r = parentTable.insertRow(-1) ; 137 138 var eCell = r.insertCell(-1) ; 139 eCell.className = 'MN_Separator MN_Icon' ; 140 141 eCell = r.insertCell(-1) ; 142 eCell.className = 'MN_Separator' ; 143 eCell.appendChild( oDoc.createElement( 'DIV' ) ).className = 'MN_Separator_Line' ; 144 145 eCell = r.insertCell(-1) ; 146 eCell.className = 'MN_Separator' ; 147 eCell.appendChild( oDoc.createElement( 'DIV' ) ).className = 'MN_Separator_Line' ; 148 }
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 |