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 | * 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 | } |
---|
38 | |
---|
39 | FCKToolbarButton.prototype.Create = function( targetElement ) |
---|
40 | { |
---|
41 | this._UIButton = new FCKToolbarButtonUI( this.CommandName, this.Label, this.Tooltip, this.IconPath, this.Style ) ; |
---|
42 | this._UIButton.OnClick = this.Click ; |
---|
43 | this._UIButton._ToolbarButton = this ; |
---|
44 | this._UIButton.Create( targetElement ) ; |
---|
45 | } |
---|
46 | |
---|
47 | FCKToolbarButton.prototype.RefreshState = function() |
---|
48 | { |
---|
49 | // Gets the actual state. |
---|
50 | var eState = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).GetState() ; |
---|
51 | |
---|
52 | // If there are no state changes than do nothing and return. |
---|
53 | if ( eState == this._UIButton.State ) return ; |
---|
54 | |
---|
55 | // Sets the actual state. |
---|
56 | this._UIButton.ChangeState( eState ) ; |
---|
57 | } |
---|
58 | |
---|
59 | FCKToolbarButton.prototype.Click = function() |
---|
60 | { |
---|
61 | var oToolbarButton = this._ToolbarButton || this ; |
---|
62 | FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( oToolbarButton.CommandName ).Execute() ; |
---|
63 | } |
---|
64 | |
---|
65 | FCKToolbarButton.prototype.Enable = function() |
---|
66 | { |
---|
67 | this.RefreshState() ; |
---|
68 | } |
---|
69 | |
---|
70 | FCKToolbarButton.prototype.Disable = function() |
---|
71 | { |
---|
72 | // Sets the actual state. |
---|
73 | this._UIButton.ChangeState( FCK_TRISTATE_DISABLED ) ; |
---|
74 | } |
---|