source: sandbox/filemanager/tp/fckeditor/editor/js/fckadobeair.js @ 1575

Revision 1575, 4.9 KB checked in by amuller, 14 years ago (diff)

Ticket #597 - Implentação, melhorias do modulo gerenciador de arquivos

  • Property svn:executable set to *
Line 
1/*
2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
3 * Copyright (C) 2003-2009 Frederico Caldeira Knabben
4 *
5 * == BEGIN LICENSE ==
6 *
7 * Licensed under the terms of any of the following licenses at your
8 * choice:
9 *
10 *  - GNU General Public License Version 2 or later (the "GPL")
11 *    http://www.gnu.org/licenses/gpl.html
12 *
13 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14 *    http://www.gnu.org/licenses/lgpl.html
15 *
16 *  - Mozilla Public License Version 1.1 or later (the "MPL")
17 *    http://www.mozilla.org/MPL/MPL-1.1.html
18 *
19 * == END LICENSE ==
20 *
21 * Compatibility code for Adobe AIR.
22 */
23
24if ( FCKBrowserInfo.IsAIR )
25{
26        var FCKAdobeAIR = (function()
27        {
28                /*
29                 * ### Private functions.
30                 */
31
32                var getDocumentHead = function( doc )
33                {
34                        var head ;
35                        var heads = doc.getElementsByTagName( 'head' ) ;
36
37                        if( heads && heads[0] )
38                                head = heads[0] ;
39                        else
40                        {
41                                head = doc.createElement( 'head' ) ;
42                                doc.documentElement.insertBefore( head, doc.documentElement.firstChild ) ;
43                        }
44
45                        return head ;
46                } ;
47
48                /*
49                 * ### Public interface.
50                 */
51                return {
52                        FCKeditorAPI_Evaluate : function( parentWindow, script )
53                        {
54                                // TODO : This one doesn't work always. The parent window will
55                                // point to an anonymous function in this window. If this
56                                // window is destroyied the parent window will be pointing to
57                                // an invalid reference.
58
59                                // Evaluate the script in this window.
60                                eval( script ) ;
61
62                                // Point the FCKeditorAPI property of the parent window to the
63                                // local reference.
64                                parentWindow.FCKeditorAPI = window.FCKeditorAPI ;
65                        },
66
67                        EditingArea_Start : function( doc, html )
68                        {
69                                // Get the HTML for the <head>.
70                                var headInnerHtml = html.match( /<head>([\s\S]*)<\/head>/i )[1] ;
71
72                                if ( headInnerHtml && headInnerHtml.length > 0 )
73                                {
74                                        // Inject the <head> HTML inside a <div>.
75                                        // Do that before getDocumentHead because WebKit moves
76                                        // <link css> elements to the <head> at this point.
77                                        var div = doc.createElement( 'div' ) ;
78                                        div.innerHTML = headInnerHtml ;
79
80                                        // Move the <div> nodes to <head>.
81                                        FCKDomTools.MoveChildren( div, getDocumentHead( doc ) ) ;
82                                }
83
84                                doc.body.innerHTML = html.match( /<body>([\s\S]*)<\/body>/i )[1] ;
85
86                                //prevent clicking on hyperlinks and navigating away
87                                doc.addEventListener('click', function( ev )
88                                        {
89                                                ev.preventDefault() ;
90                                                ev.stopPropagation() ;
91                                        }, true ) ;
92                        },
93
94                        Panel_Contructor : function( doc, baseLocation )
95                        {
96                                var head = getDocumentHead( doc ) ;
97
98                                // Set the <base> href.
99                                head.appendChild( doc.createElement('base') ).href = baseLocation ;
100
101                                doc.body.style.margin   = '0px' ;
102                                doc.body.style.padding  = '0px' ;
103                        },
104
105                        ToolbarSet_GetOutElement : function( win, outMatch )
106                        {
107                                var toolbarTarget = win.parent ;
108
109                                var targetWindowParts = outMatch[1].split( '.' ) ;
110                                while ( targetWindowParts.length > 0 )
111                                {
112                                        var part = targetWindowParts.shift() ;
113                                        if ( part.length > 0 )
114                                                toolbarTarget = toolbarTarget[ part ] ;
115                                }
116
117                                toolbarTarget = toolbarTarget.document.getElementById( outMatch[2] ) ;
118                        },
119
120                        ToolbarSet_InitOutFrame : function( doc )
121                        {
122                                var head = getDocumentHead( doc ) ;
123
124                                head.appendChild( doc.createElement('base') ).href = window.document.location ;
125
126                                var targetWindow = doc.defaultView;
127
128                                targetWindow.adjust = function()
129                                {
130                                        targetWindow.frameElement.height = doc.body.scrollHeight;
131                                } ;
132
133                                targetWindow.onresize = targetWindow.adjust ;
134                                targetWindow.setTimeout( targetWindow.adjust, 0 ) ;
135
136                                doc.body.style.overflow = 'hidden';
137                                doc.body.innerHTML = document.getElementById( 'xToolbarSpace' ).innerHTML ;
138                        }
139                } ;
140        })();
141
142        /*
143         * ### Overrides
144         */
145        ( function()
146        {
147                // Save references for override reuse.
148                var _Original_FCKPanel_Window_OnFocus   = FCKPanel_Window_OnFocus ;
149                var _Original_FCKPanel_Window_OnBlur    = FCKPanel_Window_OnBlur ;
150                var _Original_FCK_StartEditor                   = FCK.StartEditor ;
151
152                FCKPanel_Window_OnFocus = function( e, panel )
153                {
154                        // Call the original implementation.
155                        _Original_FCKPanel_Window_OnFocus.call( this, e, panel ) ;
156
157                        if ( panel._focusTimer )
158                                clearTimeout( panel._focusTimer ) ;
159                }
160
161                FCKPanel_Window_OnBlur = function( e, panel )
162                {
163                        // Delay the execution of the original function.
164                        panel._focusTimer = FCKTools.SetTimeout( _Original_FCKPanel_Window_OnBlur, 100, this, [ e, panel ] ) ;
165                }
166
167                FCK.StartEditor = function()
168                {
169                        // Force pointing to the CSS files instead of using the inline CSS cached styles.
170                        window.FCK_InternalCSS                  = FCKConfig.BasePath + 'css/fck_internal.css' ;
171                        window.FCK_ShowTableBordersCSS  = FCKConfig.BasePath + 'css/fck_showtableborders_gecko.css' ;
172
173                        _Original_FCK_StartEditor.apply( this, arguments ) ;
174                }
175        })();
176}
Note: See TracBrowser for help on using the repository browser.