[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/include/fckeditor/editor/_source/classes/ -> fcktoolbarbutton.js (source)

   1  /*
   2   * FCKeditor - The text editor for internet
   3   * Copyright (C) 2003-2005 Frederico Caldeira Knabben
   4   * 
   5   * Licensed under the terms of the GNU Lesser General Public License:
   6   *         http://www.opensource.org/licenses/lgpl-license.php
   7   * 
   8   * For further information visit:
   9   *         http://www.fckeditor.net/
  10   * 
  11   * "Support Open Source software. What about a donation today?"
  12   * 
  13   * File Name: fcktoolbarbutton.js
  14   *     FCKToolbarButton Class: represents a button in the toolbar.
  15   * 
  16   * File Authors:
  17   *         Frederico Caldeira Knabben (fredck@fckeditor.net)
  18   */
  19  
  20  var FCKToolbarButton = function( commandName, label, tooltip, style, sourceView, contextSensitive )
  21  {
  22      this.Command            = FCKCommands.GetCommand( commandName ) ;
  23      this.Label                = label ? label : commandName ;
  24      this.Tooltip            = tooltip ? tooltip : ( label ? label : commandName) ;
  25      this.Style                = style ? style : FCK_TOOLBARITEM_ONLYICON ;
  26      this.SourceView            = sourceView ? true : false ;
  27      this.ContextSensitive    = contextSensitive ? true : false ;
  28      this.IconPath            = FCKConfig.SkinPath + 'toolbar/' + commandName.toLowerCase() + '.gif' ;
  29      this.State                = FCK_UNKNOWN ;
  30  }
  31  
  32  FCKToolbarButton.prototype.CreateInstance = function( parentToolbar )
  33  {
  34      this.DOMDiv = document.createElement( 'div' ) ;
  35      this.DOMDiv.className = 'TB_Button_Off' ;
  36  
  37      this.DOMDiv.FCKToolbarButton = this ;
  38      
  39      var sHtml =
  40          '<table title="' + this.Tooltip + '" cellspacing="0" cellpadding="0" border="0">' +
  41              '<tr>' ;
  42      
  43      if ( this.Style != FCK_TOOLBARITEM_ONLYTEXT ) 
  44          sHtml += '<td class="TB_Icon"><img src="' + this.IconPath + '" width="21" height="21"></td>' ;
  45      
  46      if ( this.Style != FCK_TOOLBARITEM_ONLYICON ) 
  47          sHtml += '<td class="TB_Text" nowrap>' + this.Label + '</td>' ;
  48      
  49      sHtml +=    
  50              '</tr>' +
  51          '</table>' ;
  52      
  53      this.DOMDiv.innerHTML = sHtml ;
  54  
  55      var oCell = parentToolbar.DOMRow.insertCell(-1) ;
  56      oCell.appendChild( this.DOMDiv ) ;
  57      
  58      this.RefreshState() ;
  59  }
  60  
  61  FCKToolbarButton.prototype.RefreshState = function()
  62  {
  63  /*
  64      TODO: Delete this comment block on stable version.
  65      // Gets the actual state.
  66  //    var eState ;
  67  
  68  //    if ( FCK.EditMode == FCK_EDITMODE_SOURCE && ! this.SourceView )
  69  //        eState = FCK_TRISTATE_DISABLED ;
  70  //    else
  71  */
  72      // Gets the actual state.
  73      var eState = this.Command.GetState() ;
  74      
  75      // If there are no state changes than do nothing and return.
  76      if ( eState == this.State ) return ;
  77      
  78      // Sets the actual state.
  79      this.State = eState ;
  80      
  81      switch ( this.State )
  82      {
  83          case FCK_TRISTATE_ON :
  84              this.DOMDiv.className = 'TB_Button_On' ;
  85  
  86              this.DOMDiv.onmouseover    = FCKToolbarButton_OnMouseOnOver ;
  87              this.DOMDiv.onmouseout    = FCKToolbarButton_OnMouseOnOut ;
  88              this.DOMDiv.onclick        = FCKToolbarButton_OnClick ;
  89              
  90              break ;
  91          case FCK_TRISTATE_OFF :
  92              this.DOMDiv.className = 'TB_Button_Off' ;
  93  
  94              this.DOMDiv.onmouseover    = FCKToolbarButton_OnMouseOffOver ;
  95              this.DOMDiv.onmouseout    = FCKToolbarButton_OnMouseOffOut ;
  96              this.DOMDiv.onclick        = FCKToolbarButton_OnClick ;
  97              
  98              break ;
  99          default :
 100              this.Disable() ;
 101              break ;
 102      }
 103  }
 104  
 105  function FCKToolbarButton_OnMouseOnOver()
 106  {
 107      this.className = 'TB_Button_On TB_Button_On_Over' ;
 108  }
 109  
 110  function FCKToolbarButton_OnMouseOnOut()
 111  {
 112      this.className = 'TB_Button_On' ;
 113  }
 114      
 115  function FCKToolbarButton_OnMouseOffOver()
 116  {
 117      this.className = 'TB_Button_On TB_Button_Off_Over' ;
 118  }
 119  
 120  function FCKToolbarButton_OnMouseOffOut()
 121  {
 122      this.className = 'TB_Button_Off' ;
 123  }
 124      
 125  function FCKToolbarButton_OnClick(e)
 126  {
 127      this.FCKToolbarButton.Click(e) ;
 128      return false ;
 129  }
 130  
 131  FCKToolbarButton.prototype.Click = function()
 132  {
 133      this.Command.Execute() ;
 134  }
 135  
 136  FCKToolbarButton.prototype.Enable = function()
 137  {
 138      this.RefreshState() ;
 139  }
 140  
 141  FCKToolbarButton.prototype.Disable = function()
 142  {
 143      this.State = FCK_TRISTATE_DISABLED ;
 144      this.DOMDiv.className = 'TB_Button_Disabled' ;
 145      this.DOMDiv.onmouseover    = null ;
 146      this.DOMDiv.onmouseout    = null ;
 147      this.DOMDiv.onclick        = null ;
 148  }


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7