Namespace CKFinder.tools
Constructor Attributes | Constructor Name and Description |
---|---|
Utility functions.
|
Method Attributes | Method Name and Description |
---|---|
<static> |
CKFinder.tools.addFocusIndicator(Node)
Sets/Removes CSS classes to show the focused element.
|
<static> |
CKFinder.tools.addFunction(fn, scope)
Creates a function reference that can be called later using
CKFinder.tools.callFunction.
|
<static> |
CKFinder.tools.arrayCompare(arrayA, arrayB)
Compares arrays.
|
<static> |
CKFinder.tools.bind(func, obj)
Creates a function that will always execute in the context of a
specified object.
|
<static> |
CKFinder.tools.callFunction(index, params)
Calls an anonymous function based on the reference created with
CKFinder.tools.addFunction.
|
<static> |
CKFinder.tools.capitalize(str)
Turns the first letter of a string to upper-case.
|
<static> |
CKFinder.tools.clone(object)
Creates a deep copy of an object.
|
<static> |
CKFinder.tools.createClass(definiton)
Class creation based on prototype inheritance that supports the
following features:
|
<static> |
CKFinder.tools.cssStyleToDomStyle(cssName)
Transforms a CSS property name to its relative DOM style name.
|
<static> |
CKFinder.tools.deepCopy(obj)
Recursively copies a given object.
|
<static> |
CKFinder.tools.extend(target, source[,souce(n)], overwrite, properties)
Copies the properties from one object to another.
|
<static> |
CKFinder.tools.formatSize(size, lang, isKb)
Provides centralized formatting for file sizes.
|
<static> |
CKFinder.tools.formatSpeed(speed, lang)
Provides centralized formatting for speeds.
|
<static> |
CKFinder.tools.getCookie(name)
Gets a cookie.
|
<static> |
CKFinder.tools.getNextNumber()
Gets a unique number for this CKFinder execution session.
|
<static> |
CKFinder.tools.getUrlParam(paramName, sourceWindow)
Returns value from the query string.
|
<static> |
CKFinder.tools.htmlEncode(text)
Replaces special HTML characters in a string with their relative HTML
entity values.
|
<static> |
CKFinder.tools.indexOf(array, entry)
Returns the index of an element in an array.
|
<static> |
CKFinder.tools.isArray(object)
Checks if an object is an Array.
|
<static> |
CKFinder.tools.ltrim(str)
Removes spaces from the start (left side) of a string.
|
<static> |
CKFinder.tools.override(originalFunction, functionBuilder)
Creates a function override.
|
<static> |
CKFinder.tools.removeFunction(ref)
Removes the function reference created with {@see CKEDITOR.tools.addFunction}.
|
<static> |
CKFinder.tools.repeat(str, times)
Repeats a string.
|
<static> |
CKFinder.tools.rtrim(str)
Removes spaces from the end (right side) of a string.
|
<static> |
CKFinder.tools.setCookie(name, value, expireOnBrowserClose)
Sets a cookie.
|
<static> |
CKFinder.tools.setTimeout(func, milliseconds, scope, args, ownerWindow)
Executes a function after a specified delay.
|
<static> |
CKFinder.tools.trim(str)
Removes spaces from the start and the end of a string.
|
dCopy(source)
Creates an object which is an instance of a class whose prototype is a
predefined object.
|
Namespace Detail
CKFinder.tools
Since:
2.0
Utility functions.
var foo = CKFinder.tools.htmlEncode( "<b>" );
Method Detail
<static>
{Undefined}
CKFinder.tools.addFocusIndicator(Node)
Since:
2.0
Sets/Removes CSS classes to show the focused element.
NO EXAMPLE AVAILABLE
- Parameters:
- {CKFinder.dom.node} Node
- to watch.
<static>
{Number}
CKFinder.tools.addFunction(fn, scope)
Since:
2.0
Creates a function reference that can be called later using
CKFinder.tools.callFunction. This approach is especially useful to
make DOM attribute function calls to JavaScript-defined functions.
var ref = CKFinder.tools.addFunction( function() { alert( 'Hello!'); }); CKFinder.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 CKFinder.tools.callFunction.
<static>
{Boolean}
CKFinder.tools.arrayCompare(arrayA, arrayB)
Since:
2.0
Compares arrays.
- Parameters:
- {Array} arrayA
- An array.
- {Array} arrayB
- An array.
- Returns:
- {Boolean} True if arrays are equal.
<static>
{Function}
CKFinder.tools.bind(func, obj)
Since:
2.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 the execution context should be bound.
- Returns:
- {Function} The function that can be used to execute the "func" function in the context of "obj".
<static>
{Any}
CKFinder.tools.callFunction(index, params)
Since:
2.0
Calls an anonymous function based on the reference created with
CKFinder.tools.addFunction.
var ref = CKFinder.tools.addFunction( function() { alert( 'Hello!'); }); CKEDITOR.tools.callFunction( ref ); // Hello!
- Parameters:
- {Number} index
- Function reference created with CKFinder.tools.addFunction.
- {[Any|[Any|...]} params
- Any number of parameters to be passed to the called function.
- Returns:
- {Any} The return value of the function.
<static>
{Undefined}
CKFinder.tools.capitalize(str)
Since:
2.0
Turns the first letter of a string to upper-case.
NO EXAMPLE AVAILABLE
- Parameters:
- {String} str
<static>
{Object}
CKFinder.tools.clone(object)
Since:
2.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 = CKFinder.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}
CKFinder.tools.createClass(definiton)
Since:
2.0
Class creation based on prototype inheritance that supports 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}
CKFinder.tools.cssStyleToDomStyle(cssName)
Since:
2.0
Transforms a CSS property name to its relative DOM style name.
alert( CKFinder.tools.cssStyleToDomStyle( 'background-color' ) ); // "backgroundColor" alert( CKFinder.tools.cssStyleToDomStyle( 'float' ) ); // "cssFloat"
- Parameters:
- {String} cssName
- The CSS property name.
- Returns:
- {String} The transformed name.
<static>
{Object}
CKFinder.tools.deepCopy(obj)
Since:
2.0
Recursively copies a given object.
NO EXAMPLE AVAILABLE
- Parameters:
- {Object} obj
- Object to copy.
- Returns:
- {Object} Returns the copied object
<static>
{Object}
CKFinder.tools.extend(target, source[,souce(n)], overwrite, properties)
Since:
2.0
Copies the properties from one object to another. By default, properties
already present in the target object are not overwritten.
// Create a sample object. var myObject = { prop1 : true }; // Extend the above object with two properties. CKFinder.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 the properties will be copied. Any number of objects can be passed to this function.
- {Boolean} overwrite Optional
- If
true
is specified, it indicates that the 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}
CKFinder.tools.formatSize(size, lang, isKb)
Since:
2.2
Provides centralized formatting for file sizes.
NO EXAMPLE AVAILABLE
- Parameters:
- {Number} size
- Number to format (kilobytes).
- {Object} lang
- Reference to app.lang.
- {Boolean} isKb
- Whether the input data is already rounded kB.
<static>
{Undefined}
CKFinder.tools.formatSpeed(speed, lang)
Since:
2.2
Provides centralized formatting for speeds.
NO EXAMPLE AVAILABLE
- Parameters:
- {Number} speed
- Number to format (kilobytes/second).
- {Object} lang
- Reference to app.lang.
<static>
{String}
CKFinder.tools.getCookie(name)
Since:
2.0
Gets a cookie.
NO EXAMPLE AVAILABLE
- Parameters:
- {String} name
- Cookie name.
- Returns:
- {String} Cookie value.
<static>
{Number}
CKFinder.tools.getNextNumber()
Since:
2.0
Gets a unique number for this CKFinder execution session. It returns
consecutive numbers starting at 1.
alert( CKFinder.tools.getNextNumber() ); // "1" (e.g.) alert( CKFinder.tools.getNextNumber() ); // "2"
- Returns:
- {Number} A unique number.
<static>
{String}
CKFinder.tools.getUrlParam(paramName, sourceWindow)
Since:
2.0
Returns value from the query string.
// If current URL is index.php?foo=bar alert( CKFinder.tools.getUrlParam('foo') ); // 'bar'
- Parameters:
- {String} paramName
- Name of the argument in the URL.
- {Object} sourceWindow
- (Optional) Source window.
- Returns:
- {String} Returns the value of a given argument (if found in the query string, null otherwise).
<static>
{String}
CKFinder.tools.htmlEncode(text)
Since:
2.0
Replaces special HTML characters in a string with their relative HTML
entity values.
alert( CKFinder.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}
CKFinder.tools.indexOf(array, entry)
Since:
2.0
Returns the index of an element in an array.
var letters = [ 'a', 'b', 0, 'c', false ]; alert( CKFinder.tools.indexOf( letters, '0' ) ); "-1" because 0 !== '0' alert( CKFinder.tools.indexOf( letters, false ) ); "4" because 0 !== false
- 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}
CKFinder.tools.isArray(object)
Since:
2.0
Checks if an object is an Array.
alert( CKFinder.tools.isArray( [] ) ); // "true" alert( CKFinder.tools.isArray( 'Test' ) ); // "false"
- Parameters:
- {Object} object
- The object to be checked.
- Returns:
- {Undefined}
true
if the object is an Array, otherwisefalse
.
<static>
{String}
CKFinder.tools.ltrim(str)
Since:
2.0
Removes spaces from the start (left side) of a string. The following
characters are removed: space, tab, line break, line feed.
alert( CKFinder.tools.ltrim( ' example ' ); // "example "
- Parameters:
- {String} str
- The text from which the spaces will be removed.
- Returns:
- {String} The modified string excluding the removed spaces.
<static>
{Function}
CKFinder.tools.override(originalFunction, functionBuilder)
Since:
2.0
Creates a function override.
var example = { myFunction : function( name ) { alert( 'Name: ' + name ); } }; example.myFunction = CKFinder.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>
{Undefined}
CKFinder.tools.removeFunction(ref)
Since:
2.0
Removes the function reference created with {@see CKEDITOR.tools.addFunction}.
NO EXAMPLE AVAILABLE
- Parameters:
- {Number} ref
- The function reference created with CKFinder.tools.addFunction.
<static>
{String}
CKFinder.tools.repeat(str, times)
Since:
2.0
Repeats a string.
NO EXAMPLE AVAILABLE
- Parameters:
- {String} str
- String to repeat.
- {Number} times
- Number of time the input string should be repeated.
- Returns:
- {String} Returns the repeated string.
<static>
{String}
CKFinder.tools.rtrim(str)
Since:
2.0
Removes spaces from the end (right side) of a string. The following
characters are removed: space, tab, line break, line feed.
alert( CKFinder.tools.ltrim( ' example ' ); // " example"
- Parameters:
- {String} str
- The text from which the spaces will be removed.
- Returns:
- {String} The modified string excluding the removed spaces.
<static>
{Undefined}
CKFinder.tools.setCookie(name, value, expireOnBrowserClose)
Since:
2.0
Sets a cookie.
NO EXAMPLE AVAILABLE
- Parameters:
- {String} name
- Cookie name.
- {String} value
- Cookie value.
- {Boolean} expireOnBrowserClose
- Whether the cookie shoud expire when the browser is closed.
<static>
{Object}
CKFinder.tools.setTimeout(func, milliseconds, scope, args, ownerWindow)
Since:
2.0
Executes a function after a specified delay.
CKFinder.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 store 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}
CKFinder.tools.trim(str)
Since:
2.0
Removes spaces from the start and the end of a string. The following
characters are removed: space, tab, line break, line feed.
alert( CKFinder.tools.trim( ' example ' ); // "example"
- Parameters:
- {String} str
- The text from which the spaces will be removed.
- Returns:
- {String} The modified string without the boundary spaces.
{Object}
dCopy(source)
Since:
2.0
Creates an object which is an instance of a class whose 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.