import rt 3.8.7
[freeside.git] / rt / share / html / NoAuth / RichText / FCKeditor / editor / _source / classes / fcktoolbarpanelbutton.js
1 /*\r
2  * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
3  * Copyright (C) 2003-2009 Frederico Caldeira Knabben\r
4  *\r
5  * == BEGIN LICENSE ==\r
6  *\r
7  * Licensed under the terms of any of the following licenses at your\r
8  * choice:\r
9  *\r
10  *  - GNU General Public License Version 2 or later (the "GPL")\r
11  *    http://www.gnu.org/licenses/gpl.html\r
12  *\r
13  *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
14  *    http://www.gnu.org/licenses/lgpl.html\r
15  *\r
16  *  - Mozilla Public License Version 1.1 or later (the "MPL")\r
17  *    http://www.mozilla.org/MPL/MPL-1.1.html\r
18  *\r
19  * == END LICENSE ==\r
20  *\r
21  * FCKToolbarPanelButton Class: represents a special button in the toolbar\r
22  * that shows a panel when pressed.\r
23  */\r
24 \r
25 var FCKToolbarPanelButton = function( commandName, label, tooltip, style, icon )\r
26 {\r
27         this.CommandName = commandName ;\r
28 \r
29         var oIcon ;\r
30 \r
31         if ( icon == null )\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
35 \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
40 }\r
41 \r
42 FCKToolbarPanelButton.prototype.TypeName = 'FCKToolbarPanelButton' ;\r
43 \r
44 FCKToolbarPanelButton.prototype.Create = function( parentElement )\r
45 {\r
46         parentElement.className += 'Menu' ;\r
47 \r
48         this._UIButton.Create( parentElement ) ;\r
49 \r
50         var oPanel = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName )._Panel ;\r
51         this.RegisterPanel( oPanel ) ;\r
52 }\r
53 \r
54 FCKToolbarPanelButton.prototype.RegisterPanel = function( oPanel )\r
55 {\r
56         if ( oPanel._FCKToolbarPanelButton )\r
57                 return ;\r
58 \r
59         oPanel._FCKToolbarPanelButton = this ;\r
60 \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
64 \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
70 \r
71         oPanel.OnHide = FCKToolbarPanelButton_OnPanelHide ;\r
72 }\r
73 \r
74 /*\r
75         Events\r
76 */\r
77 \r
78 function FCKToolbarPanelButton_OnButtonClick( toolbarButton )\r
79 {\r
80         var oButton = this._FCKToolbarPanelButton ;\r
81         var e = oButton._UIButton.MainElement ;\r
82 \r
83         oButton._UIButton.ChangeState( FCK_TRISTATE_ON ) ;\r
84 \r
85         // oButton.LineImg.style.width = ( e.offsetWidth - 2 ) + 'px' ;\r
86 \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
91 }\r
92 \r
93 function FCKToolbarPanelButton_OnPanelHide()\r
94 {\r
95         var oMenuButton = this._FCKToolbarPanelButton ;\r
96         oMenuButton._UIButton.ChangeState( FCK_TRISTATE_OFF ) ;\r
97 }\r
98 \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