]>
git.immae.eu Git - perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git/blob - sources/core/ckeditor_base.js
1e90d72ec2771174ef4a8e03729cec72584217c2
2 * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
7 * @fileOverview Contains the first and essential part of the {@link CKEDITOR}
11 // #### Compressed Code
12 // Compressed code in ckeditor.js must be be updated on changes in the script.
13 // The Closure Compiler online service should be used when updating this manually:
14 // http://closure-compiler.appspot.com/
17 // ATTENTION: read the above "Compressed Code" notes when changing this code.
19 if ( ! window
. CKEDITOR
) {
21 * This is the API entry point. The entire CKEditor code runs under this object.
25 window
. CKEDITOR
= ( function () {
26 var basePathSrcPattern
= /(^|.*[\\\/])ckeditor\.js(?:\?.*|;.*)?$/i ;
31 * A constant string unique for each release of CKEditor. Its value
32 * is used, by default, to build the URL for all resources loaded
33 * by the editor code, guaranteeing clean cache results when
36 * alert( CKEDITOR.timestamp ); // e.g. '87dm'
38 timestamp : '' , // %REMOVE_LINE%
40 // The production implementation contains a fixed timestamp, unique
41 // for each release and generated by the releaser.
42 // (Base 36 value of each component of YYMMDDHH - 4 chars total - e.g. 87bm == 08071122)
43 timestamp: '%TIMESTAMP%',
47 * Contains the CKEditor version number.
49 * alert( CKEDITOR.version ); // e.g. 'CKEditor 3.4.1'
54 * Contains the CKEditor revision number.
55 * The revision number is incremented automatically, following each
56 * modification to the CKEditor source code.
58 * alert( CKEDITOR.revision ); // e.g. '3975'
63 * A 3-digit random integer, valid for the entire life of the CKEDITOR object.
65 * alert( CKEDITOR.rnd ); // e.g. 319
69 rnd : Math
. floor ( Math
. random () * ( 999 /*Max*/ - 100 /*Min*/ + 1 ) ) + 100 /*Min*/ ,
72 * Private object used to hold core stuff. It should not be used outside of
73 * the API code as properties defined here may change at any time
80 basePathSrcPattern : basePathSrcPattern
84 * Indicates the API loading status. The following statuses are available:
86 * * **unloaded**: the API is not yet loaded.
87 * * **basic_loaded**: the basic API features are available.
88 * * **basic_ready**: the basic API is ready to load the full core code.
89 * * **loaded**: the API can be fully used.
93 * if ( CKEDITOR.status == 'loaded' ) {
94 * // The API can now be fully used.
97 * // Wait for the full core to be loaded and fire its loading.
98 * CKEDITOR.on( 'load', doSomething );
99 * CKEDITOR.loadFullCore && CKEDITOR.loadFullCore();
105 * The full URL for the CKEditor installation directory.
106 * It is possible to manually provide the base path by setting a
107 * global variable named `CKEDITOR_BASEPATH`. This global variable
108 * must be set **before** the editor script loading.
110 * alert( CKEDITOR.basePath ); // e.g. 'http://www.example.com/ckeditor/'
114 basePath : ( function () {
115 // Find out the editor directory path, based on its <script> tag.
116 var path
= window
. CKEDITOR_BASEPATH
|| '' ;
119 var scripts
= document
. getElementsByTagName ( 'script' );
121 for ( var i
= 0 ; i
< scripts
. length
; i
++ ) {
122 var match
= scripts
[ i
]. src
. match ( basePathSrcPattern
);
131 // In IE (only) the script.src string is the raw value entered in the
132 // HTML source. Other browsers return the full resolved URL instead.
133 if ( path
. indexOf ( ':/' ) == - 1 && path
. slice ( 0 , 2 ) != '//' ) {
135 if ( path
. indexOf ( '/' ) === 0 )
136 path
= location
. href
. match ( /^.*?:\/\/[^\/]*/ )[ 0 ] + path
;
139 path
= location
. href
. match ( /^[^\?]*\/(?:)/ )[ 0 ] + path
;
143 throw 'The CKEditor installation path could not be automatically detected. Please set the global variable "CKEDITOR_BASEPATH" before creating editor instances.' ;
149 * Gets the full URL for CKEditor resources. By default, URLs
150 * returned by this function contain a querystring parameter ("t")
151 * set to the {@link CKEDITOR#timestamp} value.
153 * It is possible to provide a custom implementation of this
154 * function by setting a global variable named `CKEDITOR_GETURL`.
155 * This global variable must be set **before** the editor script
156 * loading. If the custom implementation returns nothing (`==null`), the
157 * default implementation is used.
159 * // e.g. 'http://www.example.com/ckeditor/skins/default/editor.css?t=87dm'
160 * alert( CKEDITOR.getUrl( 'skins/default/editor.css' ) );
162 * // e.g. 'http://www.example.com/skins/default/editor.css?t=87dm'
163 * alert( CKEDITOR.getUrl( '/skins/default/editor.css' ) );
165 * // e.g. 'http://www.somesite.com/skins/default/editor.css?t=87dm'
166 * alert( CKEDITOR.getUrl( 'http://www.somesite.com/skins/default/editor.css' ) );
168 * @param {String} resource The resource whose full URL we want to get.
169 * It may be a full, absolute, or relative URL.
170 * @returns {String} The full URL.
172 getUrl : function ( resource
) {
173 // If this is not a full or absolute path.
174 if ( resource
. indexOf ( ':/' ) == - 1 && resource
. indexOf ( '/' ) !== 0 )
175 resource
= this . basePath
+ resource
;
177 // Add the timestamp, except for directories.
178 if ( this . timestamp
&& resource
. charAt ( resource
. length
- 1 ) != '/' && !( /[&?]t=/ ). test ( resource
) )
179 resource
+= ( resource
. indexOf ( '?' ) >= 0 ? '&' : '?' ) + 't=' + this . timestamp
;
185 * Specify a function to execute when the DOM is fully loaded.
187 * If called after the DOM has been initialized, the function passed in will
188 * be executed immediately.
193 domReady : ( function () {
194 // Based on the original jQuery code (available under the MIT license, see LICENSE.md).
200 // Cleanup functions for the document ready method
201 if ( document
. addEventListener
) {
202 document
. removeEventListener ( 'DOMContentLoaded' , onReady
, false );
205 // Make sure body exists, at least, in case IE gets a little overzealous.
206 else if ( document
. attachEvent
&& document
. readyState
=== 'complete' ) {
207 document
. detachEvent ( 'onreadystatechange' , onReady
);
213 function executeCallbacks () {
215 while ( ( i
= callbacks
. shift () ) )
219 return function ( fn
) {
220 callbacks
. push ( fn
);
222 // Catch cases where this is called after the
223 // browser event has already occurred.
224 if ( document
. readyState
=== 'complete' )
225 // Handle it asynchronously to allow scripts the opportunity to delay ready
226 setTimeout ( onReady
, 1 );
228 // Run below once on demand only.
229 if ( callbacks
. length
!= 1 )
232 // For IE>8, Firefox, Opera and Webkit.
233 if ( document
. addEventListener
) {
234 // Use the handy event callback
235 document
. addEventListener ( 'DOMContentLoaded' , onReady
, false );
237 // A fallback to window.onload, that will always work
238 window
. addEventListener ( 'load' , onReady
, false );
241 // If old IE event model is used
242 else if ( document
. attachEvent
) {
243 // ensure firing before onload,
244 // maybe late but safe also for iframes
245 document
. attachEvent ( 'onreadystatechange' , onReady
);
247 // A fallback to window.onload, that will always work
248 window
. attachEvent ( 'onload' , onReady
);
250 // If IE and not a frame
251 // continually check to see if the document is ready
252 // use the trick by Diego Perini
253 // http://javascript.nwbox.com/IEContentLoaded/
254 var toplevel
= false ;
257 toplevel
= ! window
. frameElement
;
260 if ( document
. documentElement
. doScroll
&& toplevel
) {
265 function scrollCheck () {
267 document
. documentElement
. doScroll ( 'left' );
269 setTimeout ( scrollCheck
, 1 );
279 // Make it possible to override the "url" function with a custom
280 // implementation pointing to a global named CKEDITOR_GETURL.
281 var newGetUrl
= window
. CKEDITOR_GETURL
;
283 var originalGetUrl
= CKEDITOR
. getUrl
;
284 CKEDITOR
. getUrl = function ( resource
) {
285 return newGetUrl
. call ( CKEDITOR
, resource
) || originalGetUrl
. call ( CKEDITOR
, resource
);
294 * Function called upon loading a custom configuration file that can
295 * modify the editor instance configuration ({@link CKEDITOR.editor#config}).
296 * It is usually defined inside the custom configuration files that can
297 * include developer defined settings.
299 * // This is supposed to be placed in the config.js file.
300 * CKEDITOR.editorConfig = function( config ) {
301 * // Define changes to default configuration here. For example:
302 * config.language = 'fr';
303 * config.uiColor = '#AADC6E';
306 * @method editorConfig
307 * @param {CKEDITOR.config} config A configuration object containing the
308 * settings defined for a {@link CKEDITOR.editor} instance up to this
309 * function call. Note that not all settings may still be available. See
310 * [Configuration Loading Order](http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Setting_Configurations#Configuration_Loading_Order)
314 // PACKAGER_RENAME( CKEDITOR )