Code Index | File Index

Namespaces

Classes


Namespace CKEDITOR.tools


Defined in: core/tools.js.

Field Summary
Field Attributes Field Name and Description
<static>  
CKEDITOR.tools.convertToPx
Convert the specified CSS length value to the calculated pixel length inside this page.
<static>  
CKEDITOR.tools.cssLength
Append the 'px' length unit to the size if it's missing.
<static>  
CKEDITOR.tools.cssStyleToDomStyle
Transforms a CSS property name to its relative DOM style name.
<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)
Creates a function reference that can be called later using CKEDITOR.tools.callFunction.
<static>  
CKEDITOR.tools.arrayCompare(arrayA, arrayB)
Compare the elements of two arrays.
<static>  
CKEDITOR.tools.bind(func, obj)
Creates a function that will always execute in the context of a specified object.
<static>  
CKEDITOR.tools.buildStyleHtml(css)
Build the HTML snippet of a set of <style>/<link>.
<static>  
CKEDITOR.tools.buildTableMap(table)
Create a two-dimension array that reflects the actual layout of table cells, with cell spans, with mappings to the original td elements.
<static>  
CKEDITOR.tools.callFunction(ref, params)
Executes a function based on the reference created with CKEDITOR.tools.addFunction.
<static>  
CKEDITOR.tools.capitalize(str)
Turn the first letter of string to upper-case.
<static>  
CKEDITOR.tools.clone(object)
Creates a deep copy of an object.
<static>  
CKEDITOR.tools.convertRgbToHex(styleText)
Find and convert rgb(x,x,x) colors definition to hexadecimal notation.
<static>  
CKEDITOR.tools.createClass(definition)
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.extend(target, source[,souce(n)], overwrite, properties)
Copy the properties from one object to another.
<static>  
CKEDITOR.tools.genKey(subKey)
Generate a combined key from a series of params.
<static>  
CKEDITOR.tools.getNextId()
Gets a unique ID for CKEditor's interface elements.
<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.htmlEncodeAttr(The)
Replace special HTML characters in HTMLElement's attribute with their relative HTML entity values.
<static>  
CKEDITOR.tools.isArray(object)
Checks if an object is an Array.
<static>  
CKEDITOR.tools.isEmpty(object)
Whether the object contains no properties of it's own.
<static>  
CKEDITOR.tools.ltrim(str)
Remove spaces from the start (left) of a string.
<static>  
CKEDITOR.tools.normalizeCssText(styleText, nativeNormalize)
Try to avoid differences in the style attribute.
<static>  
CKEDITOR.tools.override(originalFunction, functionBuilder)
Creates a function override.
<static>  
CKEDITOR.tools.parseCssText(styleText, normalize, nativeNormalize)
Turn inline style text properties into one hash.
<static>  
CKEDITOR.tools.removeFunction(ref)
Removes the function reference created with {@see CKEDITOR.tools.addFunction}.
<static>  
CKEDITOR.tools.repeat(str, times)
String specified by {@param str} repeats {@param times} times.
<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.
<static>  
CKEDITOR.tools.tryThese()
Return the first successfully executed function's return value that doesn't throw any exception.
 
dCopy(source)
Creates an object which is an instance of a class which prototype is a predefined object.
Field Detail
<static> {Undefined} CKEDITOR.tools.convertToPx
Since: 3.0
Convert the specified CSS length value to the calculated pixel length inside this page. Note: Percentage based value is left intact.
NO EXAMPLE AVAILABLE

<static> {Undefined} CKEDITOR.tools.cssLength
Since: 3.0
Append the 'px' length unit to the size if it's missing.
NO EXAMPLE AVAILABLE

<static> {String} CKEDITOR.tools.cssStyleToDomStyle
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"

<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> {Number} CKEDITOR.tools.addFunction(fn, scope)
Since: 3.0
Creates a function reference that can be called later using CKEDITOR.tools.callFunction. This approach is specially useful to make DOM attribute function calls to JavaScript defined functions.
var ref = CKEDITOR.tools.addFunction(
    function()
    {
        alert( 'Hello!');
    });
CKEDITOR.tools.callFunction( ref );  // Hello!
Parameters:
{Function} fn
The function to be executed on call.
{Object} scope Optional
The object to have the context on "fn" execution.
Returns:
{Number} A unique reference to be used in conjuction with CKEDITOR.tools.callFunction.

<static> {Boolean} CKEDITOR.tools.arrayCompare(arrayA, arrayB)
Since: 3.0
Compare the elements of two arrays.
var a = [ 1, 'a', 3 ];
var b = [ 1, 3, 'a' ];
var c = [ 1, 'a', 3 ];
var d = [ 1, 'a', 3, 4 ];

alert( CKEDITOR.tools.arrayCompare( a, b ) );  // false
alert( CKEDITOR.tools.arrayCompare( a, c ) );  // true
alert( CKEDITOR.tools.arrayCompare( a, d ) );  // false
Parameters:
{Array} arrayA
An array to be compared.
{Array} arrayB
The other array to be compared.
Returns:
{Boolean} "true" is the arrays have the same lenght and their elements match.

<static> {Function} CKEDITOR.tools.bind(func, obj)
Since: 3.0
Creates a function that will always execute in the context of a specified object.
var obj = { text : 'My Object' };

function alertText()
{
    alert( this.text );
}

var newFunc = CKEDITOR.tools.bind( alertText, obj );
newFunc();  // Alerts "My Object".
Parameters:
{Function} func
The function to be executed.
{Object} obj
The object to which bind the execution context.
Returns:
{Function} The function that can be used to execute the "func" function in the context of "obj".

<static> {Undefined} CKEDITOR.tools.buildStyleHtml(css)
Since: 3.0
Build the HTML snippet of a set of <style>/<link>.
NO EXAMPLE AVAILABLE
Parameters:
{Undefined} css
{String|Array} Each of which are url (absolute) of a CSS file or a trunk of style text.

<static> {Undefined} CKEDITOR.tools.buildTableMap(table)
Since: 3.0
Create a two-dimension array that reflects the actual layout of table cells, with cell spans, with mappings to the original td elements.
Defined in: plugins/tabletools/plugin.js.
NO EXAMPLE AVAILABLE
Parameters:
{Undefined} table
{CKEDITOR.dom.element}

<static> {Any} CKEDITOR.tools.callFunction(ref, params)
Since: 3.0
Executes a function based on the reference created with CKEDITOR.tools.addFunction.
var ref = CKEDITOR.tools.addFunction(
    function()
    {
        alert( 'Hello!');
    });
CKEDITOR.tools.callFunction( ref );  // Hello!
Parameters:
{Number} ref
The function reference created with CKEDITOR.tools.addFunction.
{[Any|[Any|...]} params
Any number of parameters to be passed to the executed function.
Returns:
{Any} The return value of the function.

<static> {Undefined} CKEDITOR.tools.capitalize(str)
Since: 3.0
Turn the first letter of string to upper-case.
NO EXAMPLE AVAILABLE
Parameters:
{String} str

<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> {String} CKEDITOR.tools.convertRgbToHex(styleText)
Since: 3.0
Find and convert rgb(x,x,x) colors definition to hexadecimal notation.
NO EXAMPLE AVAILABLE
Parameters:
{String} styleText
The style data (or just a string containing rgb colors) to be converted.
Returns:
{String} The style data with rgb colors converted to hexadecimal equivalents.

<static> {Function} CKEDITOR.tools.createClass(definition)
Since: 3.0
Class creation based on prototype inheritance, with supports of the following features:
NO EXAMPLE AVAILABLE
Parameters:
{Object} definition
The class definition object.
Returns:
{Function} A class-like JavaScript function.

<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> {Undefined} CKEDITOR.tools.genKey(subKey)
Since: 3.0
Generate a combined key from a series of params.
var key = CKEDITOR.tools.genKey( 'key1', 'key2', 'key3' );
alert( key );		// "key1-key2-key3".
Parameters:
{String} subKey
One or more string used as sub keys.

<static> {String} CKEDITOR.tools.getNextId()
Since: 3.0
Gets a unique ID for CKEditor's interface elements. It returns a string with the "cke_" prefix and a progressive number.
alert( CKEDITOR.tools.getNextId() );  // "cke_1" (e.g.)
alert( CKEDITOR.tools.getNextId() );  // "cke_2"
Returns:
{String} A unique ID.

<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> {String} CKEDITOR.tools.htmlEncodeAttr(The)
Since: 3.0
Replace special HTML characters in HTMLElement's attribute with their relative HTML entity values.
element.setAttribute( 'title', '' );
alert( CKEDITOR.tools.htmlEncodeAttr( element.getAttribute( 'title' ) );  // ">a " b <"
Parameters:
{String} The
attribute's value to be encoded.
Returns:
{String} The encode value.

<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> {Undefined} CKEDITOR.tools.isEmpty(object)
Since: 3.0
Whether the object contains no properties of it's own.
NO EXAMPLE AVAILABLE
Parameters:
{Undefined} object

<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> {String} CKEDITOR.tools.normalizeCssText(styleText, nativeNormalize)
Since: 3.0
Try to avoid differences in the style attribute.
NO EXAMPLE AVAILABLE
Parameters:
{String} styleText
The style data to be normalized.
{Boolean} nativeNormalize Optional, Default: false
Parse the data using the browser.
Returns:
{String} The normalized value.

<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.parseCssText(styleText, normalize, nativeNormalize)
Since: 3.0
Turn inline style text properties into one hash.
NO EXAMPLE AVAILABLE
Parameters:
{String} styleText
The style data to be parsed.
{Boolean} normalize Optional, Default: false
Normalize properties and values (e.g. trim spaces, convert to lower case).
{Boolean} nativeNormalize Optional, Default: false
Parse the data using the browser.
Returns:
{String} The object containing parsed properties.

<static> {Undefined} CKEDITOR.tools.removeFunction(ref)
Since: 3.0
Removes the function reference created with {@see CKEDITOR.tools.addFunction}.
NO EXAMPLE AVAILABLE
Parameters:
{Number} ref
The function reference created with CKEDITOR.tools.addFunction.

<static> {Undefined} CKEDITOR.tools.repeat(str, times)
Since: 3.0
String specified by {@param str} repeats {@param times} times.
NO EXAMPLE AVAILABLE
Parameters:
{Undefined} str
{Undefined} times

<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.

<static> {Undefined} CKEDITOR.tools.tryThese()
Since: 3.0
Return the first successfully executed function's return value that doesn't throw any exception.
NO EXAMPLE AVAILABLE

{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-2010, CKSource - Frederico Knabben. All rights reserved.