1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
2<!--
3 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
4 * Copyright (C) 2003-2007 Frederico Caldeira Knabben
5 *
6 * == BEGIN LICENSE ==
7 *
8 * Licensed under the terms of any of the following licenses at your
9 * choice:
10 *
11 *  - GNU General Public License Version 2 or later (the "GPL")
12 *    http://www.gnu.org/licenses/gpl.html
13 *
14 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
15 *    http://www.gnu.org/licenses/lgpl.html
16 *
17 *  - Mozilla Public License Version 1.1 or later (the "MPL")
18 *    http://www.mozilla.org/MPL/MPL-1.1.html
19 *
20 * == END LICENSE ==
21 *
22 * Table dialog window.
23-->
24<html xmlns="http://www.w3.org/1999/xhtml">
25<head>
26	<title>Table Properties</title>
27	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
28	<meta name="robots" content="noindex, nofollow" />
29	<script src="common/fck_dialog_common.js" type="text/javascript"></script>
30	<script type="text/javascript">
31
32var oEditor = window.parent.InnerDialogLoaded() ;
33
34// Gets the document DOM
35var oDOM = oEditor.FCK.EditorDocument ;
36
37// Gets the table if there is one selected.
38var table ;
39var e = oEditor.FCKSelection.GetSelectedElement() ;
40
41if ( ( !e && document.location.search.substr(1) == 'Parent' ) || ( e && e.tagName != 'TABLE' ) )
42	e = oEditor.FCKSelection.MoveToAncestorNode( 'TABLE' ) ;
43
44if ( e && e.tagName == "TABLE" )
45	table = e ;
46
47// Fired when the window loading process is finished. It sets the fields with the
48// actual values if a table is selected in the editor.
49window.onload = function()
50{
51	// First of all, translate the dialog box texts
52	oEditor.FCKLanguageManager.TranslatePage(document) ;
53
54	if (table)
55	{
56		document.getElementById('txtRows').value    = table.rows.length ;
57		document.getElementById('txtColumns').value = table.rows[0].cells.length ;
58
59		// Gets the value from the Width or the Style attribute
60		var iWidth  = (table.style.width  ? table.style.width  : table.width ) ;
61		var iHeight = (table.style.height ? table.style.height : table.height ) ;
62
63		if (iWidth.indexOf('%') >= 0)			// Percentual = %
64		{
65			iWidth = parseInt( iWidth.substr(0,iWidth.length - 1), 10 ) ;
66			document.getElementById('selWidthType').value = "percent" ;
67		}
68		else if (iWidth.indexOf('px') >= 0)		// Style Pixel = px
69		{																										  //
70			iWidth = iWidth.substr(0,iWidth.length - 2);
71			document.getElementById('selWidthType').value = "pixels" ;
72		}
73
74		if (iHeight && iHeight.indexOf('px') >= 0)		// Style Pixel = px
75			iHeight = iHeight.substr(0,iHeight.length - 2);
76
77		document.getElementById('txtWidth').value		= iWidth || '' ;
78		document.getElementById('txtHeight').value		= iHeight || '' ;
79		document.getElementById('txtBorder').value		= GetAttribute( table, 'border', '' ) ;
80		document.getElementById('selAlignment').value	= GetAttribute( table, 'align', '' ) ;
81		document.getElementById('txtCellPadding').value	= GetAttribute( table, 'cellPadding', '' ) ;
82		document.getElementById('txtCellSpacing').value	= GetAttribute( table, 'cellSpacing', '' ) ;
83		document.getElementById('txtSummary').value     = GetAttribute( table, 'summary', '' ) ;
84//		document.getElementById('cmbFontStyle').value	= table.className ;
85
86		var eCaption = oEditor.FCKDomTools.GetFirstChild( table, 'CAPTION' ) ;
87		if ( eCaption ) document.getElementById('txtCaption').value = eCaption.innerHTML ;
88
89		document.getElementById('txtRows').disabled    = true ;
90		document.getElementById('txtColumns').disabled = true ;
91	}
92
93	window.parent.SetOkButton( true ) ;
94	window.parent.SetAutoSize( true ) ;
95}
96
97// Fired when the user press the OK button
98function Ok()
99{
100	var bExists = ( table != null ) ;
101
102	if ( ! bExists )
103		table = oEditor.FCK.EditorDocument.createElement( "TABLE" ) ;
104
105	// Removes the Width and Height styles
106	if ( bExists && table.style.width )		table.style.width = null ; //.removeAttribute("width") ;
107	if ( bExists && table.style.height )	table.style.height = null ; //.removeAttribute("height") ;
108
109	var sWidth = GetE('txtWidth').value ;
110	if ( sWidth.length > 0 && GetE('selWidthType').value == 'percent' )
111		sWidth += '%' ;
112
113	SetAttribute( table, 'width'		, sWidth ) ;
114	SetAttribute( table, 'height'		, GetE('txtHeight').value ) ;
115	SetAttribute( table, 'border'		, GetE('txtBorder').value ) ;
116	SetAttribute( table, 'align'		, GetE('selAlignment').value ) ;
117	SetAttribute( table, 'cellPadding'	, GetE('txtCellPadding').value ) ;
118	SetAttribute( table, 'cellSpacing'	, GetE('txtCellSpacing').value ) ;
119	SetAttribute( table, 'summary'		, GetE('txtSummary').value ) ;
120
121	var eCaption = oEditor.FCKDomTools.GetFirstChild( table, 'CAPTION' ) ;
122
123	if ( document.getElementById('txtCaption').value != '')
124	{
125		if ( !eCaption )
126		{
127			eCaption = oEditor.FCK.EditorDocument.createElement( 'CAPTION' ) ;
128			table.insertBefore( eCaption, table.firstChild ) ;
129		}
130
131		eCaption.innerHTML = document.getElementById('txtCaption').value ;
132	}
133	else if ( bExists && eCaption )
134	{
135		// TODO: It causes an IE internal error if using removeChild or
136		// table.deleteCaption() (see #505).
137		if ( oEditor.FCKBrowserInfo.IsIE )
138			eCaption.innerHTML = '' ;
139		else
140			eCaption.parentNode.removeChild( eCaption ) ;
141	}
142
143	if (! bExists)
144	{
145		var iRows = document.getElementById('txtRows').value ;
146		var iCols = document.getElementById('txtColumns').value ;
147
148		for ( var r = 0 ; r < iRows ; r++ )
149		{
150			var oRow = table.insertRow(-1) ;
151			for ( var c = 0 ; c < iCols ; c++ )
152			{
153				var oCell = oRow.insertCell(-1) ;
154				if ( oEditor.FCKBrowserInfo.IsGeckoLike )
155					oEditor.FCKTools.AppendBogusBr( oCell ) ;
156			}
157		}
158
159		oEditor.FCKUndo.SaveUndoStep() ;
160
161		oEditor.FCK.InsertElement( table ) ;
162	}
163
164	return true ;
165}
166
167	</script>
168</head>
169<body style="overflow: hidden">
170	<table id="otable" cellspacing="0" cellpadding="0" width="100%" border="0" style="height: 100%">
171		<tr>
172			<td>
173				<table cellspacing="1" cellpadding="1" width="100%" border="0">
174					<tr>
175						<td valign="top">
176							<table cellspacing="0" cellpadding="0" border="0">
177								<tr>
178									<td>
179										<span fcklang="DlgTableRows">Rows</span>:</td>
180									<td>
181										&nbsp;<input id="txtRows" type="text" maxlength="3" size="2" value="3" name="txtRows"
182											onkeypress="return IsDigit(event);" /></td>
183								</tr>
184								<tr>
185									<td>
186										<span fcklang="DlgTableColumns">Columns</span>:</td>
187									<td>
188										&nbsp;<input id="txtColumns" type="text" maxlength="2" size="2" value="2" name="txtColumns"
189											onkeypress="return IsDigit(event);" /></td>
190								</tr>
191								<tr>
192									<td>
193										&nbsp;</td>
194									<td>
195										&nbsp;</td>
196								</tr>
197								<tr>
198									<td>
199										<span fcklang="DlgTableBorder">Border size</span>:</td>
200									<td>
201										&nbsp;<input id="txtBorder" type="text" maxlength="2" size="2" value="1" name="txtBorder"
202											onkeypress="return IsDigit(event);" /></td>
203								</tr>
204								<tr>
205									<td>
206										<span fcklang="DlgTableAlign">Alignment</span>:</td>
207									<td>
208										&nbsp;<select id="selAlignment" name="selAlignment">
209											<option fcklang="DlgTableAlignNotSet" value="" selected="selected">&lt;Not set&gt;</option>
210											<option fcklang="DlgTableAlignLeft" value="left">Left</option>
211											<option fcklang="DlgTableAlignCenter" value="center">Center</option>
212											<option fcklang="DlgTableAlignRight" value="right">Right</option>
213										</select></td>
214								</tr>
215							</table>
216						</td>
217						<td>
218							&nbsp;&nbsp;&nbsp;</td>
219						<td align="right" valign="top">
220							<table cellspacing="0" cellpadding="0" border="0">
221								<tr>
222									<td>
223										<span fcklang="DlgTableWidth">Width</span>:</td>
224									<td>
225										&nbsp;<input id="txtWidth" type="text" maxlength="4" size="3" value="200" name="txtWidth"
226											onkeypress="return IsDigit(event);" /></td>
227									<td>
228										&nbsp;<select id="selWidthType" name="selWidthType">
229											<option fcklang="DlgTableWidthPx" value="pixels" selected="selected">pixels</option>
230											<option fcklang="DlgTableWidthPc" value="percent">percent</option>
231										</select></td>
232								</tr>
233								<tr>
234									<td>
235										<span fcklang="DlgTableHeight">Height</span>:</td>
236									<td>
237										&nbsp;<input id="txtHeight" type="text" maxlength="4" size="3" name="txtHeight" onkeypress="return IsDigit(event);" /></td>
238									<td>
239										&nbsp;<span fcklang="DlgTableWidthPx">pixels</span></td>
240								</tr>
241								<tr>
242									<td>
243										&nbsp;</td>
244									<td>
245										&nbsp;</td>
246									<td>
247										&nbsp;</td>
248								</tr>
249								<tr>
250									<td nowrap="nowrap">
251										<span fcklang="DlgTableCellSpace">Cell spacing</span>:</td>
252									<td>
253										&nbsp;<input id="txtCellSpacing" type="text" maxlength="2" size="2" value="1" name="txtCellSpacing"
254											onkeypress="return IsDigit(event);" /></td>
255									<td>
256										&nbsp;</td>
257								</tr>
258								<tr>
259									<td nowrap="nowrap">
260										<span fcklang="DlgTableCellPad">Cell padding</span>:</td>
261									<td>
262										&nbsp;<input id="txtCellPadding" type="text" maxlength="2" size="2" value="1" name="txtCellPadding"
263											onkeypress="return IsDigit(event);" /></td>
264									<td>
265										&nbsp;</td>
266								</tr>
267							</table>
268						</td>
269					</tr>
270				</table>
271				<table cellspacing="0" cellpadding="0" width="100%" border="0">
272					<tr>
273						<td nowrap="nowrap">
274							<span fcklang="DlgTableCaption">Caption</span>:&nbsp;</td>
275						<td>
276							&nbsp;</td>
277						<td width="100%" nowrap="nowrap">
278							<input id="txtCaption" type="text" style="width: 100%" /></td>
279					</tr>
280					<tr>
281						<td nowrap="nowrap">
282							<span fcklang="DlgTableSummary">Summary</span>:&nbsp;</td>
283						<td>
284							&nbsp;</td>
285						<td width="100%" nowrap="nowrap">
286							<input id="txtSummary" type="text" style="width: 100%" /></td>
287					</tr>
288				</table>
289			</td>
290		</tr>
291	</table>
292</body>
293</html>
294