[389] | 1 | /* |
---|
| 2 | * FCKeditor - The text editor for internet |
---|
| 3 | * Copyright (C) 2003-2006 Frederico Caldeira Knabben |
---|
| 4 | * |
---|
| 5 | * Licensed under the terms of the GNU Lesser General Public License: |
---|
| 6 | * http://www.opensource.org/licenses/lgpl-license.php |
---|
| 7 | * |
---|
| 8 | * For further information visit: |
---|
| 9 | * http://www.fckeditor.net/ |
---|
| 10 | * |
---|
| 11 | * "Support Open Source software. What about a donation today?" |
---|
| 12 | * |
---|
| 13 | * File Name: fcktoolbarpanelbutton.js |
---|
| 14 | * FCKToolbarPanelButton Class: represents a special button in the toolbar |
---|
| 15 | * that shows a panel when pressed. |
---|
| 16 | * |
---|
| 17 | * File Authors: |
---|
| 18 | * Frederico Caldeira Knabben (fredck@fckeditor.net) |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | var FCKToolbarPanelButton = function( commandName, label, tooltip, style, icon ) |
---|
| 22 | { |
---|
| 23 | this.CommandName = commandName ; |
---|
| 24 | |
---|
| 25 | var oIcon ; |
---|
| 26 | |
---|
| 27 | if ( icon == null ) |
---|
| 28 | oIcon = FCKConfig.SkinPath + 'toolbar/' + commandName.toLowerCase() + '.gif' ; |
---|
| 29 | else if ( typeof( icon ) == 'number' ) |
---|
| 30 | oIcon = [ FCKConfig.SkinPath + 'fck_strip.gif', 16, icon ] ; |
---|
| 31 | |
---|
| 32 | var oUIButton = this._UIButton = new FCKToolbarButtonUI( commandName, label, tooltip, oIcon, style ) ; |
---|
| 33 | oUIButton._FCKToolbarPanelButton = this ; |
---|
| 34 | oUIButton.ShowArrow = true ; |
---|
| 35 | oUIButton.OnClick = FCKToolbarPanelButton_OnButtonClick ; |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | FCKToolbarPanelButton.prototype.TypeName = 'FCKToolbarPanelButton' ; |
---|
| 39 | |
---|
| 40 | FCKToolbarPanelButton.prototype.Create = function( parentElement ) |
---|
| 41 | { |
---|
| 42 | parentElement.className += 'Menu' ; |
---|
| 43 | |
---|
| 44 | this._UIButton.Create( parentElement ) ; |
---|
| 45 | |
---|
| 46 | var oPanel = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName )._Panel ; |
---|
| 47 | oPanel._FCKToolbarPanelButton = this ; |
---|
| 48 | |
---|
| 49 | var eLineDiv = oPanel.Document.body.appendChild( oPanel.Document.createElement( 'div' ) ) ; |
---|
| 50 | eLineDiv.style.position = 'absolute' ; |
---|
| 51 | eLineDiv.style.top = '0px' ; |
---|
| 52 | |
---|
| 53 | var eLine = this.LineImg = eLineDiv.appendChild( oPanel.Document.createElement( 'IMG' ) ) ; |
---|
| 54 | eLine.className = 'TB_ConnectionLine' ; |
---|
| 55 | // eLine.style.backgroundColor = 'Red' ; |
---|
| 56 | eLine.src = FCK_SPACER_PATH ; |
---|
| 57 | |
---|
| 58 | oPanel.OnHide = FCKToolbarPanelButton_OnPanelHide ; |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | /* |
---|
| 62 | Events |
---|
| 63 | */ |
---|
| 64 | |
---|
| 65 | function FCKToolbarPanelButton_OnButtonClick( toolbarButton ) |
---|
| 66 | { |
---|
| 67 | var oButton = this._FCKToolbarPanelButton ; |
---|
| 68 | var e = oButton._UIButton.MainElement ; |
---|
| 69 | |
---|
| 70 | oButton._UIButton.ChangeState( FCK_TRISTATE_ON ) ; |
---|
| 71 | |
---|
| 72 | oButton.LineImg.style.width = ( e.offsetWidth - 2 ) + 'px' ; |
---|
| 73 | |
---|
| 74 | FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( oButton.CommandName ).Execute( 0, e.offsetHeight - 1, e ) ; // -1 to be over the border |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | function FCKToolbarPanelButton_OnPanelHide() |
---|
| 78 | { |
---|
| 79 | var oMenuButton = this._FCKToolbarPanelButton ; |
---|
| 80 | oMenuButton._UIButton.ChangeState( FCK_TRISTATE_OFF ) ; |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | // The Panel Button works like a normal button so the refresh state functions |
---|
| 84 | // defined for the normal button can be reused here. |
---|
| 85 | FCKToolbarPanelButton.prototype.RefreshState = FCKToolbarButton.prototype.RefreshState ; |
---|
| 86 | FCKToolbarPanelButton.prototype.Enable = FCKToolbarButton.prototype.Enable ; |
---|
| 87 | FCKToolbarPanelButton.prototype.Disable = FCKToolbarButton.prototype.Disable ; |
---|