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 | * FCKToolbar Class: represents a toolbar in the toolbarset. It is a group of |
---|
22 | * toolbar items. |
---|
23 | */ |
---|
24 | |
---|
25 | var FCKToolbar = function() |
---|
26 | { |
---|
27 | this.Items = new Array() ; |
---|
28 | |
---|
29 | if ( FCK.IECleanup ) |
---|
30 | FCK.IECleanup.AddItem( this, FCKToolbar_Cleanup ) ; |
---|
31 | } |
---|
32 | |
---|
33 | FCKToolbar.prototype.AddItem = function( item ) |
---|
34 | { |
---|
35 | return this.Items[ this.Items.length ] = item ; |
---|
36 | } |
---|
37 | |
---|
38 | FCKToolbar.prototype.AddButton = function( name, label, tooltip, iconPathOrStripInfoArrayOrIndex, style, state ) |
---|
39 | { |
---|
40 | if ( typeof( iconPathOrStripInfoArrayOrIndex ) == 'number' ) |
---|
41 | iconPathOrStripInfoArrayOrIndex = [ this.DefaultIconsStrip, this.DefaultIconSize, iconPathOrStripInfoArrayOrIndex ] ; |
---|
42 | |
---|
43 | var oButton = new FCKToolbarButtonUI( name, label, tooltip, iconPathOrStripInfoArrayOrIndex, style, state ) ; |
---|
44 | oButton._FCKToolbar = this ; |
---|
45 | oButton.OnClick = FCKToolbar_OnItemClick ; |
---|
46 | |
---|
47 | return this.AddItem( oButton ) ; |
---|
48 | } |
---|
49 | |
---|
50 | function FCKToolbar_OnItemClick( item ) |
---|
51 | { |
---|
52 | var oToolbar = item._FCKToolbar ; |
---|
53 | |
---|
54 | if ( oToolbar.OnItemClick ) |
---|
55 | oToolbar.OnItemClick( oToolbar, item ) ; |
---|
56 | } |
---|
57 | |
---|
58 | FCKToolbar.prototype.AddSeparator = function() |
---|
59 | { |
---|
60 | this.AddItem( new FCKToolbarSeparator() ) ; |
---|
61 | } |
---|
62 | |
---|
63 | FCKToolbar.prototype.Create = function( parentElement ) |
---|
64 | { |
---|
65 | if ( this.MainElement ) |
---|
66 | { |
---|
67 | // this._Cleanup() ; |
---|
68 | if ( this.MainElement.parentNode ) |
---|
69 | this.MainElement.parentNode.removeChild( this.MainElement ) ; |
---|
70 | this.MainElement = null ; |
---|
71 | } |
---|
72 | |
---|
73 | var oDoc = FCKTools.GetElementDocument( parentElement ) ; |
---|
74 | |
---|
75 | var e = this.MainElement = oDoc.createElement( 'table' ) ; |
---|
76 | e.className = 'TB_Toolbar' ; |
---|
77 | e.style.styleFloat = e.style.cssFloat = ( FCKLang.Dir == 'ltr' ? 'left' : 'right' ) ; |
---|
78 | e.dir = FCKLang.Dir ; |
---|
79 | e.cellPadding = 0 ; |
---|
80 | e.cellSpacing = 0 ; |
---|
81 | |
---|
82 | this.RowElement = e.insertRow(-1) ; |
---|
83 | |
---|
84 | // Insert the start cell. |
---|
85 | var eCell ; |
---|
86 | |
---|
87 | if ( !this.HideStart ) |
---|
88 | { |
---|
89 | eCell = this.RowElement.insertCell(-1) ; |
---|
90 | eCell.appendChild( oDoc.createElement( 'div' ) ).className = 'TB_Start' ; |
---|
91 | } |
---|
92 | |
---|
93 | for ( var i = 0 ; i < this.Items.length ; i++ ) |
---|
94 | { |
---|
95 | this.Items[i].Create( this.RowElement.insertCell(-1) ) ; |
---|
96 | } |
---|
97 | |
---|
98 | // Insert the ending cell. |
---|
99 | if ( !this.HideEnd ) |
---|
100 | { |
---|
101 | eCell = this.RowElement.insertCell(-1) ; |
---|
102 | eCell.appendChild( oDoc.createElement( 'div' ) ).className = 'TB_End' ; |
---|
103 | } |
---|
104 | |
---|
105 | parentElement.appendChild( e ) ; |
---|
106 | } |
---|
107 | |
---|
108 | function FCKToolbar_Cleanup() |
---|
109 | { |
---|
110 | this.MainElement = null ; |
---|
111 | this.RowElement = null ; |
---|
112 | } |
---|
113 | |
---|
114 | var FCKToolbarSeparator = function() |
---|
115 | {} |
---|
116 | |
---|
117 | FCKToolbarSeparator.prototype.Create = function( parentElement ) |
---|
118 | { |
---|
119 | FCKTools.AppendElement( parentElement, 'div' ).className = 'TB_Separator' ; |
---|
120 | } |
---|