2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
\r
3 * Copyright (C) 2003-2009 Frederico Caldeira Knabben
\r
5 * == BEGIN LICENSE ==
\r
7 * Licensed under the terms of any of the following licenses at your
\r
10 * - GNU General Public License Version 2 or later (the "GPL")
\r
11 * http://www.gnu.org/licenses/gpl.html
\r
13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
\r
14 * http://www.gnu.org/licenses/lgpl.html
\r
16 * - Mozilla Public License Version 1.1 or later (the "MPL")
\r
17 * http://www.mozilla.org/MPL/MPL-1.1.html
\r
21 * FCKToolbarPanelButton Class: represents a special button in the toolbar
\r
22 * that shows a panel when pressed.
\r
25 var FCKToolbarPanelButton = function( commandName, label, tooltip, style, icon )
\r
27 this.CommandName = commandName ;
\r
32 oIcon = FCKConfig.SkinPath + 'toolbar/' + commandName.toLowerCase() + '.gif' ;
\r
33 else if ( typeof( icon ) == 'number' )
\r
34 oIcon = [ FCKConfig.SkinPath + 'fck_strip.gif', 16, icon ] ;
\r
36 var oUIButton = this._UIButton = new FCKToolbarButtonUI( commandName, label, tooltip, oIcon, style ) ;
\r
37 oUIButton._FCKToolbarPanelButton = this ;
\r
38 oUIButton.ShowArrow = true ;
\r
39 oUIButton.OnClick = FCKToolbarPanelButton_OnButtonClick ;
\r
42 FCKToolbarPanelButton.prototype.TypeName = 'FCKToolbarPanelButton' ;
\r
44 FCKToolbarPanelButton.prototype.Create = function( parentElement )
\r
46 parentElement.className += 'Menu' ;
\r
48 this._UIButton.Create( parentElement ) ;
\r
50 var oPanel = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName )._Panel ;
\r
51 this.RegisterPanel( oPanel ) ;
\r
54 FCKToolbarPanelButton.prototype.RegisterPanel = function( oPanel )
\r
56 if ( oPanel._FCKToolbarPanelButton )
\r
59 oPanel._FCKToolbarPanelButton = this ;
\r
61 var eLineDiv = oPanel.Document.body.appendChild( oPanel.Document.createElement( 'div' ) ) ;
\r
62 eLineDiv.style.position = 'absolute' ;
\r
63 eLineDiv.style.top = '0px' ;
\r
65 var eLine = oPanel._FCKToolbarPanelButtonLineDiv = eLineDiv.appendChild( oPanel.Document.createElement( 'IMG' ) ) ;
\r
66 eLine.className = 'TB_ConnectionLine' ;
\r
67 eLine.style.position = 'absolute' ;
\r
68 // eLine.style.backgroundColor = 'Red' ;
\r
69 eLine.src = FCK_SPACER_PATH ;
\r
71 oPanel.OnHide = FCKToolbarPanelButton_OnPanelHide ;
\r
78 function FCKToolbarPanelButton_OnButtonClick( toolbarButton )
\r
80 var oButton = this._FCKToolbarPanelButton ;
\r
81 var e = oButton._UIButton.MainElement ;
\r
83 oButton._UIButton.ChangeState( FCK_TRISTATE_ON ) ;
\r
85 // oButton.LineImg.style.width = ( e.offsetWidth - 2 ) + 'px' ;
\r
87 var oCommand = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( oButton.CommandName ) ;
\r
88 var oPanel = oCommand._Panel ;
\r
89 oPanel._FCKToolbarPanelButtonLineDiv.style.width = ( e.offsetWidth - 2 ) + 'px' ;
\r
90 oCommand.Execute( 0, e.offsetHeight - 1, e ) ; // -1 to be over the border
\r
93 function FCKToolbarPanelButton_OnPanelHide()
\r
95 var oMenuButton = this._FCKToolbarPanelButton ;
\r
96 oMenuButton._UIButton.ChangeState( FCK_TRISTATE_OFF ) ;
\r
99 // The Panel Button works like a normal button so the refresh state functions
\r
100 // defined for the normal button can be reused here.
\r
101 FCKToolbarPanelButton.prototype.RefreshState = FCKToolbarButton.prototype.RefreshState ;
\r
102 FCKToolbarPanelButton.prototype.Enable = FCKToolbarButton.prototype.Enable ;
\r
103 FCKToolbarPanelButton.prototype.Disable = FCKToolbarButton.prototype.Disable ;
\r