1 | Index: editor/_source/internals/fcktools_gecko.js |
---|
2 | =================================================================== |
---|
3 | --- editor/_source/internals/fcktools_gecko.js (revision 1092) |
---|
4 | +++ editor/_source/internals/fcktools_gecko.js (working copy) |
---|
5 | @@ -38,12 +38,21 @@ |
---|
6 | // Appends a CSS file to a document. |
---|
7 | FCKTools._AppendStyleSheet = function( documentElement, cssFileUrl ) |
---|
8 | { |
---|
9 | - var e = documentElement.createElement( 'LINK' ) ; |
---|
10 | - e.rel = 'stylesheet' ; |
---|
11 | - e.type = 'text/css' ; |
---|
12 | - e.href = cssFileUrl ; |
---|
13 | - documentElement.getElementsByTagName("HEAD")[0].appendChild( e ) ; |
---|
14 | - return e ; |
---|
15 | + var cssText = FCKCSSManager.GetCachedCSS( cssFileUrl ) ; |
---|
16 | + |
---|
17 | + if ( cssText == null ) |
---|
18 | + { |
---|
19 | + var e = documentElement.createElement( 'LINK' ) ; |
---|
20 | + e.rel = 'stylesheet' ; |
---|
21 | + e.type = 'text/css' ; |
---|
22 | + e.href = cssFileUrl ; |
---|
23 | + documentElement.getElementsByTagName( "HEAD" )[0].appendChild( e ) ; |
---|
24 | + return e ; |
---|
25 | + } |
---|
26 | + else |
---|
27 | + { |
---|
28 | + return FCKTools._AppendStyleString( documentElement, cssText ) ; |
---|
29 | + } |
---|
30 | } |
---|
31 | |
---|
32 | // Appends a CSS style string to a document. |
---|
33 | Index: editor/_source/internals/fcktools_ie.js |
---|
34 | =================================================================== |
---|
35 | --- editor/_source/internals/fcktools_ie.js (revision 1092) |
---|
36 | +++ editor/_source/internals/fcktools_ie.js (working copy) |
---|
37 | @@ -29,7 +29,16 @@ |
---|
38 | // Appends one or more CSS files to a document. |
---|
39 | FCKTools._AppendStyleSheet = function( documentElement, cssFileUrl ) |
---|
40 | { |
---|
41 | - return documentElement.createStyleSheet( cssFileUrl ).owningElement ; |
---|
42 | + var cssText = FCKCSSManager.GetCachedCSS( cssFileUrl ); |
---|
43 | + |
---|
44 | + if ( cssText ) |
---|
45 | + { |
---|
46 | + return FCKTools._AppendStyleString( documentElement, cssText ) ; |
---|
47 | + } |
---|
48 | + else |
---|
49 | + { |
---|
50 | + return documentElement.createStyleSheet( cssFileUrl ).owningElement ; |
---|
51 | + } |
---|
52 | } |
---|
53 | |
---|
54 | // Appends a CSS style string to a document. |
---|
55 | Index: editor/_source/internals/fckcssmanager.js |
---|
56 | =================================================================== |
---|
57 | --- editor/_source/internals/fckcssmanager.js (revision 0) |
---|
58 | +++ editor/_source/internals/fckcssmanager.js (revision 0) |
---|
59 | @@ -0,0 +1,89 @@ |
---|
60 | +/* |
---|
61 | +* FCKeditor - The text editor for Internet - http://www.fckeditor.net |
---|
62 | +* This file copyright (C) 2007 PBwiki, Inc. |
---|
63 | +* |
---|
64 | +* == BEGIN LICENSE == |
---|
65 | +* |
---|
66 | +* Licensed under the terms of any of the following licenses at your |
---|
67 | +* choice: |
---|
68 | +* |
---|
69 | +* - GNU General Public License Version 2 or later (the "GPL") |
---|
70 | +* http://www.gnu.org/licenses/gpl.html |
---|
71 | +* |
---|
72 | +* - GNU Lesser General Public License Version 2.1 or later (the "LGPL") |
---|
73 | +* http://www.gnu.org/licenses/lgpl.html |
---|
74 | +* |
---|
75 | +* - Mozilla Public License Version 1.1 or later (the "MPL") |
---|
76 | +* http://www.mozilla.org/MPL/MPL-1.1.html |
---|
77 | +* |
---|
78 | +* == END LICENSE == |
---|
79 | +* |
---|
80 | +*/ |
---|
81 | + |
---|
82 | +var FCKCSSManager = |
---|
83 | +{ |
---|
84 | + CachedCSS : {}, |
---|
85 | + |
---|
86 | + AddCachedCSS : function( path, value ) |
---|
87 | + { |
---|
88 | + FCKCSSManager.CachedCSS[ path ] = value ; |
---|
89 | + }, |
---|
90 | + |
---|
91 | + _ProcessPath : function( path ) |
---|
92 | + { |
---|
93 | + if ( !path ) |
---|
94 | + return null ; |
---|
95 | + |
---|
96 | + if ( path.substr( 0, FCKConfig.BasePath.length ) == FCKConfig.BasePath ) |
---|
97 | + path = path.substr( FCKConfig.BasePath.length ).replace( /^\//, "" ) ; |
---|
98 | + |
---|
99 | + return path; |
---|
100 | + }, |
---|
101 | + |
---|
102 | + GetCachedCSS : function( path ) |
---|
103 | + { |
---|
104 | + if ( !path ) |
---|
105 | + return null ; |
---|
106 | + |
---|
107 | + var relativePath = FCKCSSManager._ProcessPath( path ) ; |
---|
108 | + |
---|
109 | + if ( !FCKCSSManager.CachedCSS[ relativePath ] ) |
---|
110 | + return null ; |
---|
111 | + |
---|
112 | + var cachedCSS = FCKCSSManager.CachedCSS[ relativePath ]; |
---|
113 | + |
---|
114 | + var pathPrefix = path.replace( /\/[^\/]+\.css$/i, "/" ); |
---|
115 | + pathPrefix.replace( /^[^\/]*$/, "" ); |
---|
116 | + |
---|
117 | + function pathReplace ( str, prefix, path, suffix, cache_path ) { |
---|
118 | + if ( path.match( /^http|^\// ) ) |
---|
119 | + return "url(" + prefix + path + suffix + ")" ; |
---|
120 | + else |
---|
121 | + return "url(" + prefix + cache_path + path + suffix + ")" ; |
---|
122 | + } |
---|
123 | + |
---|
124 | + cachedCSS = cachedCSS.replace( /url *\(([ '"]*)(.*?)([ "']*)\)/g, |
---|
125 | + ( function( a, b, c, d, e, f, g) { return pathReplace( a, b, c, d, pathPrefix ) ; } ) ); |
---|
126 | + |
---|
127 | + return cachedCSS ; |
---|
128 | + }, |
---|
129 | + |
---|
130 | + GetCSSInclude : function( path ) |
---|
131 | + { |
---|
132 | + if ( !path ) |
---|
133 | + return null ; |
---|
134 | + |
---|
135 | + var cachedCSS = FCKCSSManager.GetCachedCSS( path ) ; |
---|
136 | + |
---|
137 | + if ( !cachedCSS ) |
---|
138 | + return( '<link href="' + path + '" type="text/css" rel="stylesheet" />' ) ; |
---|
139 | + |
---|
140 | + return( '<sty' + 'le type="text/css">' + cachedCSS + '</st' + 'yle>' ) ; |
---|
141 | + }, |
---|
142 | + |
---|
143 | + PrintCSSInclude : function( path ) |
---|
144 | + { |
---|
145 | + document.write( FCKCSSManager.GetCSSInclude( path ) ) ; |
---|
146 | + } |
---|
147 | +} ; |
---|
148 | + |
---|
149 | Index: editor/fckeditor.html |
---|
150 | =================================================================== |
---|
151 | --- editor/fckeditor.html (revision 1092) |
---|
152 | +++ editor/fckeditor.html (working copy) |
---|
153 | @@ -43,7 +43,7 @@ |
---|
154 | |
---|
155 | function LoadCss( url ) |
---|
156 | { |
---|
157 | - document.write( '<link href="' + url + '" type="text/css" rel="stylesheet" />' ) ; |
---|
158 | + FCKCSSManager.PrintCSSInclude( url ) ; |
---|
159 | } |
---|
160 | |
---|
161 | // Main editor scripts. |
---|
162 | @@ -147,6 +147,7 @@ |
---|
163 | LoadScript( '_source/classes/fckmenublockpanel.js' ) ; |
---|
164 | LoadScript( '_source/classes/fckcontextmenu.js' ) ; |
---|
165 | LoadScript( '_source/internals/fck_contextmenu.js' ) ; |
---|
166 | +LoadScript( '_source/internals/fckcssmanager.js' ) ; |
---|
167 | LoadScript( '_source/classes/fckplugin.js' ) ; |
---|
168 | LoadScript( '_source/internals/fckplugins.js' ) ; |
---|
169 | |
---|
170 | Index: fckpackager.xml |
---|
171 | =================================================================== |
---|
172 | --- fckpackager.xml (revision 1092) |
---|
173 | +++ fckpackager.xml (working copy) |
---|
174 | @@ -161,6 +161,15 @@ |
---|
175 | |
---|
176 | <File path="editor/_source/classes/fckplugin.js" /> |
---|
177 | <File path="editor/_source/internals/fckplugins.js" /> |
---|
178 | + |
---|
179 | + <File path="editor/_source/internals/fckcssmanager.js" /> |
---|
180 | + <File path="editor/skins/silver/fck_editor.css" /> |
---|
181 | + <File path="editor/css/fck_editorarea.css" /> |
---|
182 | + <File path="editor/css/fck_internal.css" /> |
---|
183 | </PackageFile> |
---|
184 | |
---|
185 | <PackageFile path="editor/js/fckeditorcode_gecko.js"> |
---|
186 | @@ -255,8 +264,18 @@ |
---|
187 | <File path="editor/_source/classes/fckcontextmenu.js" /> |
---|
188 | <File path="editor/_source/internals/fck_contextmenu.js" /> |
---|
189 | |
---|
190 | + <File path="editor/_source/internals/fckcssmanager.js" /> |
---|
191 | + <File path="editor/skins/silver/fck_editor.css" /> |
---|
192 | + <File path="editor/css/fck_showtableborders_gecko.css" /> |
---|
193 | + <File path="editor/css/fck_editorarea.css" /> |
---|
194 | + <File path="editor/css/fck_internal.css" /> |
---|
195 | + |
---|
196 | <File path="editor/_source/classes/fckplugin.js" /> |
---|
197 | <File path="editor/_source/internals/fckplugins.js" /> |
---|
198 | </PackageFile> |
---|
199 | |
---|
200 | </Package> |
---|
201 | Index: /home/chris/fckeditor/trunk/FCKpackager/trunk/fckpackager.php |
---|
202 | =================================================================== |
---|
203 | --- /home/chris/fckeditor/trunk/FCKpackager/trunk/fckpackager.php (revision 1090) |
---|
204 | +++ /home/chris/fckeditor/trunk/FCKpackager/trunk/fckpackager.php (working copy) |
---|
205 | @@ -493,10 +493,21 @@ |
---|
206 | echo ' Adding ' . basename( $file ) . "\n" ; |
---|
207 | |
---|
208 | // Compress (if needed) and process its contents. |
---|
209 | - if ( $this->CompactJavaScript ) |
---|
210 | - $outputData .= FCKJavaScriptCompressor::Compress( FCKPreProcessor::Process( $data ), $this->ConstantsProcessor ) ; |
---|
211 | + if ( preg_match( '/\.js$/', $file ) ) |
---|
212 | + { |
---|
213 | + if ( $this->CompactJavaScript ) |
---|
214 | + $outputData .= FCKJavaScriptCompressor::Compress( FCKPreProcessor::Process( $data ), $this->ConstantsProcessor ) ; |
---|
215 | + else |
---|
216 | + $outputData .= FCKPreProcessor::Process( $data ) ; |
---|
217 | + } |
---|
218 | + else if ( preg_match( '/\.css$/', $file ) ) |
---|
219 | + { |
---|
220 | + $outputData .= FCKCSSProcessor::Process( $data, $file ) ; |
---|
221 | + } |
---|
222 | else |
---|
223 | - $outputData .= FCKPreProcessor::Process( $data ) ; |
---|
224 | + { |
---|
225 | + echo " Unknown file type, not added!\n"; |
---|
226 | + } |
---|
227 | |
---|
228 | // Each file terminates with a CRLF, even if compressed. |
---|
229 | $outputData .= "\r\n" ; |
---|
230 | @@ -659,7 +670,19 @@ |
---|
231 | ?> |
---|
232 | <?php |
---|
233 | |
---|
234 | +class FCKCSSProcessor |
---|
235 | +{ |
---|
236 | + function FCKCSSProcessor( ) |
---|
237 | + { } |
---|
238 | |
---|
239 | + // Intended to be static |
---|
240 | + function Process( $data, $filename ) |
---|
241 | + { |
---|
242 | + $def = "FCKCSSManager.AddCachedCSS(" . json_encode( str_replace( 'editor/', '', $filename ) ) . ",". json_encode( $data ) .");" ; |
---|
243 | + return $inc . $def ; |
---|
244 | + } |
---|
245 | +} |
---|
246 | + |
---|
247 | class FCKPreProcessor |
---|
248 | { |
---|
249 | function FCKPreProcessor() |
---|
250 | @@ -873,4 +896,4 @@ |
---|
251 | } |
---|
252 | } |
---|
253 | |
---|
254 | -?> |
---|
255 | \ No newline at end of file |
---|
256 | +?> |
---|