source: companies/serpro/expressoMail1_2/js/fckeditor/editor/_source/classes/fckmenublock.js @ 903

Revision 903, 3.4 KB checked in by niltonneto, 15 years ago (diff)

Importacao inicial do Expresso do Serpro

Line 
1/*
2 * FCKeditor - The text editor for internet
3 * Copyright (C) 2003-2006 Frederico Caldeira Knabben
4 *
5 * Licensed under the terms of the GNU Lesser General Public License:
6 *              http://www.opensource.org/licenses/lgpl-license.php
7 *
8 * For further information visit:
9 *              http://www.fckeditor.net/
10 *
11 * "Support Open Source software. What about a donation today?"
12 *
13 * File Name: fckmenublock.js
14 *      Renders a list of menu items.
15 *
16 * File Authors:
17 *              Frederico Caldeira Knabben (fredck@fckeditor.net)
18 */
19
20
21var FCKMenuBlock = function()
22{
23        this._Items     = new Array() ;
24}
25
26
27FCKMenuBlock.prototype.Count = function()
28{
29        return this._Items.length ;
30}
31
32FCKMenuBlock.prototype.AddItem = function( name, label, iconPathOrStripInfoArrayOrIndex, isDisabled )
33{
34        var oItem = new FCKMenuItem( this, name, label, iconPathOrStripInfoArrayOrIndex, isDisabled ) ;
35       
36        oItem.OnClick           = FCKTools.CreateEventListener( FCKMenuBlock_Item_OnClick, this ) ;
37        oItem.OnActivate        = FCKTools.CreateEventListener( FCKMenuBlock_Item_OnActivate, this ) ;
38       
39        this._Items.push( oItem ) ;
40
41        return oItem ;
42}
43
44FCKMenuBlock.prototype.AddSeparator = function()
45{
46        this._Items.push( new FCKMenuSeparator() ) ;
47}
48
49FCKMenuBlock.prototype.RemoveAllItems = function()
50{
51        this._Items = new Array() ;
52       
53        var eItemsTable = this._ItemsTable ;
54        if ( eItemsTable )
55        {
56                while ( eItemsTable.rows.length > 0 )
57                        eItemsTable.deleteRow( 0 ) ;
58        }
59}
60
61FCKMenuBlock.prototype.Create = function( parentElement )
62{
63        if ( !this._ItemsTable )
64        {
65                if ( FCK.IECleanup )
66                        FCK.IECleanup.AddItem( this, FCKMenuBlock_Cleanup ) ;
67
68                this._Window = FCKTools.GetElementWindow( parentElement ) ;
69
70                var oDoc = FCKTools.GetElementDocument( parentElement ) ;
71
72                var eTable = parentElement.appendChild( oDoc.createElement( 'table' ) ) ;
73                eTable.cellPadding = 0 ;
74                eTable.cellSpacing = 0 ;
75
76                FCKTools.DisableSelection( eTable ) ;
77               
78                var oMainElement = eTable.insertRow(-1).insertCell(-1) ;
79                oMainElement.className = 'MN_Menu' ;
80       
81                var eItemsTable = this._ItemsTable = oMainElement.appendChild( oDoc.createElement( 'table' ) ) ;
82                eItemsTable.cellPadding = 0 ;
83                eItemsTable.cellSpacing = 0 ;           
84        }
85       
86        for ( var i = 0 ; i < this._Items.length ; i++ )
87                this._Items[i].Create( this._ItemsTable ) ;
88}
89
90/* Events */
91
92function FCKMenuBlock_Item_OnClick( clickedItem, menuBlock )
93{
94        FCKTools.RunFunction( menuBlock.OnClick, menuBlock, [ clickedItem ] ) ;
95}
96
97function FCKMenuBlock_Item_OnActivate( menuBlock )
98{
99        var oActiveItem = menuBlock._ActiveItem ;
100       
101        if ( oActiveItem && oActiveItem != this )
102        {
103                // Set the focus to this menu block window (to fire OnBlur on opened panels).
104                if ( !FCKBrowserInfo.IsIE && oActiveItem.HasSubMenu && !this.HasSubMenu )
105                        menuBlock._Window.focus() ;
106
107                oActiveItem.Deactivate() ;             
108        }
109
110        menuBlock._ActiveItem = this ;
111}
112
113function FCKMenuBlock_Cleanup()
114{
115        this._Window = null ;
116        this._ItemsTable = null ;
117}
118
119// ################# //
120
121var FCKMenuSeparator = function()
122{}
123
124FCKMenuSeparator.prototype.Create = function( parentTable )
125{
126        var oDoc = FCKTools.GetElementDocument( parentTable ) ;
127
128        var r = parentTable.insertRow(-1) ;
129       
130        var eCell = r.insertCell(-1) ;
131        eCell.className = 'MN_Separator MN_Icon' ;
132
133        eCell = r.insertCell(-1) ;
134        eCell.className = 'MN_Separator' ;
135        eCell.appendChild( oDoc.createElement( 'DIV' ) ).className = 'MN_Separator_Line' ;
136
137        eCell = r.insertCell(-1) ;
138        eCell.className = 'MN_Separator' ;
139        eCell.appendChild( oDoc.createElement( 'DIV' ) ).className = 'MN_Separator_Line' ;
140}
Note: See TracBrowser for help on using the repository browser.