]>
git.immae.eu Git - perso/Immae/Projets/packagist/piedsjaloux-ckeditor-component.git/blob - sources/core/ckeditor_base.js
8c36b11a0c2bc8bdf70621ddab0b27819e5dd682
2 * @license Copyright (c) 2003-2017, 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 * **Note:** There is [a known issue where "icons.png" does not include
37 * timestamp](http://dev.ckeditor.com/ticket/10685) and might get cached.
38 * We are working on having it fixed.
40 * alert( CKEDITOR.timestamp ); // e.g. '87dm'
42 timestamp : '' , // %REMOVE_LINE%
44 // The production implementation contains a fixed timestamp, unique
45 // for each release and generated by the releaser.
46 // (Base 36 value of each component of YYMMDDHH - 4 chars total - e.g. 87bm == 08071122)
47 timestamp: '%TIMESTAMP%',
51 * Contains the CKEditor version number.
53 * alert( CKEDITOR.version ); // e.g. 'CKEditor 3.4.1'
58 * Contains the CKEditor revision number.
59 * The revision number is incremented automatically, following each
60 * modification to the CKEditor source code.
62 * alert( CKEDITOR.revision ); // e.g. '3975'
67 * A 3-digit random integer, valid for the entire life of the CKEDITOR object.
69 * alert( CKEDITOR.rnd ); // e.g. 319
73 rnd : Math
. floor ( Math
. random () * ( 999 /*Max*/ - 100 /*Min*/ + 1 ) ) + 100 /*Min*/ ,
76 * Private object used to hold core stuff. It should not be used outside of
77 * the API code as properties defined here may change at any time
84 basePathSrcPattern : basePathSrcPattern
88 * Indicates the API loading status. The following statuses are available:
90 * * **unloaded**: the API is not yet loaded.
91 * * **basic_loaded**: the basic API features are available.
92 * * **basic_ready**: the basic API is ready to load the full core code.
93 * * **loaded**: the API can be fully used.
97 * if ( CKEDITOR.status == 'loaded' ) {
98 * // The API can now be fully used.
101 * // Wait for the full core to be loaded and fire its loading.
102 * CKEDITOR.on( 'load', doSomething );
103 * CKEDITOR.loadFullCore && CKEDITOR.loadFullCore();
109 * The full URL for the CKEditor installation directory.
110 * It is possible to manually provide the base path by setting a
111 * global variable named `CKEDITOR_BASEPATH`. This global variable
112 * must be set **before** the editor script loading.
114 * alert( CKEDITOR.basePath ); // e.g. 'http://www.example.com/ckeditor/'
118 basePath : ( function () {
119 // Find out the editor directory path, based on its <script> tag.
120 var path
= window
. CKEDITOR_BASEPATH
|| '' ;
123 var scripts
= document
. getElementsByTagName ( 'script' );
125 for ( var i
= 0 ; i
< scripts
. length
; i
++ ) {
126 var match
= scripts
[ i
]. src
. match ( basePathSrcPattern
);
135 // In IE (only) the script.src string is the raw value entered in the
136 // HTML source. Other browsers return the full resolved URL instead.
137 if ( path
. indexOf ( ':/' ) == - 1 && path
. slice ( 0 , 2 ) != '//' ) {
139 if ( path
. indexOf ( '/' ) === 0 )
140 path
= location
. href
. match ( /^.*?:\/\/[^\/]*/ )[ 0 ] + path
;
143 path
= location
. href
. match ( /^[^\?]*\/(?:)/ )[ 0 ] + path
;
147 throw 'The CKEditor installation path could not be automatically detected. Please set the global variable "CKEDITOR_BASEPATH" before creating editor instances.' ;
153 * Gets the full URL for CKEditor resources. By default, URLs
154 * returned by this function contain a querystring parameter ("t")
155 * set to the {@link CKEDITOR#timestamp} value.
157 * It is possible to provide a custom implementation of this
158 * function by setting a global variable named `CKEDITOR_GETURL`.
159 * This global variable must be set **before** the editor script
160 * loading. If the custom implementation returns nothing (`==null`), the
161 * default implementation is used.
163 * // e.g. 'http://www.example.com/ckeditor/skins/default/editor.css?t=87dm'
164 * alert( CKEDITOR.getUrl( 'skins/default/editor.css' ) );
166 * // e.g. 'http://www.example.com/skins/default/editor.css?t=87dm'
167 * alert( CKEDITOR.getUrl( '/skins/default/editor.css' ) );
169 * // e.g. 'http://www.somesite.com/skins/default/editor.css?t=87dm'
170 * alert( CKEDITOR.getUrl( 'http://www.somesite.com/skins/default/editor.css' ) );
172 * @param {String} resource The resource whose full URL we want to get.
173 * It may be a full, absolute, or relative URL.
174 * @returns {String} The full URL.
176 getUrl : function ( resource
) {
177 // If this is not a full or absolute path.
178 if ( resource
. indexOf ( ':/' ) == - 1 && resource
. indexOf ( '/' ) !== 0 )
179 resource
= this . basePath
+ resource
;
181 // Add the timestamp, except for directories.
182 if ( this . timestamp
&& resource
. charAt ( resource
. length
- 1 ) != '/' && !( /[&?]t=/ ). test ( resource
) )
183 resource
+= ( resource
. indexOf ( '?' ) >= 0 ? '&' : '?' ) + 't=' + this . timestamp
;
189 * Specify a function to execute when the DOM is fully loaded.
191 * If called after the DOM has been initialized, the function passed in will
192 * be executed immediately.
197 domReady : ( function () {
198 // Based on the original jQuery code (available under the MIT license, see LICENSE.md).
204 // Cleanup functions for the document ready method
205 if ( document
. addEventListener
) {
206 document
. removeEventListener ( 'DOMContentLoaded' , onReady
, false );
209 // Make sure body exists, at least, in case IE gets a little overzealous.
210 else if ( document
. attachEvent
&& document
. readyState
=== 'complete' ) {
211 document
. detachEvent ( 'onreadystatechange' , onReady
);
217 function executeCallbacks () {
219 while ( ( i
= callbacks
. shift () ) )
223 return function ( fn
) {
224 callbacks
. push ( fn
);
226 // Catch cases where this is called after the
227 // browser event has already occurred.
228 if ( document
. readyState
=== 'complete' )
229 // Handle it asynchronously to allow scripts the opportunity to delay ready
230 setTimeout ( onReady
, 1 );
232 // Run below once on demand only.
233 if ( callbacks
. length
!= 1 )
236 // For IE>8, Firefox, Opera and Webkit.
237 if ( document
. addEventListener
) {
238 // Use the handy event callback
239 document
. addEventListener ( 'DOMContentLoaded' , onReady
, false );
241 // A fallback to window.onload, that will always work
242 window
. addEventListener ( 'load' , onReady
, false );
245 // If old IE event model is used
246 else if ( document
. attachEvent
) {
247 // ensure firing before onload,
248 // maybe late but safe also for iframes
249 document
. attachEvent ( 'onreadystatechange' , onReady
);
251 // A fallback to window.onload, that will always work
252 window
. attachEvent ( 'onload' , onReady
);
254 // If IE and not a frame
255 // continually check to see if the document is ready
256 // use the trick by Diego Perini
257 // http://javascript.nwbox.com/IEContentLoaded/
258 var toplevel
= false ;
261 toplevel
= ! window
. frameElement
;
264 if ( document
. documentElement
. doScroll
&& toplevel
) {
269 function scrollCheck () {
271 document
. documentElement
. doScroll ( 'left' );
273 setTimeout ( scrollCheck
, 1 );
283 // Make it possible to override the "url" function with a custom
284 // implementation pointing to a global named CKEDITOR_GETURL.
285 var newGetUrl
= window
. CKEDITOR_GETURL
;
287 var originalGetUrl
= CKEDITOR
. getUrl
;
288 CKEDITOR
. getUrl = function ( resource
) {
289 return newGetUrl
. call ( CKEDITOR
, resource
) || originalGetUrl
. call ( CKEDITOR
, resource
);
298 * Function called upon loading a custom configuration file that can
299 * modify the editor instance configuration ({@link CKEDITOR.editor#config}).
300 * It is usually defined inside the custom configuration files that can
301 * include developer defined settings.
303 * // This is supposed to be placed in the config.js file.
304 * CKEDITOR.editorConfig = function( config ) {
305 * // Define changes to default configuration here. For example:
306 * config.language = 'fr';
307 * config.uiColor = '#AADC6E';
310 * @method editorConfig
311 * @param {CKEDITOR.config} config A configuration object containing the
312 * settings defined for a {@link CKEDITOR.editor} instance up to this
313 * function call. Note that not all settings may still be available. See
314 * [Configuration Loading Order](http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Setting_Configurations#Configuration_Loading_Order)
318 // PACKAGER_RENAME( CKEDITOR )