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