[ 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/ -> fckpanel_gecko.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: fckpanel_gecko.js
  14   *     FCKPanel Class: Creates and manages floating panels in Gecko Browsers.
  15   * 
  16   * File Authors:
  17   *         Frederico Caldeira Knabben (fredck@fckeditor.net)
  18   */
  19  
  20  var FCKPanel = function( parentWindow )
  21  {
  22      this.IsRTL            = false ;
  23      this.IsContextMenu    = false ;
  24      this._IsOpened        = false ;
  25      
  26      if ( parentWindow )
  27          this._Window = parentWindow ;
  28      else
  29      {
  30          this._Window = window ;
  31  
  32          while ( this._Window != window.top )
  33          {
  34              // Try/Catch must be used to avoit an error when using a frameset
  35              // on a different domain:
  36              // "Permission denied to get property HTMLDocument.Body".
  37              try
  38              {
  39                  if ( this._Window.parent.document.body.tagName == 'FRAMESET' )
  40                      break ;
  41              } catch (e) { break ; }
  42  
  43              this._Window = this._Window.parent ;
  44          }
  45      }
  46      
  47      var oIFrame = this._IFrame = this._Window.document.createElement('iframe') ; 
  48      oIFrame.frameBorder            = '0';
  49      oIFrame.scrolling            = 'no' ;
  50      oIFrame.style.position        = 'absolute';
  51      oIFrame.width = oIFrame.height = 0 ;
  52      oIFrame.style.zIndex        = FCKConfig.FloatingPanelsZIndex ;
  53  
  54      this._Window.document.body.appendChild( oIFrame ) ;
  55      
  56      this.Document = oIFrame.contentWindow.document ;
  57  
  58      // Initialize the IFRAME document body.
  59      this.Document.open() ;
  60      this.Document.write( '<html><head></head><body><\/body><\/html>' ) ;
  61      this.Document.close() ;
  62  
  63      // Remove the default margins.
  64      this.Document.body.style.margin = this.Document.body.style.padding = '0px' ;
  65  
  66      this._IFrame.contentWindow.onblur = this.Hide ;
  67      
  68      oIFrame.contentWindow.Panel = this ;
  69  
  70  
  71      // Create the main DIV that is used as the panel base.
  72      this.PanelDiv = this.Document.body.appendChild( this.Document.createElement('DIV') ) ;
  73      this.PanelDiv.className = 'FCK_Panel' ;
  74      
  75      this.EnableContextMenu( false ) ;
  76      this.SetDirection( FCKLang.Dir ) ;
  77  }
  78  
  79  FCKPanel.prototype.EnableContextMenu = function( enabled )
  80  {
  81      this.Document.oncontextmenu = enabled ? null : FCKTools.CancelEvent ;
  82  }
  83  
  84  FCKPanel.prototype.AppendStyleSheet = function( styleSheet )
  85  {
  86      FCKTools.AppendStyleSheet( this.Document, styleSheet ) ;
  87  }
  88  
  89  FCKPanel.prototype.SetDirection = function( dir )
  90  {
  91      this.IsRTL = ( dir == 'rtl' ) ;
  92      this.Document.dir = dir ;
  93  
  94      // The "float" property must be set so Firefox calculates the size correcly.
  95      this.PanelDiv.style.cssFloat = ( dir == 'rtl' ? 'right' : 'left' ) ;
  96  }
  97  
  98  FCKPanel.prototype.Load = function()
  99  {
 100      // This is a IE only need.
 101  }
 102  
 103  FCKPanel.prototype.Show = function( x, y, relElement, width, height )
 104  {
 105      this.PanelDiv.style.width    = width ? width + 'px' : '' ;
 106      this.PanelDiv.style.height    = height ? height + 'px' : '' ;
 107  
 108      if ( !width )    this._IFrame.width    = 1 ;
 109      if ( !height )    this._IFrame.height    = 1 ;
 110  
 111      var oPos = FCKTools.GetElementPosition( relElement, this._Window ) ;
 112  
 113      x += oPos.X ;
 114      y += oPos.Y ;
 115  
 116      if ( this.IsRTL )
 117      {
 118          if ( this.IsContextMenu )
 119              x  = x - this.PanelDiv.offsetWidth + 1 ;
 120          else if ( relElement )
 121              x  = x + ( relElement.offsetWidth - this.PanelDiv.offsetWidth ) ;
 122      }
 123      else
 124      {
 125          if ( ( x + this.PanelDiv.offsetWidth ) > this._Window.document.body.clientWidth )
 126              x -= x + this.PanelDiv.offsetWidth - this._Window.document.body.clientWidth ;
 127      }
 128      
 129      if ( x < 0 )
 130              x = 0 ;
 131  
 132      // Set the context menu DIV in the specified location.
 133      this._IFrame.style.left    = x + 'px' ;
 134      this._IFrame.style.top    = y + 'px' ;
 135      
 136      var iWidth    = this.PanelDiv.offsetWidth ;
 137      var iHeight    = this.PanelDiv.offsetHeight ;
 138      
 139      this._IFrame.width    = iWidth ;
 140      this._IFrame.height = iHeight ;
 141  
 142      // Move the focus to the IFRAME so we catch the "onblur".
 143      this._IFrame.contentWindow.focus() ;
 144  
 145      this._IsOpened = true ;
 146  }
 147  
 148  FCKPanel.prototype.Hide = function()
 149  {
 150      var oPanel = this.Panel ? this.Panel : this ;
 151      
 152      if ( !oPanel._IsOpened )
 153          return ;
 154      
 155      // It is better to set the sizes to 0, otherwise Firefox would have 
 156      // rendering problems.
 157      oPanel._IFrame.width = oPanel._IFrame.height = 0 ;
 158      
 159      if ( oPanel._OnHide )
 160          oPanel._OnHide( oPanel ) ;
 161  
 162      oPanel._IsOpened = false ;
 163  }
 164  
 165  FCKPanel.prototype.CheckIsOpened = function()
 166  {
 167      return this._IsOpened ;
 168  }
 169  
 170  FCKPanel.prototype.AttachToOnHideEvent = function( targetFunction )
 171  {
 172      this._OnHide = targetFunction ;
 173  }


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