[ Index ]
 

Code source de FCKeditor 2.4

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

title

Body

[fermer]

/editor/_source/classes/ -> fckicon.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: fckicon.js
  22   *     FCKIcon Class: renders an icon from a single image, a strip or even a
  23   *     spacer.
  24   * 
  25   * File Authors:
  26   *         Frederico Caldeira Knabben (www.fckeditor.net)
  27   */
  28  
  29  var FCKIcon = function( iconPathOrStripInfoArray )
  30  {
  31      var sTypeOf = iconPathOrStripInfoArray ? typeof( iconPathOrStripInfoArray ) : 'undefined' ;
  32      switch ( sTypeOf )
  33      {
  34          case 'number' :
  35              this.Path = FCKConfig.SkinPath + 'fck_strip.gif' ;
  36              this.Size = 16 ;
  37              this.Position = iconPathOrStripInfoArray ;
  38              break ;
  39          
  40          case 'undefined' :
  41              this.Path = FCK_SPACER_PATH ;
  42              break ;
  43          
  44          case 'string' :
  45              this.Path = iconPathOrStripInfoArray ;
  46              break ;
  47          
  48          default :
  49              // It is an array in the format [ StripFilePath, IconSize, IconPosition ]
  50              this.Path        = iconPathOrStripInfoArray[0] ;
  51              this.Size        = iconPathOrStripInfoArray[1] ;
  52              this.Position    = iconPathOrStripInfoArray[2] ;
  53      }
  54  }
  55  
  56  FCKIcon.prototype.CreateIconElement = function( document )
  57  {
  58      var eIcon, eIconImage ;
  59      
  60      if ( this.Position )        // It is using an icons strip image.
  61      {
  62          var sPos = '-' + ( ( this.Position - 1 ) * this.Size ) + 'px' ;
  63      
  64          if ( FCKBrowserInfo.IsIE )
  65          {
  66              // <div class="TB_Button_Image"><img src="strip.gif" style="top:-16px"></div>
  67              
  68              eIcon = document.createElement( 'DIV' ) ;
  69              
  70              eIconImage = eIcon.appendChild( document.createElement( 'IMG' ) ) ;
  71              eIconImage.src = this.Path ;
  72              eIconImage.style.top = sPos ;
  73          }
  74          else
  75          {
  76              // <img class="TB_Button_Image" src="spacer.gif" style="background-position: 0px -16px;background-image: url(strip.gif);">
  77              
  78              eIcon = document.createElement( 'IMG' ) ;
  79              eIcon.src = FCK_SPACER_PATH ;
  80              eIcon.style.backgroundPosition    = '0px ' + sPos ;
  81              eIcon.style.backgroundImage        = 'url(' + this.Path + ')' ;
  82          }
  83      }
  84      else                    // It is using a single icon image.
  85      {
  86          // This is not working well with IE. See notes bellow.
  87          // <img class="TB_Button_Image" src="smiley.gif">
  88  //        eIcon = document.createElement( 'IMG' ) ;
  89  //        eIcon.src = this.Path ? this.Path : FCK_SPACER_PATH ;
  90  
  91          // IE makes the button 1px higher if using the <img> directly, so we
  92          // are changing to the <div> system to clip the image correctly.
  93          eIcon = document.createElement( 'DIV' ) ;
  94          
  95          eIconImage = eIcon.appendChild( document.createElement( 'IMG' ) ) ;
  96          eIconImage.src = this.Path ? this.Path : FCK_SPACER_PATH ;
  97      }
  98      
  99      eIcon.className = 'TB_Button_Image' ;
 100  
 101      return eIcon ;
 102  }


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