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 | * FCKToolbarPanelButton Class: represents a special button in the toolbar |
---|
22 | * that shows a panel when pressed. |
---|
23 | */ |
---|
24 | |
---|
25 | var FCKToolbarPanelButton = function( commandName, label, tooltip, style, icon ) |
---|
26 | { |
---|
27 | this.CommandName = commandName ; |
---|
28 | |
---|
29 | var oIcon ; |
---|
30 | |
---|
31 | if ( icon == null ) |
---|
32 | oIcon = FCKConfig.SkinPath + 'toolbar/' + commandName.toLowerCase() + '.gif' ; |
---|
33 | else if ( typeof( icon ) == 'number' ) |
---|
34 | oIcon = [ FCKConfig.SkinPath + 'fck_strip.gif', 16, icon ] ; |
---|
35 | |
---|
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 ; |
---|
40 | } |
---|
41 | |
---|
42 | FCKToolbarPanelButton.prototype.TypeName = 'FCKToolbarPanelButton' ; |
---|
43 | |
---|
44 | FCKToolbarPanelButton.prototype.Create = function( parentElement ) |
---|
45 | { |
---|
46 | parentElement.className += 'Menu' ; |
---|
47 | |
---|
48 | this._UIButton.Create( parentElement ) ; |
---|
49 | |
---|
50 | var oPanel = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName )._Panel ; |
---|
51 | oPanel._FCKToolbarPanelButton = this ; |
---|
52 | |
---|
53 | var eLineDiv = oPanel.Document.body.appendChild( oPanel.Document.createElement( 'div' ) ) ; |
---|
54 | eLineDiv.style.position = 'absolute' ; |
---|
55 | eLineDiv.style.top = '0px' ; |
---|
56 | |
---|
57 | var eLine = this.LineImg = eLineDiv.appendChild( oPanel.Document.createElement( 'IMG' ) ) ; |
---|
58 | eLine.className = 'TB_ConnectionLine' ; |
---|
59 | // eLine.style.backgroundColor = 'Red' ; |
---|
60 | eLine.src = FCK_SPACER_PATH ; |
---|
61 | |
---|
62 | oPanel.OnHide = FCKToolbarPanelButton_OnPanelHide ; |
---|
63 | } |
---|
64 | |
---|
65 | /* |
---|
66 | Events |
---|
67 | */ |
---|
68 | |
---|
69 | function FCKToolbarPanelButton_OnButtonClick( toolbarButton ) |
---|
70 | { |
---|
71 | var oButton = this._FCKToolbarPanelButton ; |
---|
72 | var e = oButton._UIButton.MainElement ; |
---|
73 | |
---|
74 | oButton._UIButton.ChangeState( FCK_TRISTATE_ON ) ; |
---|
75 | |
---|
76 | oButton.LineImg.style.width = ( e.offsetWidth - 2 ) + 'px' ; |
---|
77 | |
---|
78 | FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( oButton.CommandName ).Execute( 0, e.offsetHeight - 1, e ) ; // -1 to be over the border |
---|
79 | } |
---|
80 | |
---|
81 | function FCKToolbarPanelButton_OnPanelHide() |
---|
82 | { |
---|
83 | var oMenuButton = this._FCKToolbarPanelButton ; |
---|
84 | oMenuButton._UIButton.ChangeState( FCK_TRISTATE_OFF ) ; |
---|
85 | } |
---|
86 | |
---|
87 | // The Panel Button works like a normal button so the refresh state functions |
---|
88 | // defined for the normal button can be reused here. |
---|
89 | FCKToolbarPanelButton.prototype.RefreshState = FCKToolbarButton.prototype.RefreshState ; |
---|
90 | FCKToolbarPanelButton.prototype.Enable = FCKToolbarButton.prototype.Enable ; |
---|
91 | FCKToolbarPanelButton.prototype.Disable = FCKToolbarButton.prototype.Disable ; |
---|