[ Index ]
 

Code source de GeekLog 1.4.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/public_html/fckeditor/editor/_source/internals/ -> fck_1_gecko.js (source)

   1  /*
   2   * FCKeditor - The text editor for internet
   3   * Copyright (C) 2003-2006 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: fck_1_gecko.js
  14   *     This is the first part of the "FCK" object creation. This is the main
  15   *     object that represents an editor instance.
  16   *     (Gecko specific implementations)
  17   * 
  18   * File Authors:
  19   *         Frederico Caldeira Knabben (fredck@fckeditor.net)
  20   */
  21  
  22  FCK.Description = "FCKeditor for Gecko Browsers" ;
  23  
  24  FCK.InitializeBehaviors = function()
  25  {
  26      // When calling "SetHTML", the editing area IFRAME gets a fixed height. So we must recaulculate it.
  27      Window_OnResize() ;
  28  
  29      FCKFocusManager.AddWindow( this.EditorWindow ) ;
  30  
  31      // Handle pasting operations.
  32      var oOnKeyDown = function( e )
  33      {
  34  
  35          // START iCM Modifications
  36          /*
  37          // Need to amend carriage return key handling so inserts block element tags rather than BR all the time
  38          if ( e.which == 13 && !e.shiftKey && !e.ctrlKey && !e.altKey && !FCKConfig.UseBROnCarriageReturn && !FCK.Events.FireEvent( "OnEnter" ) )
  39          {
  40              e.preventDefault() ;
  41              e.stopPropagation() ;
  42          }
  43          // Amend backspace handling so correctly removes empty block elements i.e. those block elements containing nothing or
  44          // just the bogus BR node
  45          if ( e.which == 8 && !e.shiftKey && !e.ctrlKey && !e.altKey && !FCKConfig.UseBROnCarriageReturn && !FCK.Events.FireEvent( "OnBackSpace" ) )
  46          {
  47              e.preventDefault() ;
  48              e.stopPropagation() ;
  49          }
  50          */
  51          // END iCM Modifications
  52  
  53          var bPrevent ;
  54  
  55          if ( e.ctrlKey && !e.shiftKey && !e.altKey )
  56          {
  57              switch ( e.which ) 
  58              {
  59                  case 66 :    // B
  60                  case 98 :    // b
  61                      FCK.ExecuteNamedCommand( 'bold' ) ; bPrevent = true ;
  62                      break;
  63                  case 105 :    // i
  64                  case 73 :    // I
  65                      FCK.ExecuteNamedCommand( 'italic' ) ; bPrevent = true ;
  66                      break;
  67                  case 117 :    // u
  68                  case 85 :    // U
  69                      FCK.ExecuteNamedCommand( 'underline' ) ; bPrevent = true ;
  70                      break;
  71                  case 86 :    // V
  72                  case 118 :    // v
  73                      bPrevent = ( FCK.Status != FCK_STATUS_COMPLETE || !FCK.Events.FireEvent( "OnPaste" ) ) ;
  74                      break ;
  75              }
  76          }
  77          else if ( e.shiftKey && !e.ctrlKey && !e.altKey && e.keyCode == 45 )    // SHIFT + <INS>
  78              bPrevent = ( FCK.Status != FCK_STATUS_COMPLETE || !FCK.Events.FireEvent( "OnPaste" ) ) ;
  79          
  80          if ( bPrevent ) 
  81          {
  82              e.preventDefault() ;
  83              e.stopPropagation() ;
  84          }
  85      }
  86      this.EditorDocument.addEventListener( 'keypress', oOnKeyDown, true ) ;
  87  
  88      this.ExecOnSelectionChange = function()
  89      {
  90          FCK.Events.FireEvent( "OnSelectionChange" ) ;
  91      }
  92  
  93      this.ExecOnSelectionChangeTimer = function()
  94      {
  95          if ( FCK.LastOnChangeTimer )
  96              window.clearTimeout( FCK.LastOnChangeTimer ) ;
  97  
  98          FCK.LastOnChangeTimer = window.setTimeout( FCK.ExecOnSelectionChange, 100 ) ;
  99      }
 100  
 101      this.EditorDocument.addEventListener( 'mouseup', this.ExecOnSelectionChange, false ) ;
 102  
 103      // On Gecko, firing the "OnSelectionChange" event on every key press started to be too much
 104      // slow. So, a timer has been implemented to solve performance issues when tipying to quickly.
 105      this.EditorDocument.addEventListener( 'keyup', this.ExecOnSelectionChangeTimer, false ) ;
 106  
 107      this._DblClickListener = function( e )
 108      {
 109          FCK.OnDoubleClick( e.target ) ;
 110          e.stopPropagation() ;
 111      }
 112      this.EditorDocument.addEventListener( 'dblclick', this._DblClickListener, true ) ;
 113  
 114      // Reset the context menu.
 115      FCK.ContextMenu._InnerContextMenu.SetMouseClickWindow( FCK.EditorWindow ) ;
 116      FCK.ContextMenu._InnerContextMenu.AttachToElement( FCK.EditorDocument ) ;
 117  }
 118  
 119  FCK.MakeEditable = function()
 120  {
 121      this.EditingArea.MakeEditable() ;
 122  }
 123  
 124  // Disable the context menu in the editor (outside the editing area).
 125  function Document_OnContextMenu( e )
 126  {
 127      if ( !e.target._FCKShowContextMenu )
 128          e.preventDefault() ;
 129  }
 130  document.oncontextmenu = Document_OnContextMenu ;


Généré le : Wed Nov 21 12:27:40 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics