source: companies/serpro/expressoMail1_2/js/fckeditor/editor/_source/internals/fckundo_ie.js @ 903

Revision 903, 2.9 KB checked in by niltonneto, 15 years ago (diff)

Importacao inicial do Expresso do Serpro

Line 
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: fckundo_ie.js
14 *      IE specific implementation for the Undo/Redo system.
15 *
16 * File Authors:
17 *              Frederico Caldeira Knabben (fredck@fckeditor.net)
18 */
19
20var FCKUndo = new Object() ;
21
22FCKUndo.SavedData = new Array() ;
23FCKUndo.CurrentIndex = -1 ;
24FCKUndo.TypesCount = FCKUndo.MaxTypes = 25 ;
25FCKUndo.Typing = false ;
26
27FCKUndo.SaveUndoStep = function()
28{
29        if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
30                return ;
31
32        // Shrink the array to the current level.
33        FCKUndo.SavedData = FCKUndo.SavedData.slice( 0, FCKUndo.CurrentIndex + 1 ) ;
34
35        // Get the Actual HTML.
36        var sHtml = FCK.EditorDocument.body.innerHTML ;
37
38        // Cancel operation if the new step is identical to the previous one.
39        if ( FCKUndo.CurrentIndex >= 0 && sHtml == FCKUndo.SavedData[ FCKUndo.CurrentIndex ][0] )
40                return ;
41
42        // If we reach the Maximun number of undo levels, we must remove the first
43        // entry of the list shifting all elements.
44        if ( FCKUndo.CurrentIndex + 1 >= FCKConfig.MaxUndoLevels )
45                FCKUndo.SavedData.shift() ;
46        else
47                FCKUndo.CurrentIndex++ ;
48
49        // Get the actual selection.
50        var sBookmark ;
51        if ( FCK.EditorDocument.selection.type == 'Text' )
52                sBookmark = FCK.EditorDocument.selection.createRange().getBookmark() ;
53
54        // Save the new level in front of the actual position.
55        FCKUndo.SavedData[ FCKUndo.CurrentIndex ] = [ sHtml, sBookmark ] ;
56
57        FCK.Events.FireEvent( "OnSelectionChange" ) ;
58}
59
60FCKUndo.CheckUndoState = function()
61{
62        return ( FCKUndo.Typing || FCKUndo.CurrentIndex > 0 ) ;
63}
64
65FCKUndo.CheckRedoState = function()
66{
67        return ( !FCKUndo.Typing && FCKUndo.CurrentIndex < ( FCKUndo.SavedData.length - 1 ) ) ;
68}
69
70FCKUndo.Undo = function()
71{
72        if ( FCKUndo.CheckUndoState() )
73        {
74                // If it is the first step.
75                if ( FCKUndo.CurrentIndex == ( FCKUndo.SavedData.length - 1 ) )
76                {
77                        // Save the actual state for a possible "Redo" call.
78                        FCKUndo.SaveUndoStep() ;
79                }
80
81                // Go a step back.
82                FCKUndo._ApplyUndoLevel( --FCKUndo.CurrentIndex ) ;
83
84                FCK.Events.FireEvent( "OnSelectionChange" ) ;
85        }
86}
87
88FCKUndo.Redo = function()
89{
90        if ( FCKUndo.CheckRedoState() )
91        {
92                // Go a step forward.
93                FCKUndo._ApplyUndoLevel( ++FCKUndo.CurrentIndex ) ;
94
95                FCK.Events.FireEvent( "OnSelectionChange" ) ;
96        }
97}
98
99FCKUndo._ApplyUndoLevel = function(level)
100{
101        var oData = FCKUndo.SavedData[ level ] ;
102       
103        if ( !oData )
104                return ;
105
106        // Update the editor contents with that step data.
107        FCK.SetInnerHtml( oData[0] ) ;
108//      FCK.EditorDocument.body.innerHTML = oData[0] ;
109
110        if ( oData[1] )
111        {
112                var oRange = FCK.EditorDocument.selection.createRange() ;
113                oRange.moveToBookmark( oData[1] ) ;
114                oRange.select() ;
115        }
116       
117        FCKUndo.TypesCount = 0 ;
118        FCKUndo.Typing = false ;
119}
Note: See TracBrowser for help on using the repository browser.