[ Index ]
 

Code source de FCKeditor 2.4

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/editor/_source/classes/ -> fcktoolbar.js (source)

   1  /*
   2   * FCKeditor - The text editor for Internet - http://www.fckeditor.net
   3   * Copyright (C) 2003-2007 Frederico Caldeira Knabben
   4   * 
   5   * == BEGIN LICENSE ==
   6   * 
   7   * Licensed under the terms of any of the following licenses at your
   8   * choice:
   9   * 
  10   *  - GNU General Public License Version 2 or later (the "GPL")
  11   *    http://www.gnu.org/licenses/gpl.html
  12   * 
  13   *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  14   *    http://www.gnu.org/licenses/lgpl.html
  15   * 
  16   *  - Mozilla Public License Version 1.1 or later (the "MPL")
  17   *    http://www.mozilla.org/MPL/MPL-1.1.html
  18   * 
  19   * == END LICENSE ==
  20   * 
  21   * File Name: fcktoolbar.js
  22   *     FCKToolbar Class: represents a toolbar in the toolbarset. It is a group of
  23   *     toolbar items.
  24   * 
  25   * File Authors:
  26   *         Frederico Caldeira Knabben (www.fckeditor.net)
  27   */
  28  
  29  var FCKToolbar = function()
  30  {
  31      this.Items = new Array() ;
  32  
  33      if ( FCK.IECleanup )
  34          FCK.IECleanup.AddItem( this, FCKToolbar_Cleanup ) ;
  35  }
  36  
  37  FCKToolbar.prototype.AddItem = function( item )
  38  {
  39      return this.Items[ this.Items.length ] = item ;
  40  }
  41  
  42  FCKToolbar.prototype.AddButton = function( name, label, tooltip, iconPathOrStripInfoArrayOrIndex, style, state )
  43  {
  44      if ( typeof( iconPathOrStripInfoArrayOrIndex ) == 'number' )
  45           iconPathOrStripInfoArrayOrIndex = [ this.DefaultIconsStrip, this.DefaultIconSize, iconPathOrStripInfoArrayOrIndex ] ;
  46  
  47      var oButton = new FCKToolbarButtonUI( name, label, tooltip, iconPathOrStripInfoArrayOrIndex, style, state ) ;
  48      oButton._FCKToolbar = this ;
  49      oButton.OnClick = FCKToolbar_OnItemClick ;
  50      
  51      return this.AddItem( oButton ) ;
  52  }
  53  
  54  function FCKToolbar_OnItemClick( item )
  55  {
  56      var oToolbar = item._FCKToolbar ;
  57      
  58      if ( oToolbar.OnItemClick )
  59          oToolbar.OnItemClick( oToolbar, item ) ;
  60  }
  61  
  62  FCKToolbar.prototype.AddSeparator = function()
  63  {
  64      this.AddItem( new FCKToolbarSeparator() ) ;
  65  }
  66  
  67  FCKToolbar.prototype.Create = function( parentElement )
  68  {
  69      if ( this.MainElement )
  70      {
  71  //        this._Cleanup() ;
  72          if ( this.MainElement.parentNode )
  73              this.MainElement.parentNode.removeChild( this.MainElement ) ;
  74          this.MainElement = null ;
  75      }
  76  
  77      var oDoc = FCKTools.GetElementDocument( parentElement ) ;
  78  
  79      var e = this.MainElement = oDoc.createElement( 'table' ) ;
  80      e.className = 'TB_Toolbar' ;
  81      e.style.styleFloat = e.style.cssFloat = ( FCKLang.Dir == 'ltr' ? 'left' : 'right' ) ;
  82      e.dir = FCKLang.Dir ;
  83      e.cellPadding = 0 ;
  84      e.cellSpacing = 0 ;
  85      
  86      this.RowElement = e.insertRow(-1) ;
  87      
  88      // Insert the start cell.
  89      var eCell ;
  90      
  91      if ( !this.HideStart )
  92      {
  93          eCell = this.RowElement.insertCell(-1) ;
  94          eCell.appendChild( oDoc.createElement( 'div' ) ).className = 'TB_Start' ;
  95      }
  96      
  97      for ( var i = 0 ; i < this.Items.length ; i++ )
  98      {
  99          this.Items[i].Create( this.RowElement.insertCell(-1) ) ;
 100      }
 101      
 102      // Insert the ending cell.
 103      if ( !this.HideEnd )
 104      {
 105          eCell = this.RowElement.insertCell(-1) ;
 106          eCell.appendChild( oDoc.createElement( 'div' ) ).className = 'TB_End' ;
 107      }
 108  
 109      parentElement.appendChild( e ) ;
 110  }
 111  
 112  function FCKToolbar_Cleanup()
 113  {
 114      this.MainElement = null ;
 115      this.RowElement = null ;
 116  }
 117  
 118  var FCKToolbarSeparator = function()
 119  {}
 120  
 121  FCKToolbarSeparator.prototype.Create = function( parentElement )
 122  {
 123      FCKTools.AppendElement( parentElement, 'div' ).className = 'TB_Separator' ;
 124  }


Généré le : Sun Feb 25 15:28:05 2007 par Balluche grâce à PHPXref 0.7