[1575] | 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 | * FCKToolbarButton Class: represents a button in the toolbar.
|
---|
| 22 | */
|
---|
| 23 |
|
---|
| 24 | var FCKToolbarButton = function( commandName, label, tooltip, style, sourceView, contextSensitive, icon )
|
---|
| 25 | {
|
---|
| 26 | this.CommandName = commandName ;
|
---|
| 27 | this.Label = label ;
|
---|
| 28 | this.Tooltip = tooltip ;
|
---|
| 29 | this.Style = style ;
|
---|
| 30 | this.SourceView = sourceView ? true : false ;
|
---|
| 31 | this.ContextSensitive = contextSensitive ? true : false ;
|
---|
| 32 |
|
---|
| 33 | if ( icon == null )
|
---|
| 34 | this.IconPath = FCKConfig.SkinPath + 'toolbar/' + commandName.toLowerCase() + '.gif' ;
|
---|
| 35 | else if ( typeof( icon ) == 'number' )
|
---|
| 36 | this.IconPath = [ FCKConfig.SkinPath + 'fck_strip.gif', 16, icon ] ;
|
---|
| 37 | else
|
---|
| 38 | this.IconPath = icon ;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | FCKToolbarButton.prototype.Create = function( targetElement )
|
---|
| 42 | {
|
---|
| 43 | this._UIButton = new FCKToolbarButtonUI( this.CommandName, this.Label, this.Tooltip, this.IconPath, this.Style ) ;
|
---|
| 44 | this._UIButton.OnClick = this.Click ;
|
---|
| 45 | this._UIButton._ToolbarButton = this ;
|
---|
| 46 | this._UIButton.Create( targetElement ) ;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | FCKToolbarButton.prototype.RefreshState = function()
|
---|
| 50 | {
|
---|
| 51 | var uiButton = this._UIButton ;
|
---|
| 52 |
|
---|
| 53 | if ( !uiButton )
|
---|
| 54 | return ;
|
---|
| 55 |
|
---|
| 56 | // Gets the actual state.
|
---|
| 57 | var eState = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).GetState() ;
|
---|
| 58 |
|
---|
| 59 | // If there are no state changes than do nothing and return.
|
---|
| 60 | if ( eState == uiButton.State ) return ;
|
---|
| 61 |
|
---|
| 62 | // Sets the actual state.
|
---|
| 63 | uiButton.ChangeState( eState ) ;
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | FCKToolbarButton.prototype.Click = function()
|
---|
| 67 | {
|
---|
| 68 | var oToolbarButton = this._ToolbarButton || this ;
|
---|
| 69 | FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( oToolbarButton.CommandName ).Execute() ;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | FCKToolbarButton.prototype.Enable = function()
|
---|
| 73 | {
|
---|
| 74 | this.RefreshState() ;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | FCKToolbarButton.prototype.Disable = function()
|
---|
| 78 | {
|
---|
| 79 | // Sets the actual state.
|
---|
| 80 | this._UIButton.ChangeState( FCK_TRISTATE_DISABLED ) ;
|
---|
| 81 | }
|
---|