summaryrefslogtreecommitdiff
path: root/httemplate/elements/fckeditor/editor/dialog/fck_table.html
blob: 6bb9d11019e2e5d8e0b0131ab86ca607a266dfda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<!--
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 * Copyright (C) 2003-2007 Frederico Caldeira Knabben
 *
 * == BEGIN LICENSE ==
 *
 * Licensed under the terms of any of the following licenses at your
 * choice:
 *
 *  - GNU General Public License Version 2 or later (the "GPL")
 *    http://www.gnu.org/licenses/gpl.html
 *
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 *    http://www.gnu.org/licenses/lgpl.html
 *
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
 *    http://www.mozilla.org/MPL/MPL-1.1.html
 *
 * == END LICENSE ==
 *
 * Table dialog window.
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Table Properties</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="robots" content="noindex, nofollow" />
	<script src="common/fck_dialog_common.js" type="text/javascript"></script>
	<script type="text/javascript">

var oEditor = window.parent.InnerDialogLoaded() ;

// Gets the document DOM
var oDOM = oEditor.FCK.EditorDocument ;

// Gets the table if there is one selected.
var table ;
var e = oEditor.FCKSelection.GetSelectedElement() ;

if ( ( !e && document.location.search.substr(1) == 'Parent' ) || ( e && e.tagName != 'TABLE' ) )
	e = oEditor.FCKSelection.MoveToAncestorNode( 'TABLE' ) ;

if ( e && e.tagName == "TABLE" )
	table = e ;

// Fired when the window loading process is finished. It sets the fields with the
// actual values if a table is selected in the editor.
window.onload = function()
{
	// First of all, translate the dialog box texts
	oEditor.FCKLanguageManager.TranslatePage(document) ;

	if (table)
	{
		document.getElementById('txtRows').value    = table.rows.length ;
		document.getElementById('txtColumns').value = table.rows[0].cells.length ;

		// Gets the value from the Width or the Style attribute
		var iWidth  = (table.style.width  ? table.style.width  : table.width ) ;
		var iHeight = (table.style.height ? table.style.height : table.height ) ;

		if (iWidth.indexOf('%') >= 0)			// Percentual = %
		{
			iWidth = parseInt( iWidth.substr(0,iWidth.length - 1), 10 ) ;
			document.getElementById('selWidthType').value = "percent" ;
		}
		else if (iWidth.indexOf('px') >= 0)		// Style Pixel = px
		{																										  //
			iWidth = iWidth.substr(0,iWidth.length - 2);
			document.getElementById('selWidthType').value = "pixels" ;
		}

		if (iHeight && iHeight.indexOf('px') >= 0)		// Style Pixel = px
			iHeight = iHeight.substr(0,iHeight.length - 2);

		document.getElementById('txtWidth').value		= iWidth || '' ;
		document.getElementById('txtHeight').value		= iHeight || '' ;
		document.getElementById('txtBorder').value		= GetAttribute( table, 'border', '' ) ;
		document.getElementById('selAlignment').value	= GetAttribute( table, 'align', '' ) ;
		document.getElementById('txtCellPadding').value	= GetAttribute( table, 'cellPadding', '' ) ;
		document.getElementById('txtCellSpacing').value	= GetAttribute( table, 'cellSpacing', '' ) ;
		document.getElementById('txtSummary').value     = GetAttribute( table, 'summary', '' ) ;
//		document.getElementById('cmbFontStyle').value	= table.className ;

		if (table.caption) document.getElementById('txtCaption').value = table.caption.innerHTML ;

		document.getElementById('txtRows').disabled    = true ;
		document.getElementById('txtColumns').disabled = true ;
	}

	window.parent.SetOkButton( true ) ;
	window.parent.SetAutoSize( true ) ;
}

// Fired when the user press the OK button
function Ok()
{
	var bExists = ( table != null ) ;

	if ( ! bExists )
		table = oEditor.FCK.EditorDocument.createElement( "TABLE" ) ;

	// Removes the Width and Height styles
	if ( bExists && table.style.width )		table.style.width = null ; //.removeAttribute("width") ;
	if ( bExists && table.style.height )	table.style.height = null ; //.removeAttribute("height") ;

	var sWidth = GetE('txtWidth').value ;
	if ( sWidth.length > 0 && GetE('selWidthType').value == 'percent' )
		sWidth += '%' ;

	SetAttribute( table, 'width'		, sWidth ) ;
	SetAttribute( table, 'height'		, GetE('txtHeight').value ) ;
	SetAttribute( table, 'border'		, GetE('txtBorder').value ) ;
	SetAttribute( table, 'align'		, GetE('selAlignment').value ) ;
	SetAttribute( table, 'cellPadding'	, GetE('txtCellPadding').value ) ;
	SetAttribute( table, 'cellSpacing'	, GetE('txtCellSpacing').value ) ;
	SetAttribute( table, 'summary'		, GetE('txtSummary').value ) ;

	var eCaption = oEditor.FCKDomTools.GetFirstChild( table, 'CAPTION' ) ;

	if ( document.getElementById('txtCaption').value != '')
	{
		if ( !eCaption )
		{
			eCaption = oEditor.FCK.EditorDocument.createElement( 'CAPTION' ) ;
			table.insertBefore( eCaption, table.firstChild ) ;
		}

		eCaption.innerHTML = document.getElementById('txtCaption').value ;
	}
	else if ( bExists && eCaption )
	{
		if ( oEditor.FCKBrowserInfo.IsIE )
			eCaption.innerHTML = '' ;	// TODO: It causes an IE internal error if using removeChild or table.deleteCaption().
		else
			eCaption.parentNode.removeChild( eCaption ) ;
	}

	if (! bExists)
	{
		var iRows = document.getElementById('txtRows').value ;
		var iCols = document.getElementById('txtColumns').value ;

		for ( var r = 0 ; r < iRows ; r++ )
		{
			var oRow = table.insertRow(-1) ;
			for ( var c = 0 ; c < iCols ; c++ )
			{
				var oCell = oRow.insertCell(-1) ;
				if ( oEditor.FCKBrowserInfo.IsGeckoLike )
					oCell.innerHTML = GECKO_BOGUS ;
				//oCell.innerHTML = "&nbsp;" ;
			}
		}

		oEditor.FCKUndo.SaveUndoStep() ;

		oEditor.FCK.InsertElement( table ) ;
	}

	return true ;
}

	</script>
</head>
<body style="overflow: hidden">
	<table id="otable" cellspacing="0" cellpadding="0" width="100%" border="0" style="height: 100%">
		<tr>
			<td>
				<table cellspacing="1" cellpadding="1" width="100%" border="0">
					<tr>
						<td valign="top">
							<table cellspacing="0" cellpadding="0" border="0">
								<tr>
									<td>
										<span fcklang="DlgTableRows">Rows</span>:</td>
									<td>
										&nbsp;<input id="txtRows" type="text" maxlength="3" size="2" value="3" name="txtRows"
											onkeypress="return IsDigit(event);" /></td>
								</tr>
								<tr>
									<td>
										<span fcklang="DlgTableColumns">Columns</span>:</td>
									<td>
										&nbsp;<input id="txtColumns" type="text" maxlength="2" size="2" value="2" name="txtColumns"
											onkeypress="return IsDigit(event);" /></td>
								</tr>
								<tr>
									<td>
										&nbsp;</td>
									<td>
										&nbsp;</td>
								</tr>
								<tr>
									<td>
										<span fcklang="DlgTableBorder">Border size</span>:</td>
									<td>
										&nbsp;<input id="txtBorder" type="text" maxlength="2" size="2" value="1" name="txtBorder"
											onkeypress="return IsDigit(event);" /></td>
								</tr>
								<tr>
									<td>
										<span fcklang="DlgTableAlign">Alignment</span>:</td>
									<td>
										&nbsp;<select id="selAlignment" name="selAlignment">
											<option fcklang="DlgTableAlignNotSet" value="" selected="selected">&lt;Not set&gt;</option>
											<option fcklang="DlgTableAlignLeft" value="left">Left</option>
											<option fcklang="DlgTableAlignCenter" value="center">Center</option>
											<option fcklang="DlgTableAlignRight" value="right">Right</option>
										</select></td>
								</tr>
							</table>
						</td>
						<td>
							&nbsp;&nbsp;&nbsp;</td>
						<td align="right" valign="top">
							<table cellspacing="0" cellpadding="0" border="0">
								<tr>
									<td>
										<span fcklang="DlgTableWidth">Width</span>:</td>
									<td>
										&nbsp;<input id="txtWidth" type="text" maxlength="4" size="3" value="200" name="txtWidth"
											onkeypress="return IsDigit(event);" /></td>
									<td>
										&nbsp;<select id="selWidthType" name="selWidthType">
											<option fcklang="DlgTableWidthPx" value="pixels" selected="selected">pixels</option>
											<option fcklang="DlgTableWidthPc" value="percent">percent</option>
										</select></td>
								</tr>
								<tr>
									<td>
										<span fcklang="DlgTableHeight">Height</span>:</td>
									<td>
										&nbsp;<input id="txtHeight" type="text" maxlength="4" size="3" name="txtHeight" onkeypress="return IsDigit(event);" /></td>
									<td>
										&nbsp;<span fcklang="DlgTableWidthPx">pixels</span></td>
								</tr>
								<tr>
									<td>
										&nbsp;</td>
									<td>
										&nbsp;</td>
									<td>
										&nbsp;</td>
								</tr>
								<tr>
									<td nowrap="nowrap">
										<span fcklang="DlgTableCellSpace">Cell spacing</span>:</td>
									<td>
										&nbsp;<input id="txtCellSpacing" type="text" maxlength="2" size="2" value="1" name="txtCellSpacing"
											onkeypress="return IsDigit(event);" /></td>
									<td>
										&nbsp;</td>
								</tr>
								<tr>
									<td nowrap="nowrap">
										<span fcklang="DlgTableCellPad">Cell padding</span>:</td>
									<td>
										&nbsp;<input id="txtCellPadding" type="text" maxlength="2" size="2" value="1" name="txtCellPadding"
											onkeypress="return IsDigit(event);" /></td>
									<td>
										&nbsp;</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
				<table cellspacing="0" cellpadding="0" width="100%" border="0">
					<tr>
						<td nowrap="nowrap">
							<span fcklang="DlgTableCaption">Caption</span>:&nbsp;</td>
						<td>
							&nbsp;</td>
						<td width="100%" nowrap="nowrap">
							<input id="txtCaption" type="text" style="width: 100%" /></td>
					</tr>
					<tr>
						<td nowrap="nowrap">
							<span fcklang="DlgTableSummary">Summary</span>:&nbsp;</td>
						<td>
							&nbsp;</td>
						<td width="100%" nowrap="nowrap">
							<input id="txtSummary" type="text" style="width: 100%" /></td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</body>
</html>