~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/FCK/editor/_source/internals/fckconfig.js

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 
3
 * Copyright (C) 2003-2007 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
 * Creates and initializes the FCKConfig object.
 
22
 */
 
23
 
 
24
var FCKConfig = FCK.Config = new Object() ;
 
25
 
 
26
/*
 
27
        For the next major version (probably 3.0) we should move all this stuff to
 
28
        another dedicated object and leave FCKConfig as a holder object for settings only).
 
29
*/
 
30
 
 
31
// Editor Base Path
 
32
if ( document.location.protocol == 'file:' )
 
33
{
 
34
        FCKConfig.BasePath = decodeURIComponent( document.location.pathname.substr(1) ) ;
 
35
        FCKConfig.BasePath = FCKConfig.BasePath.replace( /\\/gi, '/' ) ;
 
36
        FCKConfig.BasePath = 'file://' + FCKConfig.BasePath.substring(0,FCKConfig.BasePath.lastIndexOf('/')+1) ;
 
37
        FCKConfig.FullBasePath = FCKConfig.BasePath ;
 
38
}
 
39
else
 
40
{
 
41
        FCKConfig.BasePath = document.location.pathname.substring(0,document.location.pathname.lastIndexOf('/')+1) ;
 
42
        FCKConfig.FullBasePath = document.location.protocol + '//' + document.location.host + FCKConfig.BasePath ;
 
43
}
 
44
 
 
45
FCKConfig.EditorPath = FCKConfig.BasePath.replace( /editor\/$/, '' ) ;
 
46
 
 
47
// There is a bug in Gecko. If the editor is hidden on startup, an error is
 
48
// thrown when trying to get the screen dimentions.
 
49
try
 
50
{
 
51
        FCKConfig.ScreenWidth   = screen.width ;
 
52
        FCKConfig.ScreenHeight  = screen.height ;
 
53
}
 
54
catch (e)
 
55
{
 
56
        FCKConfig.ScreenWidth   = 800 ;
 
57
        FCKConfig.ScreenHeight  = 600 ;
 
58
}
 
59
 
 
60
// Override the actual configuration values with the values passed throw the
 
61
// hidden field "<InstanceName>___Config".
 
62
FCKConfig.ProcessHiddenField = function()
 
63
{
 
64
        this.PageConfig = new Object() ;
 
65
 
 
66
        // Get the hidden field.
 
67
        var oConfigField = window.parent.document.getElementById( FCK.Name + '___Config' ) ;
 
68
 
 
69
        // Do nothing if the config field was not defined.
 
70
        if ( ! oConfigField ) return ;
 
71
 
 
72
        var aCouples = oConfigField.value.split('&') ;
 
73
 
 
74
        for ( var i = 0 ; i < aCouples.length ; i++ )
 
75
        {
 
76
                if ( aCouples[i].length == 0 )
 
77
                        continue ;
 
78
 
 
79
                var aConfig = aCouples[i].split( '=' ) ;
 
80
                var sKey = decodeURIComponent( aConfig[0] ) ;
 
81
                var sVal = decodeURIComponent( aConfig[1] ) ;
 
82
 
 
83
                if ( sKey == 'CustomConfigurationsPath' )       // The Custom Config File path must be loaded immediately.
 
84
                        FCKConfig[ sKey ] = sVal ;
 
85
 
 
86
                else if ( sVal.toLowerCase() == "true" )        // If it is a boolean TRUE.
 
87
                        this.PageConfig[ sKey ] = true ;
 
88
 
 
89
                else if ( sVal.toLowerCase() == "false" )       // If it is a boolean FALSE.
 
90
                        this.PageConfig[ sKey ] = false ;
 
91
 
 
92
                else if ( sVal.length > 0 && !isNaN( sVal ) )   // If it is a number.
 
93
                        this.PageConfig[ sKey ] = parseInt( sVal, 10 ) ;
 
94
 
 
95
                else                                                                            // In any other case it is a string.
 
96
                        this.PageConfig[ sKey ] = sVal ;
 
97
        }
 
98
}
 
99
 
 
100
function FCKConfig_LoadPageConfig()
 
101
{
 
102
        var oPageConfig = FCKConfig.PageConfig ;
 
103
        for ( var sKey in oPageConfig )
 
104
                FCKConfig[ sKey ] = oPageConfig[ sKey ] ;
 
105
}
 
106
 
 
107
function FCKConfig_PreProcess()
 
108
{
 
109
        var oConfig = FCKConfig ;
 
110
 
 
111
        // Force debug mode if fckdebug=true in the QueryString (main page).
 
112
        if ( oConfig.AllowQueryStringDebug )
 
113
        {
 
114
                try
 
115
                {
 
116
                        if ( (/fckdebug=true/i).test( window.top.location.search ) )
 
117
                                oConfig.Debug = true ;
 
118
                }
 
119
                catch (e) { /* Ignore it. Much probably we are inside a FRAME where the "top" is in another domain (security error). */ }
 
120
        }
 
121
 
 
122
        // Certifies that the "PluginsPath" configuration ends with a slash.
 
123
        if ( !oConfig.PluginsPath.EndsWith('/') )
 
124
                oConfig.PluginsPath += '/' ;
 
125
 
 
126
        // EditorAreaCSS accepts an array of paths or a single path (as string).
 
127
        // In the last case, transform it in an array.
 
128
        if ( typeof( oConfig.EditorAreaCSS ) == 'string' )
 
129
                oConfig.EditorAreaCSS = [ oConfig.EditorAreaCSS ] ;
 
130
 
 
131
        var sComboPreviewCSS = oConfig.ToolbarComboPreviewCSS ;
 
132
        if ( !sComboPreviewCSS || sComboPreviewCSS.length == 0 )
 
133
                oConfig.ToolbarComboPreviewCSS = oConfig.EditorAreaCSS ;
 
134
        else if ( typeof( sComboPreviewCSS ) == 'string' )
 
135
                oConfig.ToolbarComboPreviewCSS = [ sComboPreviewCSS ] ;
 
136
}
 
137
 
 
138
// Define toolbar sets collection.
 
139
FCKConfig.ToolbarSets = new Object() ;
 
140
 
 
141
// Defines the plugins collection.
 
142
FCKConfig.Plugins = new Object() ;
 
143
FCKConfig.Plugins.Items = new Array() ;
 
144
 
 
145
FCKConfig.Plugins.Add = function( name, langs, path )
 
146
{
 
147
        FCKConfig.Plugins.Items.AddItem( [name, langs, path] ) ;
 
148
}
 
149
 
 
150
// FCKConfig.ProtectedSource: object that holds a collection of Regular
 
151
// Expressions that defined parts of the raw HTML that must remain untouched
 
152
// like custom tags, scripts, server side code, etc...
 
153
FCKConfig.ProtectedSource = new Object() ;
 
154
 
 
155
// Initialize the regex array with the default ones.
 
156
FCKConfig.ProtectedSource.RegexEntries = [
 
157
        // First of any other protection, we must protect all comments to avoid
 
158
        // loosing them (of course, IE related).
 
159
        /<!--[\s\S]*?-->/g ,
 
160
 
 
161
        // Script tags will also be forced to be protected, otherwise IE will execute them.
 
162
        /<script[\s\S]*?<\/script>/gi,
 
163
 
 
164
        // <noscript> tags (get lost in IE and messed up in FF).
 
165
        /<noscript[\s\S]*?<\/noscript>/gi,
 
166
        
 
167
        // Protect <object> tags. See #359.
 
168
        /<object[\s\S]+?<\/object>/gi
 
169
] ;
 
170
 
 
171
FCKConfig.ProtectedSource.Add = function( regexPattern )
 
172
{
 
173
        this.RegexEntries.AddItem( regexPattern ) ;
 
174
}
 
175
 
 
176
FCKConfig.ProtectedSource.Protect = function( html )
 
177
{
 
178
        function _Replace( protectedSource )
 
179
        {
 
180
                var index = FCKTempBin.AddElement( protectedSource ) ;
 
181
                return '<!--{PS..' + index + '}-->' ;
 
182
        }
 
183
 
 
184
        for ( var i = 0 ; i < this.RegexEntries.length ; i++ )
 
185
        {
 
186
                html = html.replace( this.RegexEntries[i], _Replace ) ;
 
187
        }
 
188
 
 
189
        return html ;
 
190
}
 
191
 
 
192
FCKConfig.ProtectedSource.Revert = function( html, clearBin )
 
193
{
 
194
        function _Replace( m, opener, index )
 
195
        {
 
196
                var protectedValue = clearBin ? FCKTempBin.RemoveElement( index ) : FCKTempBin.Elements[ index ] ;
 
197
                // There could be protected source inside another one.
 
198
                return FCKConfig.ProtectedSource.Revert( protectedValue, clearBin ) ;
 
199
        }
 
200
 
 
201
        return html.replace( /(<|&lt;)!--\{PS..(\d+)\}--(>|&gt;)/g, _Replace ) ;
 
202
}
 
 
b'\\ No newline at end of file'