Subversion Repositories Applications.papyrus

Rev

Rev 1925 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1925 jp_milcent 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
2
<!--
3
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
2048 gduche 4
 * Copyright (C) 2003-2009 Frederico Caldeira Knabben
1925 jp_milcent 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
 
32
var dialog	= window.parent ;
33
var oEditor = dialog.InnerDialogLoaded() ;
34
 
2048 gduche 35
var FCKDomTools = oEditor.FCKDomTools ;
1925 jp_milcent 36
 
37
// Gets the table if there is one selected.
38
var table ;
39
var e = dialog.Selection.GetSelectedElement() ;
2048 gduche 40
var hasColumnHeaders ;
1925 jp_milcent 41
 
42
if ( ( !e && document.location.search.substr(1) == 'Parent' ) || ( e && e.tagName != 'TABLE' ) )
43
	e = oEditor.FCKSelection.MoveToAncestorNode( 'TABLE' ) ;
44
 
45
if ( e && e.tagName == "TABLE" )
46
	table = e ;
47
 
48
// Fired when the window loading process is finished. It sets the fields with the
49
// actual values if a table is selected in the editor.
50
window.onload = function()
51
{
52
	// First of all, translate the dialog box texts
53
	oEditor.FCKLanguageManager.TranslatePage(document) ;
54
 
55
	if (table)
56
	{
57
		document.getElementById('txtRows').value    = table.rows.length ;
58
		document.getElementById('txtColumns').value = table.rows[0].cells.length ;
59
 
60
		// Gets the value from the Width or the Style attribute
61
		var iWidth  = (table.style.width  ? table.style.width  : table.width ) ;
62
		var iHeight = (table.style.height ? table.style.height : table.height ) ;
63
 
64
		if (iWidth.indexOf('%') >= 0)			// Percentual = %
65
		{
66
			iWidth = parseInt( iWidth.substr(0,iWidth.length - 1), 10 ) ;
67
			document.getElementById('selWidthType').value = "percent" ;
68
		}
69
		else if (iWidth.indexOf('px') >= 0)		// Style Pixel = px
70
		{																										  //
71
			iWidth = iWidth.substr(0,iWidth.length - 2);
72
			document.getElementById('selWidthType').value = "pixels" ;
73
		}
74
 
75
		if (iHeight && iHeight.indexOf('px') >= 0)		// Style Pixel = px
76
			iHeight = iHeight.substr(0,iHeight.length - 2);
77
 
78
		document.getElementById('txtWidth').value		= iWidth || '' ;
79
		document.getElementById('txtHeight').value		= iHeight || '' ;
80
		document.getElementById('txtBorder').value		= GetAttribute( table, 'border', '' ) ;
81
		document.getElementById('selAlignment').value	= GetAttribute( table, 'align', '' ) ;
82
		document.getElementById('txtCellPadding').value	= GetAttribute( table, 'cellPadding', '' ) ;
83
		document.getElementById('txtCellSpacing').value	= GetAttribute( table, 'cellSpacing', '' ) ;
84
		document.getElementById('txtSummary').value     = GetAttribute( table, 'summary', '' ) ;
85
//		document.getElementById('cmbFontStyle').value	= table.className ;
86
 
87
		var eCaption = oEditor.FCKDomTools.GetFirstChild( table, 'CAPTION' ) ;
88
		if ( eCaption ) document.getElementById('txtCaption').value = eCaption.innerHTML ;
89
 
2048 gduche 90
		hasColumnHeaders = true ;
91
		// Check if all the first cells in every row are TH
92
		for (var row=0; row<table.rows.length; row++)
93
		{
94
			// If just one cell isn't a TH then it isn't a header column
95
			if ( table.rows[row].cells[0].nodeName != 'TH' )
96
			{
97
				hasColumnHeaders = false ;
98
 
99
				break;
100
			}
101
		}
102
 
103
		// Check if the table contains <thead>
104
		if ((table.tHead !== null) )
105
		{
106
			if (hasColumnHeaders)
107
				GetE('selHeaders').value = 'both' ;
108
			else
109
				GetE('selHeaders').value = 'row' ;
110
		}
111
		else
112
		{
113
			if (hasColumnHeaders)
114
				GetE('selHeaders').value = 'col' ;
115
			else
116
				GetE('selHeaders').value = '' ;
117
		}
118
 
119
 
1925 jp_milcent 120
		document.getElementById('txtRows').disabled    = true ;
121
		document.getElementById('txtColumns').disabled = true ;
122
		SelectField( 'txtWidth' ) ;
123
	}
124
	else
125
		SelectField( 'txtRows' ) ;
126
 
127
	dialog.SetOkButton( true ) ;
128
	dialog.SetAutoSize( true ) ;
129
}
130
 
131
// Fired when the user press the OK button
132
function Ok()
133
{
134
	var bExists = ( table != null ) ;
135
 
2048 gduche 136
	var oDoc = oEditor.FCK.EditorDocument ;
137
	oEditor.FCKUndo.SaveUndoStep() ;
138
 
1925 jp_milcent 139
	if ( ! bExists )
2048 gduche 140
		table = oDoc.createElement( "TABLE" ) ;
1925 jp_milcent 141
 
142
	// Removes the Width and Height styles
143
	if ( bExists && table.style.width )		table.style.width = null ; //.removeAttribute("width") ;
144
	if ( bExists && table.style.height )	table.style.height = null ; //.removeAttribute("height") ;
145
 
146
	var sWidth = GetE('txtWidth').value ;
147
	if ( sWidth.length > 0 && GetE('selWidthType').value == 'percent' )
148
		sWidth += '%' ;
149
 
150
	SetAttribute( table, 'width'		, sWidth ) ;
151
	SetAttribute( table, 'height'		, GetE('txtHeight').value ) ;
152
	SetAttribute( table, 'border'		, GetE('txtBorder').value ) ;
153
	SetAttribute( table, 'align'		, GetE('selAlignment').value ) ;
154
	SetAttribute( table, 'cellPadding'	, GetE('txtCellPadding').value ) ;
155
	SetAttribute( table, 'cellSpacing'	, GetE('txtCellSpacing').value ) ;
156
	SetAttribute( table, 'summary'		, GetE('txtSummary').value ) ;
157
 
158
	var eCaption = oEditor.FCKDomTools.GetFirstChild( table, 'CAPTION' ) ;
159
 
160
	if ( document.getElementById('txtCaption').value != '')
161
	{
162
		if ( !eCaption )
163
		{
2048 gduche 164
			eCaption = oDoc.createElement( 'CAPTION' ) ;
1925 jp_milcent 165
			table.insertBefore( eCaption, table.firstChild ) ;
166
		}
167
 
168
		eCaption.innerHTML = document.getElementById('txtCaption').value ;
169
	}
170
	else if ( bExists && eCaption )
171
	{
172
		// TODO: It causes an IE internal error if using removeChild or
173
		// table.deleteCaption() (see #505).
174
		if ( oEditor.FCKBrowserInfo.IsIE )
175
			eCaption.innerHTML = '' ;
176
		else
177
			eCaption.parentNode.removeChild( eCaption ) ;
178
	}
179
 
2048 gduche 180
	var headers = GetE('selHeaders').value ;
181
	if ( bExists )
182
	{
183
		// Should we make a <thead>?
184
		if ( table.tHead==null && (headers=='row' || headers=='both') )
185
		{
186
			var oThead = table.createTHead() ;
187
			var tbody = FCKDomTools.GetFirstChild( table, 'TBODY' ) ;
188
			var theRow= FCKDomTools.GetFirstChild( tbody, 'TR' ) ;
189
 
190
			//now change TD to TH:
191
			for (var i = 0; i<theRow.childNodes.length ; i++)
192
			{
193
				var th = RenameNode(theRow.childNodes[i], 'TH') ;
194
				if (th != null)
195
					th.scope='col' ;
196
			}
197
			oThead.appendChild( theRow ) ;
198
		}
199
 
200
		if ( table.tHead!==null && !(headers=='row' || headers=='both') )
201
		{
202
			// Move the row out of the THead and put it in the TBody:
203
			var tHead = table.tHead ;
204
			var tbody = FCKDomTools.GetFirstChild( table, 'TBODY' ) ;
205
 
206
			var previousFirstRow = tbody.firstChild ;
207
			while ( tHead.firstChild )
208
			{
209
				var theRow = tHead.firstChild ;
210
				for (var i = 0; i < theRow.childNodes.length ; i++ )
211
				{
212
					var newCell = RenameNode( theRow.childNodes[i], 'TD' ) ;
213
					if ( newCell != null )
214
						newCell.removeAttribute( 'scope' ) ;
215
				}
216
				tbody.insertBefore( theRow, previousFirstRow ) ;
217
			}
218
			table.removeChild( tHead ) ;
219
		}
220
 
221
		// Should we make all first cells in a row TH?
222
		if ( (!hasColumnHeaders)  && (headers=='col' || headers=='both') )
223
		{
224
			for( var row=0 ; row < table.rows.length ; row++ )
225
			{
226
				var newCell = RenameNode(table.rows[row].cells[0], 'TH') ;
227
				if ( newCell != null )
228
					newCell.scope = 'row' ;
229
			}
230
		}
231
 
232
		// Should we make all first TH-cells in a row make TD? If 'yes' we do it the other way round :-)
233
		if ( (hasColumnHeaders)  && !(headers=='col' || headers=='both') )
234
		{
235
			for( var row=0 ; row < table.rows.length ; row++ )
236
			{
237
				var oRow = table.rows[row] ;
238
				if ( oRow.parentNode.nodeName == 'TBODY' )
239
				{
240
					var newCell = RenameNode(oRow.cells[0], 'TD') ;
241
					if (newCell != null)
242
						newCell.removeAttribute( 'scope' ) ;
243
				}
244
			}
245
		}
246
	}
247
 
1925 jp_milcent 248
	if (! bExists)
249
	{
2048 gduche 250
		var iRows = GetE('txtRows').value ;
251
		var iCols = GetE('txtColumns').value ;
1925 jp_milcent 252
 
2048 gduche 253
		var startRow = 0 ;
254
		// Should we make a <thead> ?
255
		if (headers=='row' || headers=='both')
1925 jp_milcent 256
		{
2048 gduche 257
			startRow++ ;
258
			var oThead = table.createTHead() ;
1925 jp_milcent 259
			var oRow = table.insertRow(-1) ;
2048 gduche 260
			oThead.appendChild(oRow);
261
 
1925 jp_milcent 262
			for ( var c = 0 ; c < iCols ; c++ )
263
			{
2048 gduche 264
				var oThcell = oDoc.createElement( 'TH' ) ;
265
				oThcell.scope = 'col' ;
266
				oRow.appendChild( oThcell ) ;
1925 jp_milcent 267
				if ( oEditor.FCKBrowserInfo.IsGeckoLike )
2048 gduche 268
					oEditor.FCKTools.AppendBogusBr( oThcell ) ;
269
			}
270
		}
271
 
272
		// Opera automatically creates a tbody when a thead has been added
273
		var oTbody = FCKDomTools.GetFirstChild( table, 'TBODY' ) ;
274
		if ( !oTbody )
275
		{
276
			// make TBODY if it doesn't exist
277
			oTbody = oDoc.createElement( 'TBODY' ) ;
278
			table.appendChild( oTbody ) ;
279
		}
280
		for ( var r = startRow ; r < iRows; r++ )
281
		{
282
			var oRow = oDoc.createElement( 'TR' ) ;
283
			oTbody.appendChild(oRow) ;
284
 
285
			var startCol = 0 ;
286
			// Is the first column a header?
287
			if (headers=='col' || headers=='both')
288
			{
289
				var oThcell = oDoc.createElement( 'TH' ) ;
290
				oThcell.scope = 'row' ;
291
				oRow.appendChild( oThcell ) ;
292
				if ( oEditor.FCKBrowserInfo.IsGeckoLike )
293
					oEditor.FCKTools.AppendBogusBr( oThcell ) ;
294
 
295
				startCol++ ;
296
			}
297
			for ( var c = startCol ; c < iCols ; c++ )
298
			{
299
				// IE will leave the TH at the end of the row if we use now oRow.insertCell(-1)
300
				var oCell = oDoc.createElement( 'TD' ) ;
301
				oRow.appendChild( oCell ) ;
302
				if ( oEditor.FCKBrowserInfo.IsGeckoLike )
1925 jp_milcent 303
					oEditor.FCKTools.AppendBogusBr( oCell ) ;
304
			}
305
		}
306
 
307
		oEditor.FCK.InsertElement( table ) ;
308
	}
309
 
310
	return true ;
311
}
312
 
313
	</script>
314
</head>
315
<body style="overflow: hidden">
316
	<table id="otable" cellspacing="0" cellpadding="0" width="100%" border="0" style="height: 100%">
317
		<tr>
318
			<td>
319
				<table cellspacing="1" cellpadding="1" width="100%" border="0">
320
					<tr>
321
						<td valign="top">
2048 gduche 322
							<table cellspacing="1" cellpadding="0" border="0">
1925 jp_milcent 323
								<tr>
324
									<td>
325
										<span fcklang="DlgTableRows">Rows</span>:</td>
326
									<td>
2048 gduche 327
										&nbsp;<input id="txtRows" type="text" maxlength="3" size="2" value="3"
1925 jp_milcent 328
											onkeypress="return IsDigit(event);" /></td>
329
								</tr>
330
								<tr>
331
									<td>
332
										<span fcklang="DlgTableColumns">Columns</span>:</td>
333
									<td>
2048 gduche 334
										&nbsp;<input id="txtColumns" type="text" maxlength="2" size="2" value="2"
1925 jp_milcent 335
											onkeypress="return IsDigit(event);" /></td>
336
								</tr>
337
								<tr>
2048 gduche 338
									<td><span fcklang="DlgTableHeaders">Headers</span>:</td>
1925 jp_milcent 339
									<td>
2048 gduche 340
										&nbsp;<select id="selHeaders">
341
											<option fcklang="DlgTableHeadersNone" value="">None</option>
342
											<option fcklang="DlgTableHeadersRow" value="row">First row</option>
343
											<option fcklang="DlgTableHeadersColumn" value="col">First column</option>
344
											<option fcklang="DlgTableHeadersBoth" value="both">Both</option>
345
										</select>
346
									</td>
1925 jp_milcent 347
								</tr>
348
								<tr>
349
									<td>
350
										<span fcklang="DlgTableBorder">Border size</span>:</td>
351
									<td>
2048 gduche 352
										&nbsp;<input id="txtBorder" type="text" maxlength="2" size="2" value="1"
1925 jp_milcent 353
											onkeypress="return IsDigit(event);" /></td>
354
								</tr>
355
								<tr>
356
									<td>
357
										<span fcklang="DlgTableAlign">Alignment</span>:</td>
358
									<td>
2048 gduche 359
										&nbsp;<select id="selAlignment">
1925 jp_milcent 360
											<option fcklang="DlgTableAlignNotSet" value="" selected="selected">&lt;Not set&gt;</option>
361
											<option fcklang="DlgTableAlignLeft" value="left">Left</option>
362
											<option fcklang="DlgTableAlignCenter" value="center">Center</option>
363
											<option fcklang="DlgTableAlignRight" value="right">Right</option>
364
										</select></td>
365
								</tr>
366
							</table>
367
						</td>
368
						<td>
369
							&nbsp;&nbsp;&nbsp;</td>
370
						<td align="right" valign="top">
371
							<table cellspacing="0" cellpadding="0" border="0">
372
								<tr>
373
									<td>
374
										<span fcklang="DlgTableWidth">Width</span>:</td>
375
									<td>
2048 gduche 376
										&nbsp;<input id="txtWidth" type="text" maxlength="4" size="3" value="200"
1925 jp_milcent 377
											onkeypress="return IsDigit(event);" /></td>
378
									<td>
2048 gduche 379
										&nbsp;<select id="selWidthType">
1925 jp_milcent 380
											<option fcklang="DlgTableWidthPx" value="pixels" selected="selected">pixels</option>
381
											<option fcklang="DlgTableWidthPc" value="percent">percent</option>
382
										</select></td>
383
								</tr>
384
								<tr>
385
									<td>
386
										<span fcklang="DlgTableHeight">Height</span>:</td>
387
									<td>
2048 gduche 388
										&nbsp;<input id="txtHeight" type="text" maxlength="4" size="3" onkeypress="return IsDigit(event);" /></td>
1925 jp_milcent 389
									<td>
390
										&nbsp;<span fcklang="DlgTableWidthPx">pixels</span></td>
391
								</tr>
392
								<tr>
2048 gduche 393
									<td colspan="3">&nbsp;</td>
1925 jp_milcent 394
								</tr>
395
								<tr>
396
									<td nowrap="nowrap">
397
										<span fcklang="DlgTableCellSpace">Cell spacing</span>:</td>
398
									<td>
2048 gduche 399
										&nbsp;<input id="txtCellSpacing" type="text" maxlength="2" size="2" value="1"
1925 jp_milcent 400
											onkeypress="return IsDigit(event);" /></td>
401
									<td>
402
										&nbsp;</td>
403
								</tr>
404
								<tr>
405
									<td nowrap="nowrap">
406
										<span fcklang="DlgTableCellPad">Cell padding</span>:</td>
407
									<td>
2048 gduche 408
										&nbsp;<input id="txtCellPadding" type="text" maxlength="2" size="2" value="1"
1925 jp_milcent 409
											onkeypress="return IsDigit(event);" /></td>
410
									<td>
411
										&nbsp;</td>
412
								</tr>
413
							</table>
414
						</td>
415
					</tr>
416
				</table>
417
				<table cellspacing="0" cellpadding="0" width="100%" border="0">
418
					<tr>
419
						<td nowrap="nowrap">
420
							<span fcklang="DlgTableCaption">Caption</span>:&nbsp;</td>
421
						<td>
422
							&nbsp;</td>
423
						<td width="100%" nowrap="nowrap">
424
							<input id="txtCaption" type="text" style="width: 100%" /></td>
425
					</tr>
426
					<tr>
427
						<td nowrap="nowrap">
428
							<span fcklang="DlgTableSummary">Summary</span>:&nbsp;</td>
429
						<td>
430
							&nbsp;</td>
431
						<td width="100%" nowrap="nowrap">
432
							<input id="txtSummary" type="text" style="width: 100%" /></td>
433
					</tr>
434
				</table>
435
			</td>
436
		</tr>
437
	</table>
438
</body>
439
</html>