/pigeoncms/Plugins/fckeditor/editor/dialog/fck_table.html

http://pigeoncms.googlecode.com/ · HTML · 439 lines · 375 code · 42 blank · 22 comment · 0 complexity · 9d2de2c2e0aec9598f6a6c9661d8cd0e MD5 · raw file

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