[2] | 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 | var bPrevent ;
|
---|
| 36 |
|
---|
| 37 | if ( e.ctrlKey && !e.shiftKey && !e.altKey )
|
---|
| 38 | {
|
---|
| 39 | switch ( e.which )
|
---|
| 40 | {
|
---|
| 41 | case 66 : // B
|
---|
| 42 | case 98 : // b
|
---|
| 43 | FCK.ExecuteNamedCommand( 'bold' ) ; bPrevent = true ;
|
---|
| 44 | break;
|
---|
| 45 | case 105 : // i
|
---|
| 46 | case 73 : // I
|
---|
| 47 | FCK.ExecuteNamedCommand( 'italic' ) ; bPrevent = true ;
|
---|
| 48 | break;
|
---|
| 49 | case 117 : // u
|
---|
| 50 | case 85 : // U
|
---|
| 51 | FCK.ExecuteNamedCommand( 'underline' ) ; bPrevent = true ;
|
---|
| 52 | break;
|
---|
| 53 | case 86 : // V
|
---|
| 54 | case 118 : // v
|
---|
| 55 | bPrevent = ( FCK.Status != FCK_STATUS_COMPLETE || !FCK.Events.FireEvent( "OnPaste" ) ) ;
|
---|
| 56 | break ;
|
---|
| 57 | }
|
---|
| 58 | }
|
---|
| 59 | else if ( e.shiftKey && !e.ctrlKey && !e.altKey && e.keyCode == 45 ) // SHIFT + <INS>
|
---|
| 60 | bPrevent = ( FCK.Status != FCK_STATUS_COMPLETE || !FCK.Events.FireEvent( "OnPaste" ) ) ;
|
---|
| 61 |
|
---|
| 62 | if ( bPrevent )
|
---|
| 63 | {
|
---|
| 64 | e.preventDefault() ;
|
---|
| 65 | e.stopPropagation() ;
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
| 68 | this.EditorDocument.addEventListener( 'keypress', oOnKeyDown, true ) ;
|
---|
| 69 |
|
---|
| 70 | this.ExecOnSelectionChange = function()
|
---|
| 71 | {
|
---|
| 72 | FCK.Events.FireEvent( "OnSelectionChange" ) ;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | this.ExecOnSelectionChangeTimer = function()
|
---|
| 76 | {
|
---|
| 77 | if ( FCK.LastOnChangeTimer )
|
---|
| 78 | window.clearTimeout( FCK.LastOnChangeTimer ) ;
|
---|
| 79 |
|
---|
| 80 | FCK.LastOnChangeTimer = window.setTimeout( FCK.ExecOnSelectionChange, 100 ) ;
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | this.EditorDocument.addEventListener( 'mouseup', this.ExecOnSelectionChange, false ) ;
|
---|
| 84 |
|
---|
| 85 | // On Gecko, firing the "OnSelectionChange" event on every key press started to be too much
|
---|
| 86 | // slow. So, a timer has been implemented to solve performance issues when tipying to quickly.
|
---|
| 87 | this.EditorDocument.addEventListener( 'keyup', this.ExecOnSelectionChangeTimer, false ) ;
|
---|
| 88 |
|
---|
| 89 | this._DblClickListener = function( e )
|
---|
| 90 | {
|
---|
| 91 | FCK.OnDoubleClick( e.target ) ;
|
---|
| 92 | e.stopPropagation() ;
|
---|
| 93 | }
|
---|
| 94 | this.EditorDocument.addEventListener( 'dblclick', this._DblClickListener, true ) ;
|
---|
| 95 |
|
---|
| 96 | // Reset the context menu.
|
---|
| 97 | FCK.ContextMenu._InnerContextMenu.SetMouseClickWindow( FCK.EditorWindow ) ;
|
---|
| 98 | FCK.ContextMenu._InnerContextMenu.AttachToElement( FCK.EditorDocument ) ;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | FCK.MakeEditable = function()
|
---|
| 102 | {
|
---|
| 103 | this.EditingArea.MakeEditable() ;
|
---|
| 104 | }
|
---|
| 105 |
|
---|
| 106 | // Disable the context menu in the editor (outside the editing area).
|
---|
| 107 | function Document_OnContextMenu( e )
|
---|
| 108 | {
|
---|
| 109 | if ( !e.target._FCKShowContextMenu )
|
---|
| 110 | e.preventDefault() ;
|
---|
| 111 | }
|
---|
| 112 | document.oncontextmenu = Document_OnContextMenu ; |
---|