[ Index ]
 

Code source de FCKeditor 2.4

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

title

Body

[fermer]

/editor/_source/classes/ -> fcktoolbarstylecombo.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: fcktoolbarstylecombo.js
  22   *     FCKToolbarPanelButton Class: Handles the Fonts combo selector.
  23   * 
  24   * File Authors:
  25   *         Frederico Caldeira Knabben (www.fckeditor.net)
  26   */
  27  
  28  var FCKToolbarStyleCombo = function( tooltip, style )
  29  {
  30      this.CommandName = 'Style' ;
  31      this.Label        = this.GetLabel() ;
  32      this.Tooltip    = tooltip ? tooltip : this.Label ;
  33      this.Style        = style ? style : FCK_TOOLBARITEM_ICONTEXT ;
  34  }
  35  
  36  // Inherit from FCKToolbarSpecialCombo.
  37  FCKToolbarStyleCombo.prototype = new FCKToolbarSpecialCombo ;
  38  
  39  
  40  FCKToolbarStyleCombo.prototype.GetLabel = function()
  41  {
  42      return FCKLang.Style ;
  43  }
  44  
  45  FCKToolbarStyleCombo.prototype.CreateItems = function( targetSpecialCombo )
  46  {
  47      var oTargetDoc = targetSpecialCombo._Panel.Document ;
  48      
  49      // Add the Editor Area CSS to the panel so the style classes are previewed correctly.
  50      FCKTools.AppendStyleSheet( oTargetDoc, FCKConfig.ToolbarComboPreviewCSS ) ;
  51      oTargetDoc.body.className += ' ForceBaseFont' ;
  52  
  53      // Add ID and Class to the body
  54      if ( FCKConfig.BodyId && FCKConfig.BodyId.length > 0 )
  55          oTargetDoc.body.id = FCKConfig.BodyId ;
  56      if ( FCKConfig.BodyClass && FCKConfig.BodyClass.length > 0 )
  57          oTargetDoc.body.className += ' ' + FCKConfig.BodyClass ;
  58  
  59  
  60      // For some reason Gecko is blocking inside the "RefreshVisibleItems" function.
  61      // The problem is present only in old versions
  62      if ( !( FCKBrowserInfo.IsGecko && FCKBrowserInfo.IsGecko10 ) )
  63          targetSpecialCombo.OnBeforeClick = this.RefreshVisibleItems ;
  64  
  65      // Add the styles to the special combo.
  66      var aCommandStyles = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).Styles ;
  67      for ( var s in aCommandStyles )
  68      {
  69          var oStyle = aCommandStyles[s] ;
  70          var oItem ;
  71          
  72          if ( oStyle.IsObjectElement )
  73              oItem = targetSpecialCombo.AddItem( s, s ) ;
  74          else
  75              oItem = targetSpecialCombo.AddItem( s, oStyle.GetOpenerTag() + s + oStyle.GetCloserTag() ) ;
  76              
  77          oItem.Style = oStyle ;
  78      }
  79  }
  80  
  81  FCKToolbarStyleCombo.prototype.RefreshActiveItems = function( targetSpecialCombo )
  82  {
  83      // Clear the actual selection.
  84      targetSpecialCombo.DeselectAll() ;
  85      
  86      // Get the active styles.
  87      var aStyles = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).GetActiveStyles() ;
  88      
  89      if ( aStyles.length > 0 )
  90      {
  91          // Select the active styles in the combo.
  92          for ( var i = 0 ; i < aStyles.length ; i++ )
  93              targetSpecialCombo.SelectItem( aStyles[i].Name ) ;
  94  
  95          // Set the combo label to the first style in the collection.
  96          targetSpecialCombo.SetLabelById( aStyles[0].Name ) ;
  97      }
  98      else
  99          targetSpecialCombo.SetLabel('') ;
 100  }
 101  
 102  FCKToolbarStyleCombo.prototype.RefreshVisibleItems = function( targetSpecialCombo )
 103  {
 104      if ( FCKSelection.GetType() == 'Control' )
 105          var sTagName = FCKSelection.GetSelectedElement().tagName ;
 106  
 107      for ( var i in targetSpecialCombo.Items )
 108      {
 109          var oItem = targetSpecialCombo.Items[i] ;
 110          if ( ( sTagName && oItem.Style.Element == sTagName ) || ( ! sTagName && ! oItem.Style.IsObjectElement ) )
 111              oItem.style.display = '' ;
 112          else
 113              oItem.style.display = 'none' ;    // For some reason Gecko is blocking here.
 114      }
 115  }


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