source: extensions/FCKEditor/editor/_source/classes/fcktoolbarpanelbutton.js @ 3295

Last change on this file since 3295 was 3295, checked in by patdenice, 15 years ago

New extension added:
FCK Editor (2.0.a)

File size: 3.4 KB
Line 
1/*
2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
3 * Copyright (C) 2003-2009 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
25var 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
42FCKToolbarPanelButton.prototype.TypeName = 'FCKToolbarPanelButton' ;
43
44FCKToolbarPanelButton.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        this.RegisterPanel( oPanel ) ;
52}
53
54FCKToolbarPanelButton.prototype.RegisterPanel = function( oPanel )
55{
56        if ( oPanel._FCKToolbarPanelButton )
57                return ;
58
59        oPanel._FCKToolbarPanelButton = this ;
60
61        var eLineDiv = oPanel.Document.body.appendChild( oPanel.Document.createElement( 'div' ) ) ;
62        eLineDiv.style.position = 'absolute' ;
63        eLineDiv.style.top = '0px' ;
64
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 ;
70
71        oPanel.OnHide = FCKToolbarPanelButton_OnPanelHide ;
72}
73
74/*
75        Events
76*/
77
78function FCKToolbarPanelButton_OnButtonClick( toolbarButton )
79{
80        var oButton = this._FCKToolbarPanelButton ;
81        var e = oButton._UIButton.MainElement ;
82
83        oButton._UIButton.ChangeState( FCK_TRISTATE_ON ) ;
84
85        // oButton.LineImg.style.width = ( e.offsetWidth - 2 ) + 'px' ;
86
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
91}
92
93function FCKToolbarPanelButton_OnPanelHide()
94{
95        var oMenuButton = this._FCKToolbarPanelButton ;
96        oMenuButton._UIButton.ChangeState( FCK_TRISTATE_OFF ) ;
97}
98
99// The Panel Button works like a normal button so the refresh state functions
100// defined for the normal button can be reused here.
101FCKToolbarPanelButton.prototype.RefreshState    = FCKToolbarButton.prototype.RefreshState ;
102FCKToolbarPanelButton.prototype.Enable                  = FCKToolbarButton.prototype.Enable ;
103FCKToolbarPanelButton.prototype.Disable                 = FCKToolbarButton.prototype.Disable ;
Note: See TracBrowser for help on using the repository browser.