Namespace CKEDITOR.tools
Utility functions.
Defined in: core/tools.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Utility functions.
|
Method Attributes | Method Name and Description |
---|---|
<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)
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.indexOf(array, entry)
Returns the index of an element in an array.
|
<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.
|
Method Detail
<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)
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
- Indicates that properties already present in the target object must be overwritten. This must be the last parameter in the function call.
- 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 > B & C < D"
- Parameters:
- {String} text
- The string to be encoded.
- Returns:
- {String} The encode string.
<static>
{Number}
CKEDITOR.tools.indexOf(array, entry)
Since:
3.0
Returns the index of an element in an array.
var letters = [ 'a', 'b', 'c' ]; alert( CKEDITOR.tools.indexOf( letters, 'b' ) ); "1"
- Parameters:
- {Array} array
- The array to be searched.
- {Object} entry
- The element to be found.
- Returns:
- {Number} The (zero based) index of the first entry that matches the entry, or -1 if not found.
<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.