# CKEditor 3.0 JavaScript API Documentation

Code Index | File Index

## Namespaces

- CKEDITOR
- CKEDITOR.ajax
- CKEDITOR.config
- CKEDITOR.dom
- CKEDITOR.dtd
- CKEDITOR.env
- CKEDITOR.imageCacher
- CKEDITOR.loader
- CKEDITOR.plugins
- CKEDITOR.resourceManager
- CKEDITOR.scriptLoader
- CKEDITOR.skins
- CKEDITOR.test
- CKEDITOR.themes
- CKEDITOR.tools

## Classes

- CKEDITOR.commandDefinition
- CKEDITOR.dialog
- CKEDITOR.dialog.buttonDefinition
- CKEDITOR.dialog.contentDefinition
- CKEDITOR.dialog.contentDefinitionObject
- CKEDITOR.dialog.dialogDefinition
- CKEDITOR.dialog.dialogDefinitionObject
- CKEDITOR.dialog.uiElementDefinition
- CKEDITOR.dialogCommand
- CKEDITOR.dom.document
- CKEDITOR.dom.domObject
- CKEDITOR.dom.element
- CKEDITOR.dom.event
- CKEDITOR.dom.node
- CKEDITOR.dom.selection
- CKEDITOR.dom.text
- CKEDITOR.dom.window
- CKEDITOR.editor
- CKEDITOR.event
- CKEDITOR.eventInfo
- CKEDITOR.focusManager
- CKEDITOR.htmlParser
- CKEDITOR.htmlParser.cdata
- CKEDITOR.htmlParser.comment
- CKEDITOR.htmlParser.element
- CKEDITOR.htmlParser.fragment
- CKEDITOR.htmlParser.text
- CKEDITOR.htmlWriter
- CKEDITOR.keystrokeHandler
- CKEDITOR.pluginDefinition
- CKEDITOR.ui
- CKEDITOR.ui.button
- CKEDITOR.ui.dialog.button
- CKEDITOR.ui.dialog.checkbox
- CKEDITOR.ui.dialog.file
- CKEDITOR.ui.dialog.fileButton
- CKEDITOR.ui.dialog.hbox
- CKEDITOR.ui.dialog.html
- CKEDITOR.ui.dialog.labeledElement
- CKEDITOR.ui.dialog.radio
- CKEDITOR.ui.dialog.select
- CKEDITOR.ui.dialog.textarea
- CKEDITOR.ui.dialog.textInput
- CKEDITOR.ui.dialog.uiElement
- CKEDITOR.ui.dialog.vbox
- CKEDITOR.ui.handlerDefinition
- CKEDITOR.xml

# Namespace CKEDITOR.tools

Utility functions.
Defined in: core/tools.js.

Namespace Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| CKEDITOR.tools Utility functions.

Field Summary
Field Attributes | Field Name and Description
--- | ---
<static> | CKEDITOR.tools.indexOf Returns the index of an element in an array.

Method Summary
Method Attributes | Method Name and Description
--- | ---
<static> | CKEDITOR.tools.addFunction(fn, scope)
<static> | CKEDITOR.tools.arrayCompare(arrayA, arrayB)
<static> | CKEDITOR.tools.bind(func, obj)
<static> | CKEDITOR.tools.callFunction(index)
<static> | CKEDITOR.tools.clone(object) Creates a deep copy of an object.
<static> | CKEDITOR.tools.createClass(definiton) Class creation based on prototype inheritance, with supports of the following features: Static fields Private fields Public(prototype) fields Chainable base class constructor
<static> | CKEDITOR.tools.cssStyleToDomStyle(cssName) Transforms a CSS property name to its relative DOM style name.
<static> | CKEDITOR.tools.extend(target, source[,souce(n)], overwrite, properties) Copy the properties from one object to another.
<static> | CKEDITOR.tools.getNextNumber() Gets a unique number for this CKEDITOR execution session.
<static> | CKEDITOR.tools.htmlEncode(text) Replace special HTML characters in a string with their relative HTML entity values.
<static> | CKEDITOR.tools.isArray(object) Checks if an object is an Array.
<static> | CKEDITOR.tools.ltrim(str) Remove spaces from the start (left) of a string.
<static> | CKEDITOR.tools.override(originalFunction, functionBuilder) Creates a function override.
<static> | CKEDITOR.tools.rtrim(str) Remove spaces from the end (right) of a string.
<static> | CKEDITOR.tools.setTimeout(func, milliseconds, scope, args, ownerWindow) Executes a function after specified delay.
<static> | CKEDITOR.tools.trim(str) Remove spaces from the start and the end of a string.
| dCopy(source) Creates an object which is an instance of a class which prototype is a predefined object.

Namespace Detail
CKEDITOR.tools
Since: 3.0
Utility functions.
Field Detail
<static> {Number} CKEDITOR.tools.indexOf
Since: 3.0
Returns the index of an element in an array.

    var letters = [ 'a', 'b', 0, 'c', false ];
    alert( CKEDITOR.tools.indexOf( letters, '0' ) );  "-1" because 0 !== '0'
    alert( CKEDITOR.tools.indexOf( letters, false ) );  "4" because 0 !== false

Method Detail
<static> {Undefined} CKEDITOR.tools.addFunction(fn, scope)
Since: 3.0

    NO EXAMPLE AVAILABLE

Parameters:
{Undefined} fn
{Undefined} scope

<static> {Undefined} CKEDITOR.tools.arrayCompare(arrayA, arrayB)
Since: 3.0

    NO EXAMPLE AVAILABLE

Parameters:
{Undefined} arrayA
{Undefined} arrayB

<static> {Undefined} CKEDITOR.tools.bind(func, obj)
Since: 3.0

    NO EXAMPLE AVAILABLE

Parameters:
{Undefined} func
{Undefined} obj

<static> {Undefined} CKEDITOR.tools.callFunction(index)
Since: 3.0

    NO EXAMPLE AVAILABLE

Parameters:
{Undefined} index

<static> {Object} CKEDITOR.tools.clone(object)
Since: 3.0
Creates a deep copy of an object. Attention: there is no support for recursive references.

    var obj =
        {
            name : 'John',
            cars :
                {
                    Mercedes : { color : 'blue' },
                    Porsche : { color : 'red' }
                }
        };
    var clone = CKEDITOR.tools.clone( obj );
    clone.name = 'Paul';
    clone.cars.Porsche.color = 'silver';
    alert( obj.name );	// John
    alert( clone.name );	// Paul
    alert( obj.cars.Porsche.color );	// red
    alert( clone.cars.Porsche.color );	// silver

Parameters:
{Object} object
  The object to be cloned.

Returns:
  {Object} The object clone.

<static> {Undefined} CKEDITOR.tools.createClass(definiton)
Since: 3.0
Class creation based on prototype inheritance, with supports of the following features:

- Static fields
- Private fields
- Public(prototype) fields
- Chainable base class constructor

    NO EXAMPLE AVAILABLE

Parameters:
{Object} definiton
  (Optional)The class definiton object.

<static> {String} CKEDITOR.tools.cssStyleToDomStyle(cssName)
Since: 3.0
Transforms a CSS property name to its relative DOM style name.

    alert( CKEDITOR.tools.cssStyleToDomStyle( 'background-color' ) );  // "backgroundColor"
    alert( CKEDITOR.tools.cssStyleToDomStyle( 'float' ) );             // "cssFloat"

Parameters:
{String} cssName
  The CSS property name.

Returns:
  {String} The transformed name.

<static> {Object} CKEDITOR.tools.extend(target, source[,souce(n)], overwrite, properties)
Since: 3.0
Copy the properties from one object to another. By default, properties already present in the target object are not overwritten.

    // Create the sample object.
    var myObject =
    {
        prop1 : true
    };

    // Extend the above object with two properties.
    CKEDITOR.tools.extend( myObject,
        {
            prop2 : true,
            prop3 : true
        } );

    // Alert "prop1", "prop2" and "prop3".
    for ( var p in myObject )
        alert( p );

Parameters:
{Object} target
  The object to be extended.
{Object} source[,souce(n)]
  The objects from which copy properties. Any number of objects can be passed to this function.
{Boolean} overwrite Optional
  If 'true' is specified it indicates that properties already present in the target object could be overwritten by subsequent objects.
{Object} properties Optional
  Only properties within the specified names list will be received from the source object.

Returns:
  {Object} the extended object (target).

<static> {Number} CKEDITOR.tools.getNextNumber()
Since: 3.0
Gets a unique number for this CKEDITOR execution session. It returns progressive numbers starting at 1.

    alert( CKEDITOR.tools.getNextNumber() );  // "1" (e.g.)
    alert( CKEDITOR.tools.getNextNumber() );  // "2"

Returns:
  {Number} A unique number.

<static> {String} CKEDITOR.tools.htmlEncode(text)
Since: 3.0
Replace special HTML characters in a string with their relative HTML entity values.

    alert( CKEDITOR.tools.htmlEncode( 'A > B & C < D' ) );  // "A &gt; B &amp; C &lt; D"

Parameters:
{String} text
  The string to be encoded.

Returns:
  {String} The encode string.

<static> {Boolean} CKEDITOR.tools.isArray(object)
Since: 3.0
Checks if an object is an Array.

    alert( CKEDITOR.tools.isArray( [] ) );      // "true"
    alert( CKEDITOR.tools.isArray( 'Test' ) );  // "false"

Parameters:
{Object} object
  The object to be checked.

Returns:
  {Undefined} true if the object is an Array, otherwise false.

<static> {String} CKEDITOR.tools.ltrim(str)
Since: 3.0
Remove spaces from the start (left) of a string. The following characters are removed: space, tab, line break, line feed.

    alert( CKEDITOR.tools.ltrim( '  example ' );  // "example "

Parameters:
{String} str
  The text from which remove the spaces.

Returns:
  {String} The modified string excluding the removed spaces.

<static> {Function} CKEDITOR.tools.override(originalFunction, functionBuilder)
Since: 3.0
Creates a function override.

    var example =
    {
        myFunction : function( name )
        {
            alert( 'Name: ' + name );
        }
    };

    example.myFunction = CKEDITOR.tools.override( example.myFunction, function( myFunctionOriginal )
        {
            return function( name )
                {
                    alert( 'Override Name: ' + name );
                    myFunctionOriginal.call( this, name );
                };
        });

Parameters:
{Function} originalFunction
  The function to be overridden.
{Function} functionBuilder
  A function that returns the new function. The original function reference will be passed to this function.

Returns:
  {Function} The new function.

<static> {String} CKEDITOR.tools.rtrim(str)
Since: 3.0
Remove spaces from the end (right) of a string. The following characters are removed: space, tab, line break, line feed.

    alert( CKEDITOR.tools.ltrim( '  example ' );  // "  example"

Parameters:
{String} str
  The text from which remove the spaces.

Returns:
  {String} The modified string excluding the removed spaces.

<static> {Object} CKEDITOR.tools.setTimeout(func, milliseconds, scope, args, ownerWindow)
Since: 3.0
Executes a function after specified delay.

    CKEDITOR.tools.setTimeout(
        function()
        {
            alert( 'Executed after 2 seconds' );
        },
        2000 );

Parameters:
{Function} func
  The function to be executed.
{Number} milliseconds Optional
  The amount of time (millisecods) to wait to fire the function execution. Defaults to zero.
{Object} scope Optional
  The object to hold the function execution scope (the "this" object). By default the "window" object.
{Object|Array} args Optional
  A single object, or an array of objects, to pass as arguments to the function.
{Object} ownerWindow Optional
  The window that will be used to set the timeout. By default the current "window".

Returns:
  {Object} A value that can be used to cancel the function execution.

<static> {String} CKEDITOR.tools.trim(str)
Since: 3.0
Remove spaces from the start and the end of a string. The following characters are removed: space, tab, line break, line feed.

    alert( CKEDITOR.tools.trim( '  example ' );  // "example"

Parameters:
{String} str
  The text from which remove the spaces.

Returns:
  {String} The modified string without the boundary spaces.

{Object} dCopy(source)
Since: 3.0
Creates an object which is an instance of a class which prototype is a predefined object. All properties defined in the source object are automatically inherited by the resulting object, including future changes to it.

    NO EXAMPLE AVAILABLE

Parameters:
{Object} source
  The source object to be used as the prototype for the final object.

Returns:
  {Object} The resulting copy.

Copyright © 2003-2009, CKSource - Frederico Knabben. All rights reserved.