[ Index ]

PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09)

title

Body

[close]

/include/inc_ext/fckeditor/editor/dialog/ -> fck_table.html (source)

   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  
  32  var dialog    = window.parent ;
  33  var oEditor = dialog.InnerDialogLoaded() ;
  34  
  35  var FCKDomTools = oEditor.FCKDomTools ;
  36  
  37  // Gets the table if there is one selected.
  38  var table ;
  39  var e = dialog.Selection.GetSelectedElement() ;
  40  var hasColumnHeaders ;
  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  
  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  
 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  
 136      var oDoc = oEditor.FCK.EditorDocument ;
 137      oEditor.FCKUndo.SaveUndoStep() ;
 138  
 139      if ( ! bExists )
 140          table = oDoc.createElement( "TABLE" ) ;
 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 headers = GetE('selHeaders').value ;
 159      if ( bExists )
 160      {
 161          // Should we make a <thead>?
 162          if ( table.tHead==null && (headers=='row' || headers=='both') )
 163          {
 164              var oThead = table.createTHead() ;
 165              var tbody = FCKDomTools.GetFirstChild( table, 'TBODY' ) ;
 166              var theRow= FCKDomTools.GetFirstChild( tbody, 'TR' ) ;
 167  
 168              //now change TD to TH:
 169              for (var i = 0; i<theRow.childNodes.length ; i++)
 170              {
 171                  var th = RenameNode(theRow.childNodes[i], 'TH') ;
 172                  if (th != null)
 173                      th.scope='col' ;
 174              }
 175              oThead.appendChild( theRow ) ;
 176          }
 177  
 178          if ( table.tHead!==null && !(headers=='row' || headers=='both') )
 179          {
 180              // Move the row out of the THead and put it in the TBody:
 181              var tHead = table.tHead ;
 182              var tbody = FCKDomTools.GetFirstChild( table, 'TBODY' ) ;
 183  
 184              var previousFirstRow = tbody.firstChild ;
 185              while ( tHead.firstChild )
 186              {
 187                  var theRow = tHead.firstChild ;
 188                  for (var i = 0; i < theRow.childNodes.length ; i++ )
 189                  {
 190                      var newCell = RenameNode( theRow.childNodes[i], 'TD' ) ;
 191                      if ( newCell != null )
 192                          newCell.removeAttribute( 'scope' ) ;
 193                  }
 194                  tbody.insertBefore( theRow, previousFirstRow ) ;
 195              }
 196              table.removeChild( tHead ) ;
 197          }
 198  
 199          // Should we make all first cells in a row TH?
 200          if ( (!hasColumnHeaders)  && (headers=='col' || headers=='both') )
 201          {
 202              for( var row=0 ; row < table.rows.length ; row++ )
 203              {
 204                  var newCell = RenameNode(table.rows[row].cells[0], 'TH') ;
 205                  if ( newCell != null )
 206                      newCell.scope = 'row' ;
 207              }
 208          }
 209  
 210          // Should we make all first TH-cells in a row make TD? If 'yes' we do it the other way round :-)
 211          if ( (hasColumnHeaders)  && !(headers=='col' || headers=='both') )
 212          {
 213              for( var row=0 ; row < table.rows.length ; row++ )
 214              {
 215                  var oRow = table.rows[row] ;
 216                  if ( oRow.parentNode.nodeName == 'TBODY' )
 217                  {
 218                      var newCell = RenameNode(oRow.cells[0], 'TD') ;
 219                      if (newCell != null)
 220                          newCell.removeAttribute( 'scope' ) ;
 221                  }
 222              }
 223          }
 224      }
 225  
 226      if (! bExists)
 227      {
 228          var iRows = GetE('txtRows').value ;
 229          var iCols = GetE('txtColumns').value ;
 230  
 231          var startRow = 0 ;
 232          // Should we make a <thead> ?
 233          if (headers=='row' || headers=='both')
 234          {
 235              startRow++ ;
 236              var oThead = table.createTHead() ;
 237              var oRow = table.insertRow(-1) ;
 238              oThead.appendChild(oRow);
 239  
 240              for ( var c = 0 ; c < iCols ; c++ )
 241              {
 242                  var oThcell = oDoc.createElement( 'TH' ) ;
 243                  oThcell.scope = 'col' ;
 244                  oRow.appendChild( oThcell ) ;
 245                  if ( oEditor.FCKBrowserInfo.IsGeckoLike )
 246                      oEditor.FCKTools.AppendBogusBr( oThcell ) ;
 247              }
 248          }
 249  
 250          // Opera automatically creates a tbody when a thead has been added
 251          var oTbody = FCKDomTools.GetFirstChild( table, 'TBODY' ) ;
 252          if ( !oTbody )
 253          {
 254              // make TBODY if it doesn't exist
 255              oTbody = oDoc.createElement( 'TBODY' ) ;
 256              table.appendChild( oTbody ) ;
 257          }
 258          for ( var r = startRow ; r < iRows; r++ )
 259          {
 260              var oRow = oDoc.createElement( 'TR' ) ;
 261              oTbody.appendChild(oRow) ;
 262  
 263              var startCol = 0 ;
 264              // Is the first column a header?
 265              if (headers=='col' || headers=='both')
 266              {
 267                  var oThcell = oDoc.createElement( 'TH' ) ;
 268                  oThcell.scope = 'row' ;
 269                  oRow.appendChild( oThcell ) ;
 270                  if ( oEditor.FCKBrowserInfo.IsGeckoLike )
 271                      oEditor.FCKTools.AppendBogusBr( oThcell ) ;
 272  
 273                  startCol++ ;
 274              }
 275              for ( var c = startCol ; c < iCols ; c++ )
 276              {
 277                  // IE will leave the TH at the end of the row if we use now oRow.insertCell(-1)
 278                  var oCell = oDoc.createElement( 'TD' ) ;
 279                  oRow.appendChild( oCell ) ;
 280                  if ( oEditor.FCKBrowserInfo.IsGeckoLike )
 281                      oEditor.FCKTools.AppendBogusBr( oCell ) ;
 282              }
 283          }
 284  
 285          oEditor.FCK.InsertElement( table ) ;
 286      }
 287  
 288      var eCaption = oEditor.FCKDomTools.GetFirstChild( table, 'CAPTION' ) ;
 289  
 290      if ( eCaption && !oEditor.FCKBrowserInfo.IsIE )
 291          eCaption.parentNode.removeChild( eCaption ) ;
 292  
 293      if ( document.getElementById('txtCaption').value != '' )
 294      {
 295          if ( !eCaption || !oEditor.FCKBrowserInfo.IsIE )
 296          {
 297              eCaption = oDoc.createElement( 'CAPTION' ) ;
 298              table.insertBefore( eCaption, table.firstChild ) ;
 299          }
 300  
 301          eCaption.innerHTML = document.getElementById('txtCaption').value ;
 302      }
 303      else if ( bExists && eCaption )
 304      {
 305          // TODO: It causes an IE internal error if using removeChild or
 306          // table.deleteCaption() (see #505).
 307          if ( oEditor.FCKBrowserInfo.IsIE )
 308              eCaption.innerHTML = '' ;
 309      }
 310  
 311      return true ;
 312  }
 313  
 314      </script>
 315  </head>
 316  <body style="overflow: hidden">
 317      <table id="otable" cellspacing="0" cellpadding="0" width="100%" border="0" style="height: 100%">
 318          <tr>
 319              <td>
 320                  <table cellspacing="1" cellpadding="1" width="100%" border="0">
 321                      <tr>
 322                          <td valign="top">
 323                              <table cellspacing="1" cellpadding="0" border="0">
 324                                  <tr>
 325                                      <td>
 326                                          <span fcklang="DlgTableRows">Rows</span>:</td>
 327                                      <td>
 328                                          &nbsp;<input id="txtRows" type="text" maxlength="3" size="2" value="3"
 329                                              onkeypress="return IsDigit(event);" /></td>
 330                                  </tr>
 331                                  <tr>
 332                                      <td>
 333                                          <span fcklang="DlgTableColumns">Columns</span>:</td>
 334                                      <td>
 335                                          &nbsp;<input id="txtColumns" type="text" maxlength="2" size="2" value="2"
 336                                              onkeypress="return IsDigit(event);" /></td>
 337                                  </tr>
 338                                  <tr>
 339                                      <td><span fcklang="DlgTableHeaders">Headers</span>:</td>
 340                                      <td>
 341                                          &nbsp;<select id="selHeaders">
 342                                              <option fcklang="DlgTableHeadersNone" value="">None</option>
 343                                              <option fcklang="DlgTableHeadersRow" value="row">First row</option>
 344                                              <option fcklang="DlgTableHeadersColumn" value="col">First column</option>
 345                                              <option fcklang="DlgTableHeadersBoth" value="both">Both</option>
 346                                          </select>
 347                                      </td>
 348                                  </tr>
 349                                  <tr>
 350                                      <td>
 351                                          <span fcklang="DlgTableBorder">Border size</span>:</td>
 352                                      <td>
 353                                          &nbsp;<input id="txtBorder" type="text" maxlength="2" size="2" value="1"
 354                                              onkeypress="return IsDigit(event);" /></td>
 355                                  </tr>
 356                                  <tr>
 357                                      <td>
 358                                          <span fcklang="DlgTableAlign">Alignment</span>:</td>
 359                                      <td>
 360                                          &nbsp;<select id="selAlignment">
 361                                              <option fcklang="DlgTableAlignNotSet" value="" selected="selected">&lt;Not set&gt;</option>
 362                                              <option fcklang="DlgTableAlignLeft" value="left">Left</option>
 363                                              <option fcklang="DlgTableAlignCenter" value="center">Center</option>
 364                                              <option fcklang="DlgTableAlignRight" value="right">Right</option>
 365                                          </select></td>
 366                                  </tr>
 367                              </table>
 368                          </td>
 369                          <td>
 370                              &nbsp;&nbsp;&nbsp;</td>
 371                          <td align="right" valign="top">
 372                              <table cellspacing="0" cellpadding="0" border="0">
 373                                  <tr>
 374                                      <td>
 375                                          <span fcklang="DlgTableWidth">Width</span>:</td>
 376                                      <td>
 377                                          &nbsp;<input id="txtWidth" type="text" maxlength="4" size="3" value="200"
 378                                              onkeypress="return IsDigit(event);" /></td>
 379                                      <td>
 380                                          &nbsp;<select id="selWidthType">
 381                                              <option fcklang="DlgTableWidthPx" value="pixels" selected="selected">pixels</option>
 382                                              <option fcklang="DlgTableWidthPc" value="percent">percent</option>
 383                                          </select></td>
 384                                  </tr>
 385                                  <tr>
 386                                      <td>
 387                                          <span fcklang="DlgTableHeight">Height</span>:</td>
 388                                      <td>
 389                                          &nbsp;<input id="txtHeight" type="text" maxlength="4" size="3" onkeypress="return IsDigit(event);" /></td>
 390                                      <td>
 391                                          &nbsp;<span fcklang="DlgTableWidthPx">pixels</span></td>
 392                                  </tr>
 393                                  <tr>
 394                                      <td colspan="3">&nbsp;</td>
 395                                  </tr>
 396                                  <tr>
 397                                      <td nowrap="nowrap">
 398                                          <span fcklang="DlgTableCellSpace">Cell spacing</span>:</td>
 399                                      <td>
 400                                          &nbsp;<input id="txtCellSpacing" type="text" maxlength="2" size="2" value="1"
 401                                              onkeypress="return IsDigit(event);" /></td>
 402                                      <td>
 403                                          &nbsp;</td>
 404                                  </tr>
 405                                  <tr>
 406                                      <td nowrap="nowrap">
 407                                          <span fcklang="DlgTableCellPad">Cell padding</span>:</td>
 408                                      <td>
 409                                          &nbsp;<input id="txtCellPadding" type="text" maxlength="2" size="2" value="1"
 410                                              onkeypress="return IsDigit(event);" /></td>
 411                                      <td>
 412                                          &nbsp;</td>
 413                                  </tr>
 414                              </table>
 415                          </td>
 416                      </tr>
 417                  </table>
 418                  <table cellspacing="0" cellpadding="0" width="100%" border="0">
 419                      <tr>
 420                          <td nowrap="nowrap">
 421                              <span fcklang="DlgTableCaption">Caption</span>:&nbsp;</td>
 422                          <td>
 423                              &nbsp;</td>
 424                          <td width="100%" nowrap="nowrap">
 425                              <input id="txtCaption" type="text" style="width: 100%" /></td>
 426                      </tr>
 427                      <tr>
 428                          <td nowrap="nowrap">
 429                              <span fcklang="DlgTableSummary">Summary</span>:&nbsp;</td>
 430                          <td>
 431                              &nbsp;</td>
 432                          <td width="100%" nowrap="nowrap">
 433                              <input id="txtSummary" type="text" style="width: 100%" /></td>
 434                      </tr>
 435                  </table>
 436              </td>
 437          </tr>
 438      </table>
 439  </body>
 440  </html>


Generated: Wed Dec 30 05:55:15 2009 Cross-referenced by PHPXref 0.7