[ 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/internals/ -> fckselection_ie.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: fckselection_ie.js
  14   *     Active selection functions. (IE specific implementation)
  15   * 
  16   * File Authors:
  17   *         Frederico Caldeira Knabben (fredck@fckeditor.net)
  18   */
  19  
  20  // Get the selection type.
  21  FCKSelection.GetType = function()
  22  {
  23      return FCK.EditorDocument.selection.type ;
  24  }
  25  
  26  // Retrieves the selected element (if any), just in the case that a single
  27  // element (object like and image or a table) is selected.
  28  FCKSelection.GetSelectedElement = function()
  29  {
  30      if ( this.GetType() == 'Control' )
  31      {
  32          var oRange = FCK.EditorDocument.selection.createRange() ;
  33  
  34          if ( oRange && oRange.item )
  35              return FCK.EditorDocument.selection.createRange().item(0) ;
  36      }
  37  }
  38  
  39  FCKSelection.GetParentElement = function()
  40  {
  41      switch ( this.GetType() )
  42      {
  43          case 'Control' :
  44              return FCKSelection.GetSelectedElement().parentElement ;
  45          case 'None' :
  46              return ;
  47          default :
  48              return FCK.EditorDocument.selection.createRange().parentElement() ;
  49      }
  50  }
  51  
  52  FCKSelection.SelectNode = function( node )
  53  {
  54      FCK.Focus() ;
  55      FCK.EditorDocument.selection.empty() ;
  56      var oRange = FCK.EditorDocument.selection.createRange() ;
  57      oRange.moveToElementText( node ) ;
  58      oRange.select() ;
  59  }
  60  
  61  FCKSelection.Collapse = function( toStart )
  62  {
  63      FCK.Focus() ;
  64      var oRange = FCK.EditorDocument.selection.createRange() ;
  65      oRange.collapse( toStart == null || toStart === true ) ;
  66      oRange.select() ;
  67  }
  68  
  69  // The "nodeTagName" parameter must be Upper Case.
  70  FCKSelection.HasAncestorNode = function( nodeTagName )
  71  {
  72      var oContainer ;
  73  
  74      if ( FCK.EditorDocument.selection.type == "Control" )
  75      {
  76          oContainer = this.GetSelectedElement() ;
  77      }
  78      else
  79      {
  80          var oRange  = FCK.EditorDocument.selection.createRange() ;
  81          oContainer = oRange.parentElement() ;
  82      }
  83  
  84      while ( oContainer )
  85      {
  86          if ( oContainer.tagName == nodeTagName ) return true ;
  87          oContainer = oContainer.parentNode ;
  88      }
  89  
  90      return false ;
  91  }
  92  
  93  // The "nodeTagName" parameter must be UPPER CASE.
  94  FCKSelection.MoveToAncestorNode = function( nodeTagName )
  95  {
  96      var oNode ;
  97  
  98      if ( FCK.EditorDocument.selection.type == "Control" )
  99      {
 100          var oRange = FCK.EditorDocument.selection.createRange() ;
 101          for ( i = 0 ; i < oRange.length ; i++ )
 102          {
 103              if (oRange(i).parentNode)
 104              {
 105                  oNode = oRange(i).parentNode ;
 106                  break ;
 107              }
 108          }
 109      }
 110      else
 111      {
 112          var oRange  = FCK.EditorDocument.selection.createRange() ;
 113          oNode = oRange.parentElement() ;
 114      }
 115  
 116      while ( oNode && oNode.nodeName != nodeTagName )
 117          oNode = oNode.parentNode ;
 118  
 119      return oNode ;
 120  }
 121  
 122  FCKSelection.Delete = function()
 123  {
 124      // Gets the actual selection.
 125      var oSel = FCK.EditorDocument.selection ;
 126  
 127      // Deletes the actual selection contents.
 128      if ( oSel.type.toLowerCase() != "none" )
 129      {
 130          oSel.clear() ;
 131      }
 132  
 133      return oSel ;
 134  }
 135  // START iCM Modifications
 136  /*
 137  // Move the cursor position (the selection point) to a specific offset within a specific node
 138  // If no offset specified, the start of the node is assumed
 139  FCKSelection.SetCursorPosition = function ( oNode, nOffset )
 140  {
 141      if ( typeof nOffset == "undefined" ) nOffset = 0 ;
 142  
 143      FCK.Selection.SelectNode( oNode ) ; // Doesn't handle offsets currently but offset always zero at mo
 144      FCK.Selection.Collapse( true ) ;
 145      
 146      oNode.scrollIntoView( false );    
 147  }
 148  */
 149  // END iCM Modifications
 150  


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